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.
9 #include "VideoSyncOML.h"
11 #include "cores/VideoPlayer/VideoReferenceClock.h"
12 #include "utils/TimeUtils.h"
13 #include "utils/log.h"
14 #include "windowing/GraphicContext.h"
15 #include "windowing/X11/WinSystemX11GLContext.h"
19 using namespace KODI::WINDOWING::X11
;
21 bool CVideoSyncOML::Setup()
23 CLog::Log(LOGDEBUG
, "CVideoSyncOML::{} - setting up OML", __FUNCTION__
);
27 static_cast<CWinSystemX11
*>(&m_winSystem
)->Register(this);
32 void CVideoSyncOML::Run(CEvent
& stopEvent
)
34 uint64_t interval
, timeSinceVblank
, msc
;
36 timeSinceVblank
= m_winSystem
.GetVblankTiming(msc
, interval
);
38 while (!stopEvent
.Signaled() && !m_abort
)
46 usleep(interval
- timeSinceVblank
+ 1000);
49 timeSinceVblank
= m_winSystem
.GetVblankTiming(newMsc
, interval
);
55 else if (newMsc
< msc
)
57 timeSinceVblank
= interval
;
61 uint64_t now
= CurrentHostCounter();
62 m_refClock
->UpdateClock(newMsc
- msc
, now
);
67 void CVideoSyncOML::Cleanup()
69 m_winSystem
.Unregister(this);
72 void CVideoSyncOML::OnResetDisplay()
77 float CVideoSyncOML::GetFps()
79 m_fps
= m_winSystem
.GetGfxContext().GetFPS();