diff options
author | Rainer Hochecker <fernetmenta@online.de> | 2018-03-28 21:29:23 +0200 |
---|---|---|
committer | Rainer Hochecker <fernetmenta@online.de> | 2018-03-29 08:00:02 +0200 |
commit | 85c30589c054ead7b5f2ad39f62cde35cb159520 (patch) | |
tree | d7157e9f909b24eff1f03ce6576d89458c046d61 | |
parent | a6ad1429bff63814bcf704932579c3962bae563d (diff) |
fire python calbacks OnPlayback.. from main thread
-rw-r--r-- | xbmc/Application.cpp | 171 | ||||
-rw-r--r-- | xbmc/Application.h | 3 | ||||
-rw-r--r-- | xbmc/platform/darwin/DarwinUtils.h | 2 | ||||
-rw-r--r-- | xbmc/platform/darwin/DarwinUtils.mm | 4 |
4 files changed, 89 insertions, 91 deletions
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 059b07e928..49b0d5c4f6 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -3220,15 +3220,59 @@ bool CApplication::PlayFile(CFileItem item, const std::string& player, bool bRes return true; } -void CApplication::OnPlayBackEnded() +void CApplication::PlaybackCleanup() { - CLog::LogF(LOGDEBUG ,"CApplication::OnPlayBackEnded"); + if (!m_appPlayer.IsPlaying()) + { + g_audioManager.Enable(true); + m_appPlayer.OpenNext(m_ServiceManager->GetPlayerCoreFactory()); + } - // informs python script currently running playback has ended - // (does nothing if python is not loaded) -#ifdef HAS_PYTHON - g_pythonParser.OnPlayBackEnded(); + if (!m_appPlayer.IsPlayingVideo()) + { + if(g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO || + g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_GAME) + { + g_windowManager.PreviousWindow(); + } + else + { + // resets to res_desktop or look&feel resolution (including refreshrate) + g_graphicsContext.SetFullScreenVideo(false); + } +#ifdef TARGET_DARWIN_IOS + CDarwinUtils::SetScheduling(false); #endif + } + + if (!m_appPlayer.IsPlayingAudio() && CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_NONE && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION) + { + m_ServiceManager->GetSettings().Save(); // save vis settings + WakeUpScreenSaverAndDPMS(); + g_windowManager.PreviousWindow(); + } + + // DVD ejected while playing in vis ? + if (!m_appPlayer.IsPlayingAudio() && (m_itemCurrentFile->IsCDDA() || m_itemCurrentFile->IsOnDVD()) && !g_mediaManager.IsDiscInDrive() && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION) + { + // yes, disable vis + m_ServiceManager->GetSettings().Save(); // save vis settings + WakeUpScreenSaverAndDPMS(); + g_windowManager.PreviousWindow(); + } + + if (!m_appPlayer.IsPlaying()) + { + m_stackHelper.Clear(); + } + + if (IsEnableTestMode()) + CApplicationMessenger::GetInstance().PostMsg(TMSG_QUIT); +} + +void CApplication::OnPlayBackEnded() +{ + CLog::LogF(LOGDEBUG ,"CApplication::OnPlayBackEnded"); CServiceBroker::GetPVRManager().OnPlaybackEnded(m_itemCurrentFile); @@ -3248,12 +3292,6 @@ void CApplication::OnPlayBackStarted(const CFileItem &file) if (file.GetProperty("get_stream_details_from_player").asBoolean()) m_appPlayer.SetUpdateStreamDetails(); -#ifdef HAS_PYTHON - // informs python script currently running playback has started - // (does nothing if python is not loaded) - g_pythonParser.OnPlayBackStarted(file); -#endif - if (m_stackHelper.IsPlayingISOStack() || m_stackHelper.IsPlayingRegularStack()) m_itemCurrentFile.reset(new CFileItem(*m_stackHelper.GetRegisteredStack(file))); else @@ -3350,11 +3388,6 @@ void CApplication::OnPlayBackStopped() { CLog::LogF(LOGDEBUG, "CApplication::OnPlayBackStopped"); - // informs python script currently running playback has ended - // (does nothing if python is not loaded) -#ifdef HAS_PYTHON - g_pythonParser.OnPlayBackStopped(); -#endif #if defined(TARGET_DARWIN_IOS) CDarwinUtils::EnableOSScreenSaver(true); #endif @@ -3907,7 +3940,8 @@ bool CApplication::OnMessage(CGUIMessage& message) case GUI_MSG_PLAYBACK_STARTED: { #ifdef TARGET_DARWIN_IOS - CDarwinUtils::SetScheduling(message.GetMessage()); + // @TODO move this away to platform code + CDarwinUtils::SetScheduling(m_appPlayer.IsPlayingVideo()); #endif CPlayList playList = CServiceBroker::GetPlaylistPlayer().GetPlaylist(CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist()); @@ -3932,6 +3966,12 @@ bool CApplication::OnMessage(CGUIMessage& message) g_infoManager.SetCurrentItem(*m_itemCurrentFile); g_partyModeManager.OnSongChange(true); +#ifdef HAS_PYTHON + // informs python script currently running playback has started + // (does nothing if python is not loaded) + g_pythonParser.OnPlayBackStarted(*m_itemCurrentFile); +#endif + CVariant param; param["player"]["speed"] = 1; param["player"]["playerid"] = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); @@ -4003,80 +4043,39 @@ bool CApplication::OnMessage(CGUIMessage& message) break; case GUI_MSG_PLAYBACK_STOPPED: - case GUI_MSG_PLAYBACK_ENDED: m_playerEvent.Set(); - case GUI_MSG_PLAYLISTPLAYER_STOPPED: - { -#ifdef TARGET_DARWIN_IOS - CDarwinUtils::SetScheduling(message.GetMessage()); + m_itemCurrentFile->Reset(); + g_infoManager.ResetCurrentItem(); + PlaybackCleanup(); +#ifdef HAS_PYTHON + g_pythonParser.OnPlayBackStopped(); #endif - // first check if we still have items in the stack to play - if (message.GetMessage() == GUI_MSG_PLAYBACK_ENDED) - { - if (m_stackHelper.IsPlayingRegularStack() && m_stackHelper.HasNextStackPartFileItem()) - { // just play the next item in the stack - PlayFile(m_stackHelper.SetNextStackPartCurrentFileItem(), "", true); - return true; - } - } - - // reset the current playing file - m_itemCurrentFile->Reset(); - g_infoManager.ResetCurrentItem(); - - if (message.GetMessage() == GUI_MSG_PLAYBACK_ENDED) - { - if (!CServiceBroker::GetPlaylistPlayer().PlayNext(1, true)) - m_appPlayer.ClosePlayer(); - } - - if (!m_appPlayer.IsPlaying()) - { - g_audioManager.Enable(true); - m_appPlayer.OpenNext(m_ServiceManager->GetPlayerCoreFactory()); - } - - if (!m_appPlayer.IsPlayingVideo()) - { - if(g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO || - g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_GAME) - { - g_windowManager.PreviousWindow(); - } - else - { - // resets to res_desktop or look&feel resolution (including refreshrate) - g_graphicsContext.SetFullScreenVideo(false); - } - } + return true; - if (!m_appPlayer.IsPlayingAudio() && CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_NONE && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION) - { - m_ServiceManager->GetSettings().Save(); // save vis settings - WakeUpScreenSaverAndDPMS(); - g_windowManager.PreviousWindow(); - } + case GUI_MSG_PLAYBACK_ENDED: + m_playerEvent.Set(); + if (m_stackHelper.IsPlayingRegularStack() && m_stackHelper.HasNextStackPartFileItem()) + { // just play the next item in the stack + PlayFile(m_stackHelper.SetNextStackPartCurrentFileItem(), "", true); + return true; + } + m_itemCurrentFile->Reset(); + g_infoManager.ResetCurrentItem(); + if (!CServiceBroker::GetPlaylistPlayer().PlayNext(1, true)) + m_appPlayer.ClosePlayer(); - // DVD ejected while playing in vis ? - if (!m_appPlayer.IsPlayingAudio() && (m_itemCurrentFile->IsCDDA() || m_itemCurrentFile->IsOnDVD()) && !g_mediaManager.IsDiscInDrive() && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION) - { - // yes, disable vis - m_ServiceManager->GetSettings().Save(); // save vis settings - WakeUpScreenSaverAndDPMS(); - g_windowManager.PreviousWindow(); - } + PlaybackCleanup(); - if (!m_appPlayer.IsPlaying()) - { - m_itemCurrentFile.reset(new CFileItem()); - m_stackHelper.Clear(); - } +#ifdef HAS_PYTHON + g_pythonParser.OnPlayBackEnded(); +#endif + return true; - if (IsEnableTestMode()) - CApplicationMessenger::GetInstance().PostMsg(TMSG_QUIT); - return true; - } - break; + case GUI_MSG_PLAYLISTPLAYER_STOPPED: + m_itemCurrentFile->Reset(); + g_infoManager.ResetCurrentItem(); + PlaybackCleanup(); + return true; case GUI_MSG_PLAYBACK_AVSTARTED: m_playerEvent.Set(); diff --git a/xbmc/Application.h b/xbmc/Application.h index 6f53eb7fab..0c714e86a7 100644 --- a/xbmc/Application.h +++ b/xbmc/Application.h @@ -384,10 +384,8 @@ public: protected: bool OnSettingsSaving() const override; - bool Load(const TiXmlNode *settings) override; bool Save(TiXmlNode *settings) const override; - void OnSettingChanged(std::shared_ptr<const CSetting> setting) override; void OnSettingAction(std::shared_ptr<const CSetting> setting) override; bool OnSettingUpdate(std::shared_ptr<CSetting> setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) override; @@ -395,6 +393,7 @@ protected: bool LoadSkin(const std::string& skinID); void CheckOSScreenSaverInhibitionSetting(); + void PlaybackCleanup(); /*! \brief Delegates the action to all registered action handlers. diff --git a/xbmc/platform/darwin/DarwinUtils.h b/xbmc/platform/darwin/DarwinUtils.h index fee6d60291..2e5a9823e4 100644 --- a/xbmc/platform/darwin/DarwinUtils.h +++ b/xbmc/platform/darwin/DarwinUtils.h @@ -47,7 +47,7 @@ public: static int BatteryLevel(void); static void EnableOSScreenSaver(bool enable); static void ResetSystemIdleTimer(); - static void SetScheduling(int message); + static void SetScheduling(bool realtime); static void PrintDebugString(std::string debugString); static bool CFStringRefToString(CFStringRef source, std::string& destination); static bool CFStringRefToUTF8String(CFStringRef source, std::string& destination); diff --git a/xbmc/platform/darwin/DarwinUtils.mm b/xbmc/platform/darwin/DarwinUtils.mm index d2f0820d9e..1e75046aea 100644 --- a/xbmc/platform/darwin/DarwinUtils.mm +++ b/xbmc/platform/darwin/DarwinUtils.mm @@ -539,7 +539,7 @@ void CDarwinUtils::ResetSystemIdleTimer() } -void CDarwinUtils::SetScheduling(int message) +void CDarwinUtils::SetScheduling(bool realtime) { int policy; struct sched_param param; @@ -550,7 +550,7 @@ void CDarwinUtils::SetScheduling(int message) policy = SCHED_OTHER; thread_extended_policy_data_t theFixedPolicy={true}; - if (message == GUI_MSG_PLAYBACK_STARTED && g_application.GetAppPlayer().IsPlayingVideo()) + if (realtime) { policy = SCHED_RR; theFixedPolicy.timeshare = false; |