From 236d7a62ce842b4f48954228ef88b6eebe12fa23 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Sun, 25 Jul 2010 12:20:17 +0000 Subject: [PATCH] Under windows, run the game (windowed), go into a saved game, press Esc to get the menu, minimize using the mouse on the window's minimize icon and then restore and you'll have sound all the same. HOWEVER: If you minimize by pressing the icon on the start bar, sound will be lost upon restoring. Or, if you use alt-tab to get away from the game window the same will happen. Or, if you run the game fullscreen and use alt-tab to go to the desktop (alt-tab is the only way I know) you will lose the sound again. Here, we are probably are hitting an SDL_APPACTIVE or SDL_APPINPUTFOCUS event more than once and since the block counter goes > 1 we are not restoring properly. For now, making snd_blocked to act as a boolean and not as a counter fixes the issue. Hmmm... * main_sdl.c: Revert revision 238 change, no longer necessary. * snd_dma.c: Make snd_blocked act as a boolean and not as a counter. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@241 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/main_sdl.c | 10 ++++------ Quake/snd_dma.c | 6 ++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Quake/main_sdl.c b/Quake/main_sdl.c index 4056911b..e1938a46 100644 --- a/Quake/main_sdl.c +++ b/Quake/main_sdl.c @@ -100,12 +100,10 @@ int main(int argc, char *argv[]) case SDL_ACTIVEEVENT: if (event.active.state & (SDL_APPACTIVE|SDL_APPINPUTFOCUS)) { - if (!COM_CheckParm("-bgsound")) { - if (event.active.gain) - S_UnblockSound(); - else - S_BlockSound(); - } + if (event.active.gain) + S_UnblockSound(); + else + S_BlockSound(); } break; case SDL_MOUSEMOTION: diff --git a/Quake/snd_dma.c b/Quake/snd_dma.c index 7050913f..cb1b5714 100644 --- a/Quake/snd_dma.c +++ b/Quake/snd_dma.c @@ -801,8 +801,9 @@ void S_BlockSound (void) /* FIXME: do we really need the blocking at the * driver level? */ - if (sound_started && ++snd_blocked == 1) + if (sound_started && snd_blocked == 0) /* ++snd_blocked == 1 */ { + snd_blocked = 1; S_ClearBuffer (); if (shm) SNDDMA_BlockSound(); @@ -813,8 +814,9 @@ void S_UnblockSound (void) { if (!sound_started || !snd_blocked) return; - if (--snd_blocked == 0) + if (snd_blocked == 1) /* --snd_blocked == 0 */ { + snd_blocked = 0; SNDDMA_UnblockSound(); S_ClearBuffer (); }