diff -Nru kodi-18.0+git20180919.0201-fea8a29/BUILDDATE kodi-18.0+git20180920.0201-2c44473/BUILDDATE --- kodi-18.0+git20180919.0201-fea8a29/BUILDDATE 2018-09-19 00:01:58.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/BUILDDATE 2018-09-20 00:01:46.000000000 +0000 @@ -1 +1 @@ -20180919 +20180920 diff -Nru kodi-18.0+git20180919.0201-fea8a29/cmake/scripts/android/Install.cmake kodi-18.0+git20180920.0201-2c44473/cmake/scripts/android/Install.cmake --- kodi-18.0+git20180919.0201-fea8a29/cmake/scripts/android/Install.cmake 2018-07-31 18:47:37.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/cmake/scripts/android/Install.cmake 2018-09-20 00:01:30.000000000 +0000 @@ -82,6 +82,7 @@ src/interfaces/XBMCNsdManagerRegistrationListener.java src/interfaces/XBMCNsdManagerDiscoveryListener.java src/interfaces/XBMCMediaDrmOnEventListener.java + src/interfaces/XBMCDisplayManagerDisplayListener.java src/model/TVEpisode.java src/model/Movie.java src/model/TVShow.java diff -Nru kodi-18.0+git20180919.0201-fea8a29/cmake/scripts/ios/ArchSetup.cmake kodi-18.0+git20180920.0201-2c44473/cmake/scripts/ios/ArchSetup.cmake --- kodi-18.0+git20180919.0201-fea8a29/cmake/scripts/ios/ArchSetup.cmake 2018-09-16 00:01:49.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/cmake/scripts/ios/ArchSetup.cmake 2018-09-20 00:01:30.000000000 +0000 @@ -12,9 +12,13 @@ if(WITH_ARCH) set(ARCH ${WITH_ARCH}) else() - if(CPU STREQUAL armv7 OR CPU STREQUAL arm64) + if(CPU STREQUAL armv7) set(CMAKE_OSX_ARCHITECTURES ${CPU}) - set(ARCH arm-osx) + set(ARCH arm) + set(NEON True) + elseif(CPU STREQUAL arm64) + set(CMAKE_OSX_ARCHITECTURES ${CPU}) + set(ARCH aarch64) set(NEON True) else() message(SEND_ERROR "Unknown CPU: ${CPU}") diff -Nru kodi-18.0+git20180919.0201-fea8a29/debian/changelog kodi-18.0+git20180920.0201-2c44473/debian/changelog --- kodi-18.0+git20180919.0201-fea8a29/debian/changelog 2018-09-19 00:07:08.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/debian/changelog 2018-09-20 00:06:56.000000000 +0000 @@ -1,4 +1,17 @@ -kodi (2:18.0+git20180919.0201-fea8a29-0xenial) xenial; urgency=high +kodi (2:18.0+git20180920.0201-2c44473-0xenial) xenial; urgency=high + + [Markus Pfau] + * [Android] call OnResetDisplay() on HDMI_AUDIO_PLUG event (#14431) + + [peak3d] + * Remove currentClock parameter from CBaseRenderer::AddVideoPicture + + [peak3d] + * Release Surface Buffers 1.5 VSYNC in future and use CLOCK_MONOTONIC + + [Rechi] + * [cmake] set correct ARCH for iOS + [Philipp Kerling] * Move error handling out of CEGLContextUtils::SwapBuffers diff -Nru kodi-18.0+git20180919.0201-fea8a29/debian/changelog.tmp kodi-18.0+git20180920.0201-2c44473/debian/changelog.tmp --- kodi-18.0+git20180919.0201-fea8a29/debian/changelog.tmp 2018-09-19 00:02:29.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/debian/changelog.tmp 2018-09-20 00:02:15.000000000 +0000 @@ -1,4 +1,17 @@ -kodi (2:18.0+git20180919.0201-fea8a29-0dist) dist; urgency=high +kodi (2:18.0+git20180920.0201-2c44473-0dist) dist; urgency=high + + [Markus Pfau] + * [Android] call OnResetDisplay() on HDMI_AUDIO_PLUG event (#14431) + + [peak3d] + * Remove currentClock parameter from CBaseRenderer::AddVideoPicture + + [peak3d] + * Release Surface Buffers 1.5 VSYNC in future and use CLOCK_MONOTONIC + + [Rechi] + * [cmake] set correct ARCH for iOS + [Philipp Kerling] * Move error handling out of CEGLContextUtils::SwapBuffers diff -Nru kodi-18.0+git20180919.0201-fea8a29/debian/changelog.tmp.old kodi-18.0+git20180920.0201-2c44473/debian/changelog.tmp.old --- kodi-18.0+git20180919.0201-fea8a29/debian/changelog.tmp.old 2018-09-19 00:01:58.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/debian/changelog.tmp.old 2018-09-20 00:01:46.000000000 +0000 @@ -1,5 +1,15 @@ kodi (2:18.0+git20180719.0202-3231481-0dist) dist; urgency=high + [Philipp Kerling] + * Move error handling out of CEGLContextUtils::SwapBuffers + + [Philipp Kerling] + * Fix Wayland signal handling destructor and final marking + + [Philipp Kerling] + * Add missing m_eglDisplay check + + [ace20022] * [videoplayer] Fix crash if demuxffmpeg's AddStream method returns null. diff -Nru kodi-18.0+git20180919.0201-fea8a29/tools/android/packaging/xbmc/src/interfaces/XBMCDisplayManagerDisplayListener.java.in kodi-18.0+git20180920.0201-2c44473/tools/android/packaging/xbmc/src/interfaces/XBMCDisplayManagerDisplayListener.java.in --- kodi-18.0+git20180919.0201-fea8a29/tools/android/packaging/xbmc/src/interfaces/XBMCDisplayManagerDisplayListener.java.in 1970-01-01 00:00:00.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/tools/android/packaging/xbmc/src/interfaces/XBMCDisplayManagerDisplayListener.java.in 2018-09-20 00:01:30.000000000 +0000 @@ -0,0 +1,28 @@ +package @APP_PACKAGE@.interfaces; + +import android.hardware.display.DisplayManager; + +public class XBMCDisplayManagerDisplayListener implements DisplayManager.DisplayListener +{ + native void _onDisplayAdded(int displayId); + native void _onDisplayChanged(int displayId); + native void _onDisplayRemoved(int displayId); + + @Override + public void onDisplayAdded(int displayId) + { + _onDisplayAdded(displayId); + } + + @Override + public void onDisplayChanged(int displayId) + { + _onDisplayChanged(displayId); + } + + @Override + public void onDisplayRemoved(int displayId) + { + _onDisplayRemoved(displayId); + } +} diff -Nru kodi-18.0+git20180919.0201-fea8a29/tools/depends/target/libandroidjni/Makefile kodi-18.0+git20180920.0201-2c44473/tools/depends/target/libandroidjni/Makefile --- kodi-18.0+git20180919.0201-fea8a29/tools/depends/target/libandroidjni/Makefile 2018-09-10 10:08:09.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/tools/depends/target/libandroidjni/Makefile 2018-09-20 00:01:30.000000000 +0000 @@ -3,7 +3,7 @@ # lib name, version LIBNAME=libandroidjni -VERSION=6f753a823b587c192d2b41575f4b71f7c3dd69cc +VERSION=fe51b38eedf2b0219d45ae62e763fbe4e45dfb76 SOURCE=archive ARCHIVE=$(VERSION).tar.gz GIT_BASE_URL=https://github.com/xbmc diff -Nru kodi-18.0+git20180919.0201-fea8a29/VERSION kodi-18.0+git20180920.0201-2c44473/VERSION --- kodi-18.0+git20180919.0201-fea8a29/VERSION 2018-09-19 00:01:58.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/VERSION 2018-09-20 00:01:46.000000000 +0000 @@ -1 +1 @@ -fea8a29 +2c44473 diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h 2018-08-26 13:40:15.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h 2018-09-20 00:01:30.000000000 +0000 @@ -53,7 +53,7 @@ // Player functions virtual bool Configure(const VideoPicture &picture, float fps, unsigned int orientation) = 0; virtual bool IsConfigured() = 0; - virtual void AddVideoPicture(const VideoPicture &picture, int index, double currentClock) = 0; + virtual void AddVideoPicture(const VideoPicture &picture, int index) = 0; virtual bool IsPictureHW(const VideoPicture &picture) { return false; }; virtual void UnInit() = 0; virtual bool Flush(bool saveBuffers) { return false; }; diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.cpp 2018-09-10 10:08:09.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -901,7 +901,7 @@ CLog::Log(LOGDEBUG, "%s::%s pts:%.3f diff:%.3f m_frameInterval:%.6f m_frameIntervalDiff:%.6f", CLASSNAME, __func__, pts*1e-6, diff * 1e-6 , m_frameInterval * 1e-6, m_frameIntervalDiff *1e-6); } -void CMMALRenderer::AddVideoPicture(const VideoPicture& pic, int id, double currentClock) +void CMMALRenderer::AddVideoPicture(const VideoPicture& pic, int id) { CMMALBuffer *buffer = dynamic_cast(pic.videoBuffer); assert(buffer); diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.h kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.h 2018-09-11 00:02:00.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/MMALRenderer.h 2018-09-20 00:01:30.000000000 +0000 @@ -144,7 +144,7 @@ virtual void UnInit(); virtual bool Flush(bool saveBuffers) override; virtual bool IsConfigured() override { return m_bConfigured; } - virtual void AddVideoPicture(const VideoPicture& pic, int index, double currentClock) override; + virtual void AddVideoPicture(const VideoPicture& pic, int index) override; virtual bool IsPictureHW(const VideoPicture &picture) override { return false; }; virtual CRenderInfo GetRenderInfo() override; diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererAML.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererAML.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererAML.cpp 2018-07-31 18:47:39.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererAML.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -82,7 +82,7 @@ return true; } -void CRendererAML::AddVideoPicture(const VideoPicture &picture, int index, double currentClock) +void CRendererAML::AddVideoPicture(const VideoPicture &picture, int index) { ReleaseBuffer(index); diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererAML.h kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererAML.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererAML.h 2018-07-31 18:47:39.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererAML.h 2018-09-20 00:01:30.000000000 +0000 @@ -21,7 +21,7 @@ static bool Register(); virtual bool RenderCapture(CRenderCapture* capture) override; - virtual void AddVideoPicture(const VideoPicture &picture, int index, double currentClock) override; + virtual void AddVideoPicture(const VideoPicture &picture, int index) override; virtual void ReleaseBuffer(int idx) override; virtual bool Configure(const VideoPicture &picture, float fps, unsigned int orientation) override; virtual bool IsConfigured() override { return m_bConfigured; }; diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.cpp 2018-09-10 10:08:09.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -89,7 +89,7 @@ } } -void CRendererDRMPRIME::AddVideoPicture(const VideoPicture& picture, int index, double currentClock) +void CRendererDRMPRIME::AddVideoPicture(const VideoPicture& picture, int index) { BUFFER& buf = m_buffers[index]; if (buf.videoBuffer) diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.h kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.h 2018-08-26 13:40:15.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIME.h 2018-09-20 00:01:30.000000000 +0000 @@ -50,7 +50,7 @@ // Player functions bool Configure(const VideoPicture& picture, float fps, unsigned int orientation) override; bool IsConfigured() override { return m_bConfigured; }; - void AddVideoPicture(const VideoPicture& picture, int index, double currentClock) override; + void AddVideoPicture(const VideoPicture& picture, int index) override; void UnInit() override {}; bool Flush(bool saveBuffers) override; void ReleaseBuffer(int idx) override; diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodec.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodec.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodec.cpp 2018-07-31 18:47:39.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodec.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -57,7 +57,7 @@ return true; } -void CRendererMediaCodec::AddVideoPicture(const VideoPicture &picture, int index, double currentClock) +void CRendererMediaCodec::AddVideoPicture(const VideoPicture &picture, int index) { CPictureBuffer &buf = m_buffers[index]; CMediaCodecVideoBuffer *videoBuffer; diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodec.h kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodec.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodec.h 2018-07-31 18:47:39.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodec.h 2018-09-20 00:01:30.000000000 +0000 @@ -21,7 +21,7 @@ static bool Register(); // Player functions - virtual void AddVideoPicture(const VideoPicture &picture, int index, double currentClock) override; + virtual void AddVideoPicture(const VideoPicture &picture, int index) override; virtual void ReleaseBuffer(int idx) override; // Feature support diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.cpp 2018-07-31 18:47:39.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -23,13 +23,13 @@ #include CRendererMediaCodecSurface::CRendererMediaCodecSurface() - : m_bConfigured(false) { CLog::Log(LOGNOTICE, "Instancing CRendererMediaCodecSurface"); } CRendererMediaCodecSurface::~CRendererMediaCodecSurface() { + Reset(); } CBaseRenderer* CRendererMediaCodecSurface::Create(CVideoBuffer *buffer) @@ -79,18 +79,39 @@ return true; } -void CRendererMediaCodecSurface::AddVideoPicture(const VideoPicture &picture, int index, double currentClock) +void CRendererMediaCodecSurface::AddVideoPicture(const VideoPicture &picture, int index) { - if (m_bConfigured && dynamic_cast(picture.videoBuffer)) + ReleaseBuffer(index); + + BUFFER &buf(m_buffers[index]); + if (picture.videoBuffer) + { + buf.videoBuffer = picture.videoBuffer; + buf.videoBuffer->Acquire(); + } +} + +void CRendererMediaCodecSurface::ReleaseVideoBuffer(int idx, bool render) +{ + BUFFER &buf(m_buffers[idx]); + if (buf.videoBuffer) { - int64_t nanodiff(static_cast((picture.pts - currentClock) * 1000)); - dynamic_cast(picture.videoBuffer)->RenderUpdate(m_surfDestRect, - CurrentHostCounter() + nanodiff); + CMediaCodecVideoBuffer *mcvb(dynamic_cast(buf.videoBuffer)); + if (mcvb) + { + if (render && m_bConfigured) + mcvb->RenderUpdate(m_surfDestRect, CXBMCApp::GetNextFrameTime()); + else + mcvb->ReleaseOutputBuffer(render, 0); + } + buf.videoBuffer->Release(); + buf.videoBuffer = nullptr; } } void CRendererMediaCodecSurface::ReleaseBuffer(int idx) { + ReleaseVideoBuffer(idx, false); } bool CRendererMediaCodecSurface::Supports(ERENDERFEATURE feature) @@ -104,9 +125,15 @@ return false; } +void CRendererMediaCodecSurface::Reset() +{ + for (int i = 0 ; i < 4 ; ++i) + ReleaseVideoBuffer(i, false); + m_lastIndex = -1; +} + void CRendererMediaCodecSurface::RenderUpdate(int index, int index2, bool clear, unsigned int flags, unsigned int alpha) { - CXBMCApp::get()->WaitVSync(100); m_bConfigured = true; // this hack is needed to get the 2D mode of a 3D movie going @@ -135,6 +162,12 @@ default: break; } + + if (index != m_lastIndex) + { + ReleaseVideoBuffer(index, true); + m_lastIndex = index; + } } void CRendererMediaCodecSurface::ReorderDrawPoints() diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.h kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.h 2018-07-31 18:47:39.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/HwDecRender/RendererMediaCodecSurface.h 2018-09-20 00:01:30.000000000 +0000 @@ -22,7 +22,7 @@ static bool Register(); virtual bool RenderCapture(CRenderCapture* capture) override; - virtual void AddVideoPicture(const VideoPicture &picture, int index, double currentClock) override; + virtual void AddVideoPicture(const VideoPicture &picture, int index) override; virtual void ReleaseBuffer(int idx) override; virtual bool Configure(const VideoPicture &picture, float fps, unsigned int orientation) override; virtual bool IsConfigured() override { return m_bConfigured; }; @@ -44,6 +44,15 @@ virtual void ReorderDrawPoints() override; private: - bool m_bConfigured; + void Reset(); + void ReleaseVideoBuffer(int idx, bool render); + + bool m_bConfigured = false; CRect m_surfDestRect; + int m_lastIndex = -1; + + struct BUFFER + { + CVideoBuffer *videoBuffer = nullptr; + } m_buffers[4]; }; diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp 2018-09-10 10:08:09.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -272,7 +272,7 @@ return false; } -void CLinuxRendererGL::AddVideoPicture(const VideoPicture &picture, int index, double currentClock) +void CLinuxRendererGL::AddVideoPicture(const VideoPicture &picture, int index) { CPictureBuffer &buf = m_buffers[index]; if (buf.videoBuffer) diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.cpp 2018-09-17 00:01:32.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -181,7 +181,7 @@ return (m_iYV12RenderBuffer + 1) % m_NumYV12Buffers; } -void CLinuxRendererGLES::AddVideoPicture(const VideoPicture &picture, int index, double currentClock) +void CLinuxRendererGLES::AddVideoPicture(const VideoPicture &picture, int index) { CPictureBuffer &buf = m_buffers[index]; if (buf.videoBuffer) diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.h kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.h 2018-08-26 13:40:15.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.h 2018-09-20 00:01:30.000000000 +0000 @@ -94,7 +94,7 @@ // Player functions virtual bool Configure(const VideoPicture &picture, float fps, unsigned int orientation) override; virtual bool IsConfigured() override { return m_bConfigured; } - virtual void AddVideoPicture(const VideoPicture &picture, int index, double currentClock) override; + virtual void AddVideoPicture(const VideoPicture &picture, int index) override; virtual void UnInit() override; virtual bool Flush(bool saveBuffers) override; virtual void ReorderDrawPoints() override; diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h 2018-08-26 13:40:15.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h 2018-09-20 00:01:30.000000000 +0000 @@ -76,7 +76,7 @@ // Player functions bool Configure(const VideoPicture &picture, float fps, unsigned int orientation) override; bool IsConfigured() override { return m_bConfigured; } - void AddVideoPicture(const VideoPicture &picture, int index, double currentClock) override; + void AddVideoPicture(const VideoPicture &picture, int index) override; void UnInit() override; bool Flush(bool saveBuffers) override; void SetBufferSize(int numBuffers) override { m_NumYV12Buffers = numBuffers; } diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp 2018-09-10 10:08:09.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -908,7 +908,7 @@ if (!m_pRenderer) return false; - m_pRenderer->AddVideoPicture(picture, index, m_dvdClock.GetClock()); + m_pRenderer->AddVideoPicture(picture, index); } diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/WinRenderer.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/WinRenderer.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/WinRenderer.cpp 2018-09-10 10:08:09.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/WinRenderer.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -259,7 +259,7 @@ return -1; } -void CWinRenderer::AddVideoPicture(const VideoPicture &picture, int index, double currentClock) +void CWinRenderer::AddVideoPicture(const VideoPicture &picture, int index) { m_renderBuffers[index].AppendPicture(picture); m_renderBuffers[index].frameIdx = m_frameIdx; diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/WinRenderer.h kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/WinRenderer.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/cores/VideoPlayer/VideoRenderers/WinRenderer.h 2018-08-26 13:40:15.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/cores/VideoPlayer/VideoRenderers/WinRenderer.h 2018-09-20 00:01:30.000000000 +0000 @@ -47,7 +47,7 @@ // Player functions bool Configure(const VideoPicture &picture, float fps, unsigned int orientation) override; - void AddVideoPicture(const VideoPicture &picture, int index, double currentClock) override; + void AddVideoPicture(const VideoPicture &picture, int index) override; void UnInit() override; bool IsConfigured() override { return m_bConfigured; } bool Flush(bool saveBuffers) override; diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/android_main.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/android_main.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/android_main.cpp 2018-09-10 10:08:10.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/android_main.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -26,6 +26,7 @@ #include "platform/android/activity/JNIXBMCNsdManagerResolveListener.h" #include "platform/android/activity/JNIXBMCJsonHandler.h" #include "platform/android/activity/JNIXBMCFile.h" +#include "platform/android/activity/JNIXBMCDisplayManagerDisplayListener.h" #include "utils/StringUtils.h" #include "XBMCApp.h" @@ -132,15 +133,17 @@ std::string pkgRoot = CCompileInfo::GetClass(); - std::string mainClass = pkgRoot + "/Main"; - std::string bcReceiver = pkgRoot + "/XBMCBroadcastReceiver"; - std::string settingsObserver = pkgRoot + "/XBMCSettingsContentObserver"; - std::string inputDeviceListener = pkgRoot + "/XBMCInputDeviceListener"; + const std::string mainClass = pkgRoot + "/Main"; + const std::string bcReceiver = pkgRoot + "/XBMCBroadcastReceiver"; + const std::string settingsObserver = pkgRoot + "/XBMCSettingsContentObserver"; + const std::string inputDeviceListener = pkgRoot + "/XBMCInputDeviceListener"; CJNIXBMCAudioManagerOnAudioFocusChangeListener::RegisterNatives(env); CJNIXBMCSurfaceTextureOnFrameAvailableListener::RegisterNatives(env); CJNIXBMCMainView::RegisterNatives(env); CJNIXBMCVideoView::RegisterNatives(env); + CJNIXBMCDisplayManagerDisplayListener::RegisterNatives(env); + jni::CJNIXBMCNsdManagerDiscoveryListener::RegisterNatives(env); jni::CJNIXBMCNsdManagerRegistrationListener::RegisterNatives(env); jni::CJNIXBMCNsdManagerResolveListener::RegisterNatives(env); diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/CMakeLists.txt kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/CMakeLists.txt --- kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/CMakeLists.txt 2018-05-01 00:00:29.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/CMakeLists.txt 2018-09-20 00:01:30.000000000 +0000 @@ -17,6 +17,7 @@ JNIXBMCNsdManagerResolveListener.cpp JNIXBMCJsonHandler.cpp JNIXBMCFile.cpp + JNIXBMCDisplayManagerDisplayListener.cpp ${NDKROOT}/sources/android/native_app_glue/android_native_app_glue.c ${NDKROOT}/sources/android/cpufeatures/cpu-features.c) @@ -41,6 +42,7 @@ JNIXBMCNsdManagerResolveListener.h JNIXBMCJsonHandler.h JNIXBMCFile.h + JNIXBMCDisplayManagerDisplayListener.h XBMCApp.h) core_add_library(platform_android_activity) diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/JNIMainActivity.h kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/JNIMainActivity.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/JNIMainActivity.h 2018-07-31 18:47:40.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/JNIMainActivity.h 2018-09-20 00:01:30.000000000 +0000 @@ -45,4 +45,8 @@ virtual void onVolumeChanged(int volume)=0; virtual void doFrame(int64_t frameTimeNanos)=0; virtual void onVisibleBehindCanceled() = 0; + + virtual void onDisplayAdded(int displayId)=0; + virtual void onDisplayChanged(int displayId)=0; + virtual void onDisplayRemoved(int displayId)=0; }; diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/JNIXBMCDisplayManagerDisplayListener.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/JNIXBMCDisplayManagerDisplayListener.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/JNIXBMCDisplayManagerDisplayListener.cpp 1970-01-01 00:00:00.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/JNIXBMCDisplayManagerDisplayListener.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -0,0 +1,66 @@ +/* + * Copyright (C) 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 "JNIXBMCDisplayManagerDisplayListener.h" +#include + +#include +#include "CompileInfo.h" + +#include "XBMCApp.h" + +using namespace jni; + +static std::string s_className = std::string(CCompileInfo::GetClass()) + "/interfaces/XBMCDisplayManagerDisplayListener"; + +CJNIXBMCDisplayManagerDisplayListener::CJNIXBMCDisplayManagerDisplayListener() + : CJNIBase(s_className) +{ + m_object = new_object(CJNIContext::getClassLoader().loadClass(GetDotClassName(s_className))); + m_object.setGlobal(); +} + +void CJNIXBMCDisplayManagerDisplayListener::RegisterNatives(JNIEnv* env) +{ + jclass cClass = env->FindClass(s_className.c_str()); + if(cClass) + { + JNINativeMethod methods[] = + { + {"_onDisplayAdded", "(I)V", reinterpret_cast(&CJNIXBMCDisplayManagerDisplayListener::_onDisplayAdded)}, + {"_onDisplayChanged", "(I)V", reinterpret_cast(&CJNIXBMCDisplayManagerDisplayListener::_onDisplayChanged)}, + {"_onDisplayRemoved", "(I)V", reinterpret_cast(&CJNIXBMCDisplayManagerDisplayListener::_onDisplayRemoved)}, + }; + + env->RegisterNatives(cClass, methods, sizeof(methods)/sizeof(methods[0])); + } +} + +void CJNIXBMCDisplayManagerDisplayListener::_onDisplayAdded(JNIEnv *env, jobject context, jint displayId) +{ + static_cast(env); + static_cast(context); + + CXBMCApp::get()->onDisplayAdded(displayId); +} + +void CJNIXBMCDisplayManagerDisplayListener::_onDisplayChanged(JNIEnv *env, jobject context, jint displayId) +{ + static_cast(env); + static_cast(context); + + CXBMCApp::get()->onDisplayChanged(displayId); +} + +void CJNIXBMCDisplayManagerDisplayListener::_onDisplayRemoved(JNIEnv *env, jobject context, jint displayId) +{ + static_cast(env); + static_cast(context); + + CXBMCApp::get()->onDisplayRemoved(displayId); +} diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/JNIXBMCDisplayManagerDisplayListener.h kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/JNIXBMCDisplayManagerDisplayListener.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/JNIXBMCDisplayManagerDisplayListener.h 1970-01-01 00:00:00.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/JNIXBMCDisplayManagerDisplayListener.h 2018-09-20 00:01:30.000000000 +0000 @@ -0,0 +1,25 @@ +/* + * Copyright (C) 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. + */ + +#pragma once + +#include + +class CJNIXBMCDisplayManagerDisplayListener : public CJNIBase +{ +public: + CJNIXBMCDisplayManagerDisplayListener(); + CJNIXBMCDisplayManagerDisplayListener(const jni::jhobject &object) : CJNIBase(object) {} + + static void RegisterNatives(JNIEnv* env); + +protected: + static void _onDisplayAdded(JNIEnv* env, jobject thiz, int displayId); + static void _onDisplayChanged(JNIEnv* env, jobject thiz, int displayId); + static void _onDisplayRemoved(JNIEnv* env, jobject thiz, int displayId); +}; diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/XBMCApp.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/XBMCApp.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/XBMCApp.cpp 2018-08-26 13:40:15.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/XBMCApp.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -74,6 +75,7 @@ #include "input/mouse/MouseStat.h" #include "input/Key.h" #include "utils/log.h" +#include "utils/TimeUtils.h" #include "platform/android/network/NetworkAndroid.h" #include "cores/VideoPlayer/VideoRenderers/RenderManager.h" #include "filesystem/SpecialProtocol.h" @@ -83,7 +85,7 @@ #include "utils/URIUtils.h" #include "utils/Variant.h" #include "windowing/android/VideoSyncAndroid.h" -#include "windowing/WinSystem.h" +#include "windowing/android/WinSystemAndroid.h" #include "windowing/WinEvents.h" #include "platform/xbmc.h" @@ -117,6 +119,7 @@ bool CXBMCApp::m_hasFocus = false; bool CXBMCApp::m_headsetPlugged = false; bool CXBMCApp::m_hdmiPlugged = true; +bool CXBMCApp::m_hdmiReportedState = true; IInputDeviceCallbacks* CXBMCApp::m_inputDeviceCallbacks = nullptr; IInputDeviceEventHandler* CXBMCApp::m_inputDeviceEventHandler = nullptr; bool CXBMCApp::m_hasReqVisible = false; @@ -125,6 +128,8 @@ CVideoSyncAndroid* CXBMCApp::m_syncImpl = NULL; CEvent CXBMCApp::m_vsyncEvent; std::vector CXBMCApp::m_activityResultEvents; +int64_t CXBMCApp::m_frameTimeNanos = 0; +float CXBMCApp::m_refreshRate = 0.0f; uint32_t CXBMCApp::m_playback_state = PLAYBACK_STATE_STOPPED; @@ -333,9 +338,20 @@ m_hasFocus = false; } +void CXBMCApp::RegisterDisplayListener(CVariant* variant) +{ + CJNIDisplayManager displayManager(getSystemService("display")); + if (displayManager) + { + android_printf("CXBMCApp: installing DisplayManager::DisplayListener"); + displayManager.registerDisplayListener(CXBMCApp::get()->getDisplayListener()); + } +} + void CXBMCApp::Initialize() { CServiceBroker::GetAnnouncementManager()->AddAnnouncer(CXBMCApp::get()); + runNativeOnUiThread(RegisterDisplayListener, nullptr); } void CXBMCApp::Deinitialize() @@ -500,6 +516,11 @@ CJNIWindowManagerLayoutParams params = window.getAttributes(); if (params.getpreferredRefreshRate() != rate) { + if (g_application.GetAppPlayer().IsPlaying()) + { + dynamic_cast(CServiceBroker::GetWinSystem())->SetHDMIState(false, 1000); + m_hdmiReportedState = false; + } params.setpreferredRefreshRate(rate); if (params.getpreferredRefreshRate() > 0.0) window.setAttributes(params); @@ -507,10 +528,11 @@ } } -void CXBMCApp::SetDisplayModeCallback(CVariant* modeVariant) +void CXBMCApp::SetDisplayModeCallback(CVariant* variant) { - int mode = modeVariant->asFloat(); - delete modeVariant; + int mode = (*variant)["mode"].asInteger(); + float rate = (*variant)["rate"].asFloat(); + delete variant; CJNIWindow window = getWindow(); if (window) @@ -518,7 +540,13 @@ CJNIWindowManagerLayoutParams params = window.getAttributes(); if (params.getpreferredDisplayModeId() != mode) { + if (g_application.GetAppPlayer().IsPlaying()) + { + dynamic_cast(CServiceBroker::GetWinSystem())->SetHDMIState(false); + m_hdmiReportedState = false; + } params.setpreferredDisplayModeId(mode); + params.setpreferredRefreshRate(rate); window.setAttributes(params); } } @@ -529,16 +557,22 @@ if (rate < 1.0) return; + m_refreshRate = rate; + CVariant *variant = new CVariant(rate); runNativeOnUiThread(SetRefreshRateCallback, variant); } -void CXBMCApp::SetDisplayMode(int mode) +void CXBMCApp::SetDisplayMode(int mode, float rate) { if (mode < 1.0) return; - CVariant *variant = new CVariant(mode); + std::map vmap; + vmap["mode"] = mode; + vmap["rate"] = rate; + m_refreshRate = rate; + CVariant *variant = new CVariant(vmap); runNativeOnUiThread(SetDisplayModeCallback, variant); } @@ -952,7 +986,11 @@ { CLog::Log(LOGDEBUG, "-- HDMI state: %s", newstate ? "on" : "off"); m_hdmiPlugged = newstate; - CServiceBroker::GetActiveAE()->DeviceChange(); + if (m_hdmiPlugged != m_hdmiReportedState) + { + dynamic_cast(CServiceBroker::GetWinSystem())->SetHDMIState(m_hdmiPlugged); + m_hdmiReportedState = m_hdmiPlugged; + } } } else if (action == "android.intent.action.SCREEN_OFF") @@ -1143,6 +1181,11 @@ if (m_syncImpl) m_syncImpl->FrameCallback(frameTimeNanos); + // Calculate the time, when next surface buffer should be rendered + m_frameTimeNanos = CurrentHostCounter(); + if (m_refreshRate) + m_frameTimeNanos += (1500000000ll / m_refreshRate); + m_vsyncEvent.Set(); } @@ -1298,12 +1341,29 @@ } +void CXBMCApp::onDisplayAdded(int displayId) +{ + android_printf("%s: ", __PRETTY_FUNCTION__); +} + +void CXBMCApp::onDisplayChanged(int displayId) +{ + android_printf("%s: ", __PRETTY_FUNCTION__); +} + +void CXBMCApp::onDisplayRemoved(int displayId) +{ + android_printf("%s: ", __PRETTY_FUNCTION__); +} + void CXBMCApp::surfaceChanged(CJNISurfaceHolder holder, int format, int width, int height) { + android_printf("%s: ", __PRETTY_FUNCTION__); } void CXBMCApp::surfaceCreated(CJNISurfaceHolder holder) { + android_printf("%s: ", __PRETTY_FUNCTION__); m_window = ANativeWindow_fromSurface(xbmc_jnienv(), holder.getSurface().get_raw()); if (m_window == NULL) { @@ -1318,6 +1378,7 @@ void CXBMCApp::surfaceDestroyed(CJNISurfaceHolder holder) { + android_printf("%s: ", __PRETTY_FUNCTION__); // If we have exited XBMC, it no longer exists. if (!m_exiting) { diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/XBMCApp.h kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/XBMCApp.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/platform/android/activity/XBMCApp.h 2018-07-31 18:47:40.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/platform/android/activity/XBMCApp.h 2018-09-20 00:01:30.000000000 +0000 @@ -30,6 +30,7 @@ #include "IInputHandler.h" #include "JNIMainActivity.h" #include "JNIXBMCAudioManagerOnAudioFocusChangeListener.h" +#include "JNIXBMCDisplayManagerDisplayListener.h" #include "JNIXBMCMainView.h" #include "JNIXBMCMediaSession.h" #include "platform/xbmc.h" @@ -104,6 +105,12 @@ void onInputDeviceChanged(int deviceId) override; void onInputDeviceRemoved(int deviceId) override; + // implementation of DisplayManager::DisplayListener + void onDisplayAdded(int displayId) override; + void onDisplayChanged(int displayId) override; + void onDisplayRemoved(int displayId) override; + jni::jhobject getDisplayListener() { return m_displayListener.get_raw(); } + bool isValid() { return m_activity != NULL; } const ANativeActivity *getActivity() const { return m_activity; } @@ -152,7 +159,7 @@ static void SetSystemVolume(float percent); static void SetRefreshRate(float rate); - static void SetDisplayMode(int mode); + static void SetDisplayMode(int mode, float rate); static int GetDPI(); static CRect MapRenderToDroid(const CRect& srcRect); @@ -184,6 +191,7 @@ void ProcessSlow(); static bool WaitVSync(unsigned int milliSeconds); + static int64_t GetNextFrameTime(){ return m_frameTimeNanos; }; bool getVideosurfaceInUse(); void setVideosurfaceInUse(bool videosurfaceInUse); @@ -200,21 +208,26 @@ private: static CXBMCApp* m_xbmcappinstance; CJNIXBMCAudioManagerOnAudioFocusChangeListener m_audioFocusListener; + CJNIXBMCDisplayManagerDisplayListener m_displayListener; static std::unique_ptr m_mainView; std::unique_ptr m_mediaSession; static bool HasLaunchIntent(const std::string &package); std::string GetFilenameFromIntent(const CJNIIntent &intent); + void run(); void stop(); void SetupEnv(); static void SetRefreshRateCallback(CVariant *rate); static void SetDisplayModeCallback(CVariant *mode); + static void RegisterDisplayListener(CVariant*); + static ANativeActivity *m_activity; static CJNIWakeLock *m_wakeLock; static int m_batteryLevel; static bool m_hasFocus; static bool m_headsetPlugged; static bool m_hdmiPlugged; + static bool m_hdmiReportedState; static IInputDeviceCallbacks* m_inputDeviceCallbacks; static IInputDeviceEventHandler* m_inputDeviceEventHandler; static bool m_hasReqVisible; @@ -237,6 +250,8 @@ bool XBMC_SetupDisplay(); static uint32_t m_playback_state; + static int64_t m_frameTimeNanos; + static float m_refreshRate; public: // CJNISurfaceHolderCallback interface diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/utils/TimeUtils.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/utils/TimeUtils.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/utils/TimeUtils.cpp 2018-07-31 18:47:40.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/utils/TimeUtils.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -22,7 +22,7 @@ int64_t CurrentHostCounter(void) { -#if defined(TARGET_DARWIN) +#if defined(TARGET_DARWIN) return( (int64_t)CVGetCurrentHostTime() ); #elif defined(TARGET_WINDOWS) LARGE_INTEGER PerformanceCount; @@ -30,11 +30,11 @@ return( (int64_t)PerformanceCount.QuadPart ); #else struct timespec now; -#ifdef CLOCK_MONOTONIC_RAW +#if defined(CLOCK_MONOTONIC_RAW) && !defined(TARGET_ANDROID) clock_gettime(CLOCK_MONOTONIC_RAW, &now); #else clock_gettime(CLOCK_MONOTONIC, &now); -#endif // CLOCK_MONOTONIC_RAW +#endif // CLOCK_MONOTONIC_RAW && !TARGET_ANDROID return( ((int64_t)now.tv_sec * 1000000000L) + now.tv_nsec ); #endif } diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/windowing/android/AndroidUtils.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/windowing/android/AndroidUtils.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/windowing/android/AndroidUtils.cpp 2018-09-10 10:08:10.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/windowing/android/AndroidUtils.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -232,7 +232,7 @@ if (s_hasModeApi) { - CXBMCApp::SetDisplayMode(atoi(res.strId.c_str())); + CXBMCApp::SetDisplayMode(atoi(res.strId.c_str()), res.fRefreshRate); s_res_cur_displayMode = res; } else if (std::abs(currentRefreshRate() - res.fRefreshRate) > 0.0001) diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/windowing/android/WinSystemAndroid.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/windowing/android/WinSystemAndroid.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/windowing/android/WinSystemAndroid.cpp 2018-09-10 10:08:10.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/windowing/android/WinSystemAndroid.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -48,7 +48,9 @@ m_displayHeight = 0; m_stereo_mode = RENDER_STEREO_MODE_OFF; - m_delayDispReset = false; + + m_dispResetState = RESET_NOTWAITING; + m_dispResetTimer = new CTimer(this); m_android = nullptr; @@ -62,6 +64,7 @@ { m_nativeWindow = nullptr; } + delete m_dispResetTimer, m_dispResetTimer = nullptr; } bool CWinSystemAndroid::InitWindowSystem() @@ -116,21 +119,6 @@ return true; } - int delay = CServiceBroker::GetSettings()->GetInt("videoscreen.delayrefreshchange"); - if (delay > 0) - { - m_delayDispReset = true; - m_dispResetTimer.Set(delay * 100); - } - - { - CSingleLock lock(m_resourceSection); - for (std::vector::iterator i = m_resources.begin(); i != m_resources.end(); ++i) - { - (*i)->OnLostDisplay(); - } - } - m_stereo_mode = stereo_mode; m_bFullScreen = fullScreen; @@ -138,16 +126,6 @@ m_android->SetNativeResolution(res); - if (!m_delayDispReset) - { - CSingleLock lock(m_resourceSection); - // tell any shared resources - for (std::vector::iterator i = m_resources.begin(); i != m_resources.end(); ++i) - { - (*i)->OnResetDisplay(); - } - } - return true; } @@ -215,6 +193,41 @@ } } +void CWinSystemAndroid::OnTimeout() +{ + m_dispResetState = RESET_WAITEVENT; + SetHDMIState(true); +} + +void CWinSystemAndroid::SetHDMIState(bool connected, uint32_t timeoutMs) +{ + CSingleLock lock(m_resourceSection); + if (connected && m_dispResetState == RESET_WAITEVENT) + { + for (auto resource : m_resources) + resource->OnResetDisplay(); + } + else if (!connected) + { + int delay = CServiceBroker::GetSettings()->GetInt("videoscreen.delayrefreshchange") * 100; + + if (timeoutMs > delay) + delay = timeoutMs; + + if (delay > 0) + { + m_dispResetState = RESET_WAITTIMER; + m_dispResetTimer->Stop(); + m_dispResetTimer->Start(delay); + } + else + m_dispResetState = RESET_WAITEVENT; + + for (auto resource : m_resources) + resource->OnLostDisplay(); + } +} + bool CWinSystemAndroid::Hide() { return false; diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp kodi-18.0+git20180920.0201-2c44473/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp --- kodi-18.0+git20180919.0201-fea8a29/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp 2018-09-19 00:01:30.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp 2018-09-20 00:01:30.000000000 +0000 @@ -10,6 +10,7 @@ #include "WinSystemAndroidGLESContext.h" #include "utils/log.h" #include "threads/SingleLock.h" +#include "platform/android/activity/XBMCApp.h" std::unique_ptr CWinSystemBase::CreateWinSystem() { @@ -65,14 +66,6 @@ return false; } - if (!m_delayDispReset) - { - CSingleLock lock(m_resourceSection); - // tell any shared resources - for (std::vector::iterator i = m_resources.begin(); i != m_resources.end(); ++i) - (*i)->OnResetDisplay(); - } - return true; } @@ -91,34 +84,20 @@ void CWinSystemAndroidGLESContext::SetVSyncImpl(bool enable) { - m_iVSyncMode = enable ? 10:0; - if (!m_pGLContext.SetVSync(enable)) - { - m_iVSyncMode = 0; - CLog::Log(LOGERROR, "%s,Could not set egl vsync", __FUNCTION__); - } + // We use Choreographer for timing + m_pGLContext.SetVSync(false); } void CWinSystemAndroidGLESContext::PresentRenderImpl(bool rendered) { - if (m_delayDispReset && m_dispResetTimer.IsTimePast()) - { - m_delayDispReset = false; - CSingleLock lock(m_resourceSection); - // tell any shared resources - for (std::vector::iterator i = m_resources.begin(); i != m_resources.end(); ++i) - (*i)->OnResetDisplay(); - } - if (!rendered) - return; - // Ignore EGL_BAD_SURFACE: It seems to happen during/after mode changes, but // we can't actually do anything about it - if (!m_pGLContext.TrySwapBuffers() && eglGetError() != EGL_BAD_SURFACE) + if (rendered && !m_pGLContext.TrySwapBuffers() && eglGetError() != EGL_BAD_SURFACE) { CEGLUtils::LogError("eglSwapBuffers failed"); throw std::runtime_error("eglSwapBuffers failed"); } + CXBMCApp::get()->WaitVSync(1000); } EGLDisplay CWinSystemAndroidGLESContext::GetEGLDisplay() const diff -Nru kodi-18.0+git20180919.0201-fea8a29/xbmc/windowing/android/WinSystemAndroid.h kodi-18.0+git20180920.0201-2c44473/xbmc/windowing/android/WinSystemAndroid.h --- kodi-18.0+git20180919.0201-fea8a29/xbmc/windowing/android/WinSystemAndroid.h 2018-07-31 18:47:40.000000000 +0000 +++ kodi-18.0+git20180920.0201-2c44473/xbmc/windowing/android/WinSystemAndroid.h 2018-09-20 00:01:30.000000000 +0000 @@ -13,12 +13,12 @@ #include "rendering/gles/RenderSystemGLES.h" #include "threads/CriticalSection.h" #include "windowing/WinSystem.h" -#include "threads/SystemClock.h" +#include "threads/Timer.h" #include "EGL/egl.h" class IDispResource; -class CWinSystemAndroid : public CWinSystemBase +class CWinSystemAndroid : public CWinSystemBase, public ITimerCallback { public: CWinSystemAndroid(); @@ -34,6 +34,8 @@ bool DestroyWindow() override; void UpdateResolutions() override; + void SetHDMIState(bool connected, uint32_t timeoutMs = 0); + bool HasCursor() override { return false; }; bool Hide() override; @@ -48,6 +50,7 @@ protected: std::unique_ptr GetOSScreenSaverImpl() override; + void OnTimeout() override; CAndroidUtils *m_android; @@ -59,8 +62,15 @@ RENDER_STEREO_MODE m_stereo_mode; - bool m_delayDispReset; - XbmcThreads::EndTime m_dispResetTimer; + enum RESETSTATE + { + RESET_NOTWAITING, + RESET_WAITTIMER, + RESET_WAITEVENT + }; + + RESETSTATE m_dispResetState; + CTimer *m_dispResetTimer; CCriticalSection m_resourceSection; std::vector m_resources;