From ea997707a1118210a6955c1be50ae7c32d7d5e78 Mon Sep 17 00:00:00 2001 From: terminx Date: Tue, 2 Feb 2016 06:39:22 +0000 Subject: [PATCH] Pause and resume sounds instead of just stopping them when opening menus or pausing the game. git-svn-id: https://svn.eduke32.com/eduke32@5606 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/game.c | 28 ++++++++++------------------ polymer/eduke32/source/sector.c | 6 ++++-- polymer/eduke32/source/sounds.c | 20 ++++++++++++++++++++ polymer/eduke32/source/sounds.h | 1 + 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 34b6b0c1c..e67654740 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -3787,15 +3787,14 @@ void G_DisplayRest(int32_t smoothratio) I_EscapeTriggerClear(); S_PlaySound(EXITMENUSOUND); M_ChangeMenu(MENU_CLOSE); + S_PauseSounds(0); } else if ((g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU && g_player[myconnectindex].ps->newowner == -1 && (g_player[myconnectindex].ps->gm&MODE_TYPE) != MODE_TYPE) { I_EscapeTriggerClear(); - FX_StopAllSounds(); - S_ClearSoundLocks(); - + S_PauseSounds(1); S_MenuSound(); M_OpenMenu(myconnectindex); @@ -9031,9 +9030,8 @@ void G_HandleLocalKeys(void) { KB_ClearKeyDown(sc_F1); M_ChangeMenu(MENU_STORY); - FX_StopAllSounds(); - S_ClearSoundLocks(); + S_PauseSounds(1); M_OpenMenu(myconnectindex); if ((!g_netServer && ud.multimode < 2)) @@ -9083,8 +9081,7 @@ FAKE_F2: G_DrawRooms(myconnectindex,65536); g_screenCapture = 0; - FX_StopAllSounds(); - S_ClearSoundLocks(); + S_PauseSounds(1); // setview(0,0,xdim-1,ydim-1); M_OpenMenu(myconnectindex); @@ -9103,8 +9100,8 @@ FAKE_F2: FAKE_F3: M_ChangeMenu(MENU_LOAD); - FX_StopAllSounds(); - S_ClearSoundLocks(); + + S_PauseSounds(1); // setview(0,0,xdim-1,ydim-1); M_OpenMenu(myconnectindex); @@ -9120,8 +9117,7 @@ FAKE_F3: if (KB_UnBoundKeyPressed(sc_F4)) { KB_ClearKeyDown(sc_F4); - FX_StopAllSounds(); - S_ClearSoundLocks(); + S_PauseSounds(1); M_OpenMenu(myconnectindex); if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) @@ -9218,9 +9214,7 @@ FAKE_F3: { KB_FlushKeyboardQueue(); KB_ClearKeysDown(); - FX_StopAllSounds(); - S_ClearSoundLocks(); - + S_PauseSounds(1); G_LoadPlayerMaybeMulti(g_lastSaveSlot); } } @@ -9229,8 +9223,7 @@ FAKE_F3: { KB_ClearKeyDown(sc_F10); M_ChangeMenu(MENU_QUIT_INGAME); - FX_StopAllSounds(); - S_ClearSoundLocks(); + S_PauseSounds(1); M_OpenMenu(myconnectindex); if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) { @@ -9243,8 +9236,7 @@ FAKE_F3: { KB_ClearKeyDown(sc_F11); M_ChangeMenu(MENU_COLCORR_INGAME); - FX_StopAllSounds(); - S_ClearSoundLocks(); + S_PauseSounds(1); M_OpenMenu(myconnectindex); if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) { diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 613601b67..1d6d33ae1 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -2461,12 +2461,14 @@ void P_HandleSharedKeys(int32_t snum) if (ud.pause_on) { S_PauseMusic(1); - FX_StopAllSounds(); - S_ClearSoundLocks(); + S_PauseSounds(1); } else { if (ud.config.MusicToggle) S_PauseMusic(0); + + S_PauseSounds(0); + pub = NUMPAGES; pus = NUMPAGES; } diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index 8367c51c1..efe62177c 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -50,6 +50,7 @@ static int32_t MusicIsWaveform = 0; static char *MusicPtr = NULL; static int32_t MusicVoice = -1; static int32_t MusicPaused = 0; +static int32_t SoundPaused = 0; static mutex_t s_mutex; static volatile uint32_t dq[DQSIZE], dnum = 0; @@ -148,6 +149,25 @@ void S_PauseMusic(int32_t onf) MUSIC_Continue(); } +void S_PauseSounds(int32_t onf) +{ + if (SoundPaused == onf) + return; + + SoundPaused = onf; + + for (int i=0; i 0) + FX_PauseVoice(g_sounds[i].SoundOwner[j].voice, onf); + } + } +} + + + void S_MusicVolume(int32_t volume) { if (MusicIsWaveform && MusicVoice >= 0) diff --git a/polymer/eduke32/source/sounds.h b/polymer/eduke32/source/sounds.h index 98f1c89eb..39ca9c33f 100644 --- a/polymer/eduke32/source/sounds.h +++ b/polymer/eduke32/source/sounds.h @@ -95,6 +95,7 @@ void S_MusicStartup(void); void S_MusicVolume(int32_t volume); void S_RestartMusic(void); void S_PauseMusic(int32_t onf); +void S_PauseSounds(int32_t onf); int32_t S_PlayMusic(const char *fn); int32_t S_PlaySound(int32_t num); int32_t S_PlaySound3D(int32_t num,int32_t i,const vec3_t *pos);