diff options
author | Markus Pfau <pfau@peak3d.de> | 2018-10-17 09:14:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-17 09:14:19 +0200 |
commit | dc33111dc23d00372e48779ddf95a8c8cb1c4ffc (patch) | |
tree | 04c28a1fdc075acd4ab82f67ea61028910bb4b7c | |
parent | 0f435864f135ad4b9c960b7bca457c786156d2c2 (diff) | |
parent | a7a9e31c185b24250479f7eafb952db168fc1629 (diff) |
Merge pull request #14624 from peak3d/latency
[Android] more frame timing optimizations
-rw-r--r-- | xbmc/platform/android/activity/XBMCApp.cpp | 16 | ||||
-rw-r--r-- | xbmc/platform/android/activity/XBMCApp.h | 3 | ||||
-rw-r--r-- | xbmc/windowing/android/WinSystemAndroidGLESContext.cpp | 5 | ||||
-rw-r--r-- | xbmc/windowing/android/WinSystemAndroidGLESContext.h | 2 |
4 files changed, 23 insertions, 3 deletions
diff --git a/xbmc/platform/android/activity/XBMCApp.cpp b/xbmc/platform/android/activity/XBMCApp.cpp index a3540907b6..55aaa03e1a 100644 --- a/xbmc/platform/android/activity/XBMCApp.cpp +++ b/xbmc/platform/android/activity/XBMCApp.cpp @@ -128,6 +128,7 @@ std::vector<androidPackage> CXBMCApp::m_applications; CVideoSyncAndroid* CXBMCApp::m_syncImpl = NULL; CEvent CXBMCApp::m_vsyncEvent; std::vector<CActivityResultEvent*> CXBMCApp::m_activityResultEvents; + int64_t CXBMCApp::m_frameTimeNanos = 0; float CXBMCApp::m_refreshRate = 0.0f; @@ -1186,12 +1187,23 @@ void CXBMCApp::doFrame(int64_t frameTimeNanos) // Calculate the time, when next surface buffer should be rendered m_frameTimeNanos = frameTimeNanos; - if (m_refreshRate) - m_frameTimeNanos += static_cast<int64_t>(1500000000ll / m_refreshRate); m_vsyncEvent.Set(); } +int64_t CXBMCApp::GetNextFrameTime() +{ + if (m_refreshRate > 0.0001f) + return m_frameTimeNanos + static_cast<int64_t>(1500000000ll / m_refreshRate); + else + return m_frameTimeNanos; +} + +float CXBMCApp::GetFrameLatencyMs() +{ + return (CurrentHostCounter() - m_frameTimeNanos) * 0.000001; +} + bool CXBMCApp::WaitVSync(unsigned int milliSeconds) { return m_vsyncEvent.WaitMSec(milliSeconds); diff --git a/xbmc/platform/android/activity/XBMCApp.h b/xbmc/platform/android/activity/XBMCApp.h index 16845357fe..8ccd1d18af 100644 --- a/xbmc/platform/android/activity/XBMCApp.h +++ b/xbmc/platform/android/activity/XBMCApp.h @@ -191,7 +191,8 @@ public: void ProcessSlow(); static bool WaitVSync(unsigned int milliSeconds); - static int64_t GetNextFrameTime(){ return m_frameTimeNanos; }; + static int64_t GetNextFrameTime(); + static float GetFrameLatencyMs(); bool getVideosurfaceInUse(); void setVideosurfaceInUse(bool videosurfaceInUse); diff --git a/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp b/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp index 28dd1d1327..3c504ce121 100644 --- a/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp +++ b/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp @@ -98,6 +98,11 @@ void CWinSystemAndroidGLESContext::PresentRenderImpl(bool rendered) CXBMCApp::get()->WaitVSync(1000); } +float CWinSystemAndroidGLESContext::GetFrameLatencyAdjustment() +{ + return CXBMCApp::GetFrameLatencyMs(); +} + EGLDisplay CWinSystemAndroidGLESContext::GetEGLDisplay() const { return m_pGLContext.GetEGLDisplay(); diff --git a/xbmc/windowing/android/WinSystemAndroidGLESContext.h b/xbmc/windowing/android/WinSystemAndroidGLESContext.h index e10be6e04d..f674e3dcd9 100644 --- a/xbmc/windowing/android/WinSystemAndroidGLESContext.h +++ b/xbmc/windowing/android/WinSystemAndroidGLESContext.h @@ -31,6 +31,8 @@ public: virtual std::unique_ptr<CVideoSync> GetVideoSync(void *clock) override; + float GetFrameLatencyAdjustment() override; + EGLDisplay GetEGLDisplay() const; EGLSurface GetEGLSurface() const; EGLContext GetEGLContext() const; |