summaryrefslogtreecommitdiffstats
path: root/xbmc/windowing/X11/VideoSyncOML.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/windowing/X11/VideoSyncOML.cpp
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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;
+}
+