xbmc
VideoReferenceClock.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 #include "threads/Event.h"
13 #include "threads/Thread.h"
14 
15 #include <memory>
16 
17 class CVideoSync;
18 
20 {
21  public:
23  ~CVideoReferenceClock() override;
24 
25  int64_t GetTime(bool interpolated = true);
26  void SetSpeed(double Speed);
27  double GetSpeed();
28  double GetRefreshRate(double* interval = nullptr);
29  bool GetClockInfo(int& MissedVblanks, double& ClockSpeed, double& RefreshRate) const;
30 
31  void UpdateClock(int NrVBlanks, uint64_t time);
32 
33  private:
34  void Process() override;
35  void Start();
36  void UpdateRefreshrate();
37  void UpdateClockInternal(int NrVBlanks, bool CheckMissed);
38  double UpdateInterval() const;
39  int64_t TimeOfNextVblank() const;
40 
41  int64_t m_CurrTime; //the current time of the clock when using vblank as clock source
42  int64_t m_LastIntTime; //last interpolated clock value, to make sure the clock doesn't go backwards
43  double m_CurrTimeFract; //fractional part that is lost due to rounding when updating the clock
44  double m_ClockSpeed; //the frequency of the clock set by VideoPlayer
45  int64_t m_SystemFrequency; //frequency of the systemclock
46 
47  bool m_UseVblank; //set to true when vblank is used as clock source
48  double m_RefreshRate; //current refreshrate
49  int m_MissedVblanks; //number of clock updates missed by the vblank clock
50  int m_TotalMissedVblanks;//total number of clock updates missed, used by codec information screen
51  int64_t m_VblankTime; //last time the clock was updated when using vblank as clock
52 
53  CEvent m_vsyncStopEvent;
54 
55  mutable CCriticalSection m_CritSection;
56 
57  std::unique_ptr<CVideoSync> m_pVideoSync;
58 };
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
Definition: Thread.h:44
Definition: VideoReferenceClock.h:19
Definition: VideoSync.h:15