diff options
author | Peter Frühberger <Peter.Fruehberger@gmail.com> | 2018-12-26 14:11:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-26 14:11:46 +0100 |
commit | 8a178cd41796d5a03966bd4fa872e2463b8f84f2 (patch) | |
tree | 5b2f5a6c8da3d0149757464ef3927a2a396bf062 | |
parent | 73cbb274b7bb7558094aa31749579804e385aacc (diff) | |
parent | 74f81e6077c23469d5e9c2d20ae4496e37460f73 (diff) |
Merge pull request #15123 from FernetMenta/x11
X11: make make on vblank in SwapBuffers an advanced setting
-rw-r--r-- | xbmc/settings/AdvancedSettings.cpp | 6 | ||||
-rw-r--r-- | xbmc/settings/AdvancedSettings.h | 2 | ||||
-rw-r--r-- | xbmc/windowing/X11/GLContext.h | 3 | ||||
-rw-r--r-- | xbmc/windowing/X11/GLContextEGL.cpp | 39 |
4 files changed, 39 insertions, 11 deletions
diff --git a/xbmc/settings/AdvancedSettings.cpp b/xbmc/settings/AdvancedSettings.cpp index f6ba324537..f3931613ed 100644 --- a/xbmc/settings/AdvancedSettings.cpp +++ b/xbmc/settings/AdvancedSettings.cpp @@ -568,6 +568,12 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file) XMLUtils::GetBoolean(pElement, "omxdecodestartwithvalidframe", m_omxDecodeStartWithValidFrame); } + pElement = pRootElement->FirstChildElement("x11"); + if (pElement) + { + XMLUtils::GetBoolean(pElement, "omlsync", m_omlSync); + } + pElement = pRootElement->FirstChildElement("video"); if (pElement) { diff --git a/xbmc/settings/AdvancedSettings.h b/xbmc/settings/AdvancedSettings.h index 1f6d5e06b0..1df75ad562 100644 --- a/xbmc/settings/AdvancedSettings.h +++ b/xbmc/settings/AdvancedSettings.h @@ -135,6 +135,8 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler bool m_omxDecodeStartWithValidFrame; + bool m_omlSync = false; + float m_videoSubsDelayRange; float m_videoAudioDelayRange; bool m_videoUseTimeSeeking; diff --git a/xbmc/windowing/X11/GLContext.h b/xbmc/windowing/X11/GLContext.h index fdb17e5f76..a3d24b02e1 100644 --- a/xbmc/windowing/X11/GLContext.h +++ b/xbmc/windowing/X11/GLContext.h @@ -34,4 +34,7 @@ public: std::string m_extensions; Display *m_dpy; + +protected: + bool m_omlSync = false; }; diff --git a/xbmc/windowing/X11/GLContextEGL.cpp b/xbmc/windowing/X11/GLContextEGL.cpp index b8d0ff85eb..272cd96214 100644 --- a/xbmc/windowing/X11/GLContextEGL.cpp +++ b/xbmc/windowing/X11/GLContextEGL.cpp @@ -18,6 +18,9 @@ #include "GLContextEGL.h" #include "utils/log.h" #include <EGL/eglext.h> +#include "ServiceBroker.h" +#include "settings/AdvancedSettings.h" +#include "settings/SettingsComponent.h" #define EGL_NO_CONFIG (EGLConfig)0 @@ -30,6 +33,12 @@ CGLContextEGL::CGLContextEGL(Display *dpy) : CGLContext(dpy) m_eglConfig = EGL_NO_CONFIG; eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT"); + + CSettingsComponent *settings = CServiceBroker::GetSettingsComponent(); + if (settings) + { + m_omlSync = settings->GetAdvancedSettings()->m_omlSync; + } } CGLContextEGL::~CGLContextEGL() @@ -424,6 +433,7 @@ void CGLContextEGL::SwapBuffers() if ((msc1 - m_sync.msc1) > 2) { m_sync.cont = 0; + CLog::Log(LOGDEBUG, "CGLContextEGL::SwapBuffers: sync reset"); } // we want to block in SwapBuffers @@ -439,22 +449,29 @@ void CGLContextEGL::SwapBuffers() { m_sync.interval = (ust1 - m_sync.ust1) / (msc1 - m_sync.msc1); m_sync.cont++; + CLog::Log(LOGDEBUG, "CGLContextEGL::SwapBuffers: sync interval: %ld", m_sync.interval); } } - else if ((m_sync.cont == 5) && (msc2 == msc1)) + else if (m_sync.cont == 5 && m_omlSync) { - // if no vertical retrace has occurred in eglSwapBuffers, - // sleep until next vertical retrace - uint64_t lastIncrement = (now / 1000 - ust2); - if (lastIncrement > m_sync.interval) + CLog::Log(LOGDEBUG, "CGLContextEGL::SwapBuffers: sync check blocking"); + + if (msc2 == msc1) { - lastIncrement = m_sync.interval; - CLog::Log(LOGWARNING, "CGLContextEGL::SwapBuffers: last msc time greater than interval"); + // if no vertical retrace has occurred in eglSwapBuffers, + // sleep until next vertical retrace + uint64_t lastIncrement = (now / 1000 - ust2); + if (lastIncrement > m_sync.interval) + { + lastIncrement = m_sync.interval; + CLog::Log(LOGWARNING, "CGLContextEGL::SwapBuffers: last msc time greater than interval"); + } + uint64_t sleeptime = m_sync.interval - lastIncrement; + usleep(sleeptime); + m_sync.cont++; + msc2++; + CLog::Log(LOGDEBUG, "CGLContextEGL::SwapBuffers: sync sleep: %ld", sleeptime); } - uint64_t sleeptime = m_sync.interval - lastIncrement; - usleep(sleeptime); - m_sync.cont++; - msc2++; } else if ((m_sync.cont > 5) && (msc2 == m_sync.msc2)) { |