2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "threads/CriticalSection.h"
12 #include "threads/Event.h"
13 #include "threads/Thread.h"
19 class CVideoReferenceClock
: CThread
22 CVideoReferenceClock();
23 ~CVideoReferenceClock() override
;
25 int64_t GetTime(bool interpolated
= true);
26 void SetSpeed(double Speed
);
28 double GetRefreshRate(double* interval
= nullptr);
29 bool GetClockInfo(int& MissedVblanks
, double& ClockSpeed
, double& RefreshRate
) const;
31 void UpdateClock(int NrVBlanks
, uint64_t time
);
34 void Process() override
;
36 void UpdateRefreshrate();
37 void UpdateClockInternal(int NrVBlanks
, bool CheckMissed
);
38 double UpdateInterval() const;
39 int64_t TimeOfNextVblank() const;
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
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
53 CEvent m_vsyncStopEvent
;
55 mutable CCriticalSection m_CritSection
;
57 std::unique_ptr
<CVideoSync
> m_pVideoSync
;