xbmc
DVDClock.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "threads/CriticalSection.h"
12 
13 #include <memory>
14 #include <stdint.h>
15 
17 
18 class CDVDClock
19 {
20 public:
21 
22  CDVDClock();
23  ~CDVDClock();
24 
25  double GetClock(bool interpolated = true);
26  double GetClock(double& absolute, bool interpolated = true);
27 
28  double ErrorAdjust(double error, const char* log);
29  void Discontinuity(double clock, double absolute);
30  void Discontinuity(double clock = 0LL)
31  {
32  Discontinuity(clock, GetAbsoluteClock());
33  }
34 
35  void Reset() { m_bReset = true; }
36  void SetSpeed(int iSpeed);
37  void SetSpeedAdjust(double adjust);
38  double GetSpeedAdjust();
39 
40  double GetClockSpeed();
42  /* tells clock at what framerate video is, to *
43  * allow it to adjust speed for a better match */
44  int UpdateFramerate(double fps, double* interval = NULL);
45 
46  void SetMaxSpeedAdjust(double speed);
47 
48  double GetAbsoluteClock(bool interpolated = true);
49  double GetFrequency() { return (double)m_systemFrequency ; }
50 
51  bool GetClockInfo(int& MissedVblanks, double& ClockSpeed, double& RefreshRate) const;
52  void SetVsyncAdjust(double adjustment);
53  double GetVsyncAdjust();
54 
55  void Pause(bool pause);
56  void Advance(double time);
57 
58 protected:
59  double SystemToAbsolute(int64_t system);
60  int64_t AbsoluteToSystem(double absolute);
61  double SystemToPlaying(int64_t system);
62 
63  CCriticalSection m_critSection;
64  int64_t m_systemUsed;
65  int64_t m_startClock;
66  int64_t m_pauseClock;
67  double m_iDisc;
68  bool m_bReset;
69  bool m_paused;
70  int m_speedAfterPause;
71  std::unique_ptr<CVideoReferenceClock> m_videoRefClock;
72 
73  int64_t m_systemFrequency;
74  int64_t m_systemOffset;
75  CCriticalSection m_systemsection;
76 
77  int64_t m_systemAdjust;
78  int64_t m_lastSystemTime;
79  double m_speedAdjust;
80  double m_vSyncAdjust;
81  double m_frameTime;
82 
83  double m_maxspeedadjust;
84  CCriticalSection m_speedsection;
85 };
double GetClockSpeed()
get the current speed of the clock relative normal system time
Definition: DVDClock.cpp:303
Definition: VideoReferenceClock.h:19
Definition: DVDClock.h:18