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  private:
32  void Process() override;
33  void Start();
34  void UpdateRefreshrate();
35  void UpdateClock(int NrVBlanks, bool CheckMissed);
36  double UpdateInterval() const;
37  int64_t TimeOfNextVblank() const;
38  static void CBUpdateClock(int NrVBlanks, uint64_t time, void *clock);
39 
40  int64_t m_CurrTime; //the current time of the clock when using vblank as clock source
41  int64_t m_LastIntTime; //last interpolated clock value, to make sure the clock doesn't go backwards
42  double m_CurrTimeFract; //fractional part that is lost due to rounding when updating the clock
43  double m_ClockSpeed; //the frequency of the clock set by VideoPlayer
44  int64_t m_SystemFrequency; //frequency of the systemclock
45 
46  bool m_UseVblank; //set to true when vblank is used as clock source
47  double m_RefreshRate; //current refreshrate
48  int m_MissedVblanks; //number of clock updates missed by the vblank clock
49  int m_TotalMissedVblanks;//total number of clock updates missed, used by codec information screen
50  int64_t m_VblankTime; //last time the clock was updated when using vblank as clock
51 
52  CEvent m_vsyncStopEvent;
53 
54  mutable CCriticalSection m_CritSection;
55 
56  std::unique_ptr<CVideoSync> m_pVideoSync;
57 };
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
Definition: Thread.h:44
Definition: VideoReferenceClock.h:19
Definition: VideoSync.h:16