From 466b6e45357fb44031d52067565a26265637156e Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 23 May 2009 03:09:50 +0000 Subject: [PATCH] - Moved SetSoundPaused() out of i_input.cpp and into s_sound.cpp. SVN r1598 (trunk) --- src/s_sound.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++ src/s_sound.h | 1 + src/sdl/i_input.cpp | 8 +------ src/win32/i_input.cpp | 48 ++--------------------------------------- 4 files changed, 54 insertions(+), 53 deletions(-) diff --git a/src/s_sound.cpp b/src/s_sound.cpp index d30af704e..ecb0e9673 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1669,6 +1669,56 @@ void S_ResumeSound (bool notsfx) } } +//========================================================================== +// +// S_SetSoundPaused +// +// Called with state non-zero when the app is active, zero when it isn't. +// +//========================================================================== + +void S_SetSoundPaused (int state) +{ + if (state) + { + if (paused <= 0) + { + S_ResumeSound(true); + if (GSnd != NULL) + { + GSnd->SetInactive(false); + } + if (!netgame +#ifdef _DEBUG + && !demoplayback +#endif + ) + { + paused = 0; + } + } + } + else + { + if (paused == 0) + { + S_PauseSound(false, true); + if (GSnd != NULL) + { + GSnd->SetInactive(true); + } + if (!netgame +#ifdef _DEBUG + && !demoplayback +#endif + ) + { + paused = -1; + } + } + } +} + //========================================================================== // // S_EvictAllChannels diff --git a/src/s_sound.h b/src/s_sound.h index a2cfe60be..ad0f3c61b 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -318,6 +318,7 @@ void S_StopMusic (bool force); // Stop and resume music, during game PAUSE. void S_PauseSound (bool notmusic, bool notsfx); void S_ResumeSound (bool notsfx); +void S_SetSoundPaused (int state); // // Updates music & sounds diff --git a/src/sdl/i_input.cpp b/src/sdl/i_input.cpp index 572d381e6..ab27dfde6 100644 --- a/src/sdl/i_input.cpp +++ b/src/sdl/i_input.cpp @@ -390,14 +390,8 @@ void MessagePump (const SDL_Event &sev) if (sev.active.gain == 0) { // kill focus FlushDIKState (); - if (!paused) - S_PauseSound (false); - } - else - { // set focus - if (!paused) - S_ResumeSound (); } + S_SetSoundPaused(sev.active.gain); } break; diff --git a/src/win32/i_input.cpp b/src/win32/i_input.cpp index 65502c278..9d1cbf703 100644 --- a/src/win32/i_input.cpp +++ b/src/win32/i_input.cpp @@ -371,7 +371,6 @@ static BYTE KeyState[256]; static BYTE DIKState[2][NUM_KEYS]; static int KeysReadCount; static int ActiveDIKState; -static void SetSoundPaused (int state); // Convert DIK_* code to ASCII using Qwerty keymap static const BYTE Convert [256] = @@ -738,7 +737,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS); } - SetSoundPaused (wParam); + S_SetSoundPaused (wParam); break; case WM_WTSSESSION_CHANGE: @@ -1384,50 +1383,6 @@ void I_ShutdownInput () } } -static void SetSoundPaused (int state) -{ - if (state) - { - if (paused <= 0) - { - S_ResumeSound(true); - if (GSnd != NULL) - { - GSnd->SetInactive(false); - } - if (!netgame -#ifdef _DEBUG - && !demoplayback -#endif - ) - { - paused = 0; - } - } - } - else - { - if (paused == 0) - { - S_PauseSound(false, true); - if (GSnd != NULL) - { - GSnd->SetInactive(true); - } - if (!netgame -#ifdef _DEBUG - && !demoplayback -#endif - ) - { - paused = -1; - } - } - } -} - -static LONG PrevX, PrevY; - static void SetCursorState(bool visible) { HCURSOR usingCursor = visible ? TheArrowCursor : TheInvisibleCursor; @@ -2055,6 +2010,7 @@ protected: void CenterMouse(int x, int y); POINT UngrabbedPointerPos; + LONG PrevX, PrevY; bool Grabbed; };