summaryrefslogtreecommitdiffstats
path: root/xbmc/windowing/X11/VideoSyncOML.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/windowing/X11/VideoSyncOML.cpp')
-rw-r--r--xbmc/windowing/X11/VideoSyncOML.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/xbmc/windowing/X11/VideoSyncOML.cpp b/xbmc/windowing/X11/VideoSyncOML.cpp
new file mode 100644
index 0000000..2dc91fe
--- /dev/null
+++ b/xbmc/windowing/X11/VideoSyncOML.cpp
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+#include "VideoSyncOML.h"
+
+#include "utils/TimeUtils.h"
+#include "utils/log.h"
+#include "windowing/GraphicContext.h"
+#include "windowing/X11/WinSystemX11GLContext.h"
+
+#include <unistd.h>
+
+using namespace KODI::WINDOWING::X11;
+
+bool CVideoSyncOML::Setup(PUPDATECLOCK func)
+{
+ CLog::Log(LOGDEBUG, "CVideoSyncOML::{} - setting up OML", __FUNCTION__);
+
+ UpdateClock = func;
+
+ m_abort = false;
+
+ static_cast<CWinSystemX11*>(&m_winSystem)->Register(this);
+
+ return true;
+}
+
+void CVideoSyncOML::Run(CEvent& stopEvent)
+{
+ uint64_t interval, timeSinceVblank, msc;
+
+ timeSinceVblank = m_winSystem.GetVblankTiming(msc, interval);
+
+ while (!stopEvent.Signaled() && !m_abort)
+ {
+ if (interval == 0)
+ {
+ usleep(10000);
+ }
+ else
+ {
+ usleep(interval - timeSinceVblank + 1000);
+ }
+ uint64_t newMsc;
+ timeSinceVblank = m_winSystem.GetVblankTiming(newMsc, interval);
+
+ if (newMsc == msc)
+ {
+ newMsc++;
+ }
+ else if (newMsc < msc)
+ {
+ timeSinceVblank = interval;
+ continue;
+ }
+
+ uint64_t now = CurrentHostCounter();
+ UpdateClock(newMsc - msc, now, m_refClock);
+ msc = newMsc;
+ }
+}
+
+void CVideoSyncOML::Cleanup()
+{
+ m_winSystem.Unregister(this);
+}
+
+void CVideoSyncOML::OnResetDisplay()
+{
+ m_abort = true;
+}
+
+float CVideoSyncOML::GetFps()
+{
+ m_fps = m_winSystem.GetGfxContext().GetFPS();
+ return m_fps;
+}
+