diff --git a/src/s_sound.cpp b/src/s_sound.cpp index d30af704e6..ecb0e96731 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 a2cfe60bea..ad0f3c61b7 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 572d381e6c..ab27dfde60 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 65502c278e..9d1cbf7034 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; };