-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
/
VideoReferenceClock.h
59 lines (46 loc) · 2 KB
/
VideoReferenceClock.h
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
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "threads/CriticalSection.h"
#include "threads/Event.h"
#include "threads/Thread.h"
#include <memory>
class CVideoSync;
class CVideoReferenceClock : CThread
{
public:
CVideoReferenceClock();
~CVideoReferenceClock() override;
int64_t GetTime(bool interpolated = true);
void SetSpeed(double Speed);
double GetSpeed();
double GetRefreshRate(double* interval = nullptr);
bool GetClockInfo(int& MissedVblanks, double& ClockSpeed, double& RefreshRate) const;
private:
void Process() override;
void Start();
void UpdateRefreshrate();
void UpdateClock(int NrVBlanks, bool CheckMissed);
double UpdateInterval() const;
int64_t TimeOfNextVblank() const;
static void CBUpdateClock(int NrVBlanks, uint64_t time, void *clock);
bool m_destructing = false;
int64_t m_CurrTime; //the current time of the clock when using vblank as clock source
int64_t m_LastIntTime; //last interpolated clock value, to make sure the clock doesn't go backwards
double m_CurrTimeFract; //fractional part that is lost due to rounding when updating the clock
double m_ClockSpeed; //the frequency of the clock set by VideoPlayer
int64_t m_SystemFrequency; //frequency of the systemclock
bool m_UseVblank; //set to true when vblank is used as clock source
double m_RefreshRate; //current refreshrate
int m_MissedVblanks; //number of clock updates missed by the vblank clock
int m_TotalMissedVblanks;//total number of clock updates missed, used by codec information screen
int64_t m_VblankTime; //last time the clock was updated when using vblank as clock
CEvent m_vsyncStopEvent;
mutable CCriticalSection m_CritSection;
std::unique_ptr<CVideoSync> m_pVideoSync;
};