From 7415ed0889fdc26466ee9a042f14093827093407 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 18 Apr 2012 19:10:43 +0300 Subject: [PATCH] NowPlaying.dll: Fixed that SHUFFLE, REPEAT, and VOLUME were not reset on player shutdown --- Plugins/PluginNowPlaying/Player.cpp | 9 ++++++++- Plugins/PluginNowPlaying/Player.h | 2 +- Plugins/PluginNowPlaying/PlayerAIMP.cpp | 7 ++++--- Plugins/PluginNowPlaying/PlayerCAD.cpp | 2 +- Plugins/PluginNowPlaying/PlayerITunes.cpp | 2 +- Plugins/PluginNowPlaying/PlayerWLM.cpp | 2 +- Plugins/PluginNowPlaying/PlayerWMP.cpp | 2 +- Plugins/PluginNowPlaying/PlayerWinamp.cpp | 7 ++++--- 8 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Plugins/PluginNowPlaying/Player.cpp b/Plugins/PluginNowPlaying/Player.cpp index dc15542f..63b4e0f5 100644 --- a/Plugins/PluginNowPlaying/Player.cpp +++ b/Plugins/PluginNowPlaying/Player.cpp @@ -194,7 +194,7 @@ unsigned __stdcall CPlayer::LyricsThreadProc(void* pParam) ** Clear track information. ** */ -void CPlayer::ClearData() +void CPlayer::ClearData(bool all) { m_State = STATE_STOPPED; m_Artist.clear(); @@ -208,4 +208,11 @@ void CPlayer::ClearData() m_Rating = 0; m_Number = 0; m_Year = 0; + + if (all) + { + m_Volume = 0; + m_Shuffle = false; + m_Repeat = false; + } } diff --git a/Plugins/PluginNowPlaying/Player.h b/Plugins/PluginNowPlaying/Player.h index a5a81b72..16a7a72f 100644 --- a/Plugins/PluginNowPlaying/Player.h +++ b/Plugins/PluginNowPlaying/Player.h @@ -105,7 +105,7 @@ public: bool GetRepeat() const { return m_Repeat; } protected: - void ClearData(); + void ClearData(bool all = true); bool m_Initialized; UINT m_InstanceCount; diff --git a/Plugins/PluginNowPlaying/PlayerAIMP.cpp b/Plugins/PluginNowPlaying/PlayerAIMP.cpp index fab9f6fc..e91d5e98 100644 --- a/Plugins/PluginNowPlaying/PlayerAIMP.cpp +++ b/Plugins/PluginNowPlaying/PlayerAIMP.cpp @@ -121,15 +121,16 @@ void CPlayerAIMP::UpdateData() if (!IsWindow(m_Window)) { m_Initialized = false; + ClearData(); + if (m_FileMap) UnmapViewOfFile(m_FileMap); if (m_FileMapHandle) CloseHandle(m_FileMapHandle); } - - if (m_LastTitleSize != 0) + else if (m_State != STATE_STOPPED) { + ClearData(false); m_LastFileSize = 0; m_LastTitleSize = 0; - ClearData(); } // Don't continue if AIMP has quit or is stopped diff --git a/Plugins/PluginNowPlaying/PlayerCAD.cpp b/Plugins/PluginNowPlaying/PlayerCAD.cpp index 4c279c63..6b73e3fd 100644 --- a/Plugins/PluginNowPlaying/PlayerCAD.cpp +++ b/Plugins/PluginNowPlaying/PlayerCAD.cpp @@ -228,7 +228,7 @@ LRESULT CALLBACK CPlayerCAD::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM player->m_State = (StateType)wParam; if (player->m_State == STATE_STOPPED) { - player->ClearData(); + player->ClearData(false); } break; } diff --git a/Plugins/PluginNowPlaying/PlayerITunes.cpp b/Plugins/PluginNowPlaying/PlayerITunes.cpp index e6a7abb7..dc11a9ef 100644 --- a/Plugins/PluginNowPlaying/PlayerITunes.cpp +++ b/Plugins/PluginNowPlaying/PlayerITunes.cpp @@ -455,7 +455,7 @@ void CPlayerITunes::OnTrackChange() } else { - ClearData(); + ClearData(false); } } diff --git a/Plugins/PluginNowPlaying/PlayerWLM.cpp b/Plugins/PluginNowPlaying/PlayerWLM.cpp index 29ac3d4b..d2bed931 100644 --- a/Plugins/PluginNowPlaying/PlayerWLM.cpp +++ b/Plugins/PluginNowPlaying/PlayerWLM.cpp @@ -139,7 +139,7 @@ LRESULT CALLBACK CPlayerWLM::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM } else { - player->ClearData(); + player->ClearData(false); } return 0; diff --git a/Plugins/PluginNowPlaying/PlayerWMP.cpp b/Plugins/PluginNowPlaying/PlayerWMP.cpp index 878cdde4..af3ec2a9 100644 --- a/Plugins/PluginNowPlaying/PlayerWMP.cpp +++ b/Plugins/PluginNowPlaying/PlayerWMP.cpp @@ -93,7 +93,7 @@ void CPlayerWMP::CRemoteHost::PlayStateChange(long NewState) { case wmppsStopped: case wmppsMediaEnded: - m_Player->ClearData(); + m_Player->ClearData(false); break; case wmppsPaused: diff --git a/Plugins/PluginNowPlaying/PlayerWinamp.cpp b/Plugins/PluginNowPlaying/PlayerWinamp.cpp index 673ad120..8f29a223 100644 --- a/Plugins/PluginNowPlaying/PlayerWinamp.cpp +++ b/Plugins/PluginNowPlaying/PlayerWinamp.cpp @@ -112,12 +112,13 @@ void CPlayerWinamp::UpdateData() if (!IsWindow(m_Window)) { m_Initialized = false; + ClearData(); + if (m_WinampHandle) CloseHandle(m_WinampHandle); } - - if (m_State != STATE_STOPPED) + else if (m_State != STATE_STOPPED) { - ClearData(); + ClearData(false); } // Don't continue if Winamp has quit or is stopped