[Windows] Fix driver version detection of AMD RDNA+ GPU on Windows 10
[xbmc.git] / xbmc / windowing / X11 / VideoSyncOML.cpp
blob9260503d4af9b81f24d254c56e32aa726d141a38
1 /*
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.
7 */
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"
17 #include <unistd.h>
19 using namespace KODI::WINDOWING::X11;
21 bool CVideoSyncOML::Setup()
23 CLog::Log(LOGDEBUG, "CVideoSyncOML::{} - setting up OML", __FUNCTION__);
25 m_abort = false;
27 static_cast<CWinSystemX11*>(&m_winSystem)->Register(this);
29 return true;
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)
40 if (interval == 0)
42 usleep(10000);
44 else
46 usleep(interval - timeSinceVblank + 1000);
48 uint64_t newMsc;
49 timeSinceVblank = m_winSystem.GetVblankTiming(newMsc, interval);
51 if (newMsc == msc)
53 newMsc++;
55 else if (newMsc < msc)
57 timeSinceVblank = interval;
58 continue;
61 uint64_t now = CurrentHostCounter();
62 m_refClock->UpdateClock(newMsc - msc, now);
63 msc = newMsc;
67 void CVideoSyncOML::Cleanup()
69 m_winSystem.Unregister(this);
72 void CVideoSyncOML::OnResetDisplay()
74 m_abort = true;
77 float CVideoSyncOML::GetFps()
79 m_fps = m_winSystem.GetGfxContext().GetFPS();
80 return m_fps;