aboutsummaryrefslogtreecommitdiff
path: root/src/visualizations/XBMCProjectM/libprojectM/TimeKeeper.hpp
blob: 60cb64c543f0d7244791783113bf7a735371511e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef TimeKeeper_HPP
#define TimeKeeper_HPP

#ifndef WIN32
#include <sys/time.h>
#endif

#include "timer.h"
#include <pthread.h>

#define HARD_CUT_DELAY 3

class TimeKeeper
{

public:

  TimeKeeper(double presetDuration, double smoothDuration, double easterEgg);
  ~TimeKeeper();

  void UpdateTimers();

  void StartPreset();
  void StartSmoothing();
  void EndSmoothing();
 
  bool CanHardCut();

  double SmoothRatio();
  bool IsSmoothing();

  double GetRunningTime(); 

  double PresetProgressA();
  double PresetProgressB();

  int PresetFrameA();
  int PresetFrameB();

  double sampledPresetDuration();

#ifndef WIN32
  /* The first ticks value of the application */
  struct timeval startTime;
#else  
  long startTime;
#endif /** !WIN32 */

private:

  double _easterEgg;
  double _presetDuration;
  double _presetDurationA;
  double _presetDurationB;
  double _smoothDuration;

  double _currentTime;
  double _presetTimeA;
  double _presetTimeB;
  int _presetFrameA;
  int _presetFrameB;

  bool _isSmoothing;

  pthread_mutex_t _tk_lock;

};
#endif