diff options
author | Memphiz <memphis@machzwo.de> | 2015-05-16 13:58:26 +0200 |
---|---|---|
committer | Memphiz <memphis@machzwo.de> | 2015-05-18 21:53:14 +0200 |
commit | b1e3ebe14c2c72262455ca558e6a40b37f2e784c (patch) | |
tree | b621880e73964c0faf66676dbc5b95291668aeaf | |
parent | 0f32a2f5d4fb1077def8c581098aa4385e8d0a67 (diff) |
[osx/videosync] - move calls to displaylink init/deinit into the vsync thread and make sure that init is only called once the display reset is done - same as GLX does
-rw-r--r-- | xbmc/video/videosync/VideoSyncOsx.cpp | 42 | ||||
-rw-r--r-- | xbmc/video/videosync/VideoSyncOsx.h | 8 |
2 files changed, 36 insertions, 14 deletions
diff --git a/xbmc/video/videosync/VideoSyncOsx.cpp b/xbmc/video/videosync/VideoSyncOsx.cpp index 53992fe9f9..a59a4b9efe 100644 --- a/xbmc/video/videosync/VideoSyncOsx.cpp +++ b/xbmc/video/videosync/VideoSyncOsx.cpp @@ -34,35 +34,44 @@ bool CVideoSyncOsx::Setup(PUPDATECLOCK func) { CLog::Log(LOGDEBUG, "CVideoSyncOsx::%s setting up OSX", __FUNCTION__); - bool setupOk = false; //init the vblank timestamp m_LastVBlankTime = CurrentHostCounter(); UpdateClock = func; - m_abort = false; - - setupOk = InitDisplayLink(); - if (setupOk) - { - g_Windowing.Register(this); - } + m_displayLost = false; + m_displayReset = false; + m_lostEvent.Reset(); + + g_Windowing.Register(this); - return setupOk; + return true; } void CVideoSyncOsx::Run(volatile bool& stop) { + InitDisplayLink(); + //because cocoa has a vblank callback, we just keep sleeping until we're asked to stop the thread - while(!stop && !m_abort) + while(!stop && !m_displayLost && !m_displayReset) { Sleep(100); } + + m_lostEvent.Set(); + + while(!stop && m_displayLost && !m_displayReset) + { + Sleep(10); + } + + DeinitDisplayLink(); } void CVideoSyncOsx::Cleanup() { CLog::Log(LOGDEBUG, "CVideoSyncOsx::%s cleaning up OSX", __FUNCTION__); - DeinitDisplayLink(); + m_lostEvent.Set(); + m_LastVBlankTime = 0; g_Windowing.Unregister(this); } @@ -73,9 +82,18 @@ float CVideoSyncOsx::GetFps() return m_fps; } +void CVideoSyncOsx::OnLostDevice() +{ + if (!m_displayLost) + { + m_displayLost = true; + m_lostEvent.WaitMSec(1000); + } +} + void CVideoSyncOsx::OnResetDevice() { - m_abort = true; + m_displayReset = true; } void CVideoSyncOsx::VblankHandler(int64_t nowtime) diff --git a/xbmc/video/videosync/VideoSyncOsx.h b/xbmc/video/videosync/VideoSyncOsx.h index d24204a690..4133884df9 100644 --- a/xbmc/video/videosync/VideoSyncOsx.h +++ b/xbmc/video/videosync/VideoSyncOsx.h @@ -22,12 +22,13 @@ #if defined(TARGET_DARWIN_OSX) #include "VideoSync.h" #include "guilib/DispResource.h" +#include "threads/Event.h" class CVideoSyncOsx : public CVideoSync, IDispResource { public: - CVideoSyncOsx() : m_LastVBlankTime(0), m_abort(false){} + CVideoSyncOsx() : m_LastVBlankTime(0), m_displayLost(false), m_displayReset(false){} // CVideoSync interface virtual bool Setup(PUPDATECLOCK func); @@ -36,6 +37,7 @@ public: virtual float GetFps(); // IDispResource interface + virtual void OnLostDevice(); virtual void OnResetDevice(); // used in the displaylink callback @@ -46,7 +48,9 @@ private: virtual void DeinitDisplayLink(); int64_t m_LastVBlankTime; //timestamp of the last vblank, used for calculating how many vblanks happened - volatile bool m_abort; + volatile bool m_displayLost; + volatile bool m_displayReset; + CEvent m_lostEvent; }; #endif// TARGET_DARWIN_OSX |