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
This commit is contained in:
terminx 2016-02-02 06:39:22 +00:00
parent 0edf078f0c
commit ea997707a1
4 changed files with 35 additions and 20 deletions

View file

@ -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)
{

View file

@ -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;
}

View file

@ -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<g_maxSoundPos; ++i)
{
for (int j = 0; j<MAXSOUNDINSTANCES; ++j)
{
if (g_sounds[i].SoundOwner[j].voice > 0)
FX_PauseVoice(g_sounds[i].SoundOwner[j].voice, onf);
}
}
}
void S_MusicVolume(int32_t volume)
{
if (MusicIsWaveform && MusicVoice >= 0)

View file

@ -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);