mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-20 19:12:03 +00:00
hook up pause/resume
This commit is contained in:
parent
e14fc05aab
commit
2983bf5c49
3 changed files with 37 additions and 5 deletions
|
@ -159,7 +159,8 @@ void CDAudio_Pause(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: pause in backend
|
// FIXME: pause in backend
|
||||||
|
S_PauseBackgroundTrack();
|
||||||
|
|
||||||
wasPlaying = playing;
|
wasPlaying = playing;
|
||||||
playing = false;
|
playing = false;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +174,8 @@ void CDAudio_Resume(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: resume in backend
|
// FIXME: resume in backend
|
||||||
|
S_ResumeBackgroundTrack();
|
||||||
|
|
||||||
playing = true;
|
playing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ void S_StopAllSounds(qboolean clear);
|
||||||
void S_StopAllSoundsC(void);
|
void S_StopAllSoundsC(void);
|
||||||
|
|
||||||
snd_stream_t *s_backgroundStream = NULL;
|
snd_stream_t *s_backgroundStream = NULL;
|
||||||
|
static qboolean s_backgroundPaused = false;
|
||||||
static char s_backgroundLoop[MAX_QPATH];
|
static char s_backgroundLoop[MAX_QPATH];
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,6 +211,8 @@ void S_Shutdown (void)
|
||||||
if (!sound_started)
|
if (!sound_started)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
S_CodecShutdown();
|
||||||
|
|
||||||
if (shm)
|
if (shm)
|
||||||
shm->gamealive = 0;
|
shm->gamealive = 0;
|
||||||
sound_started = 0;
|
sound_started = 0;
|
||||||
|
@ -956,6 +959,24 @@ void S_Update_(void)
|
||||||
===============================================================================
|
===============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
======================
|
||||||
|
S_PauseBackgroundTrack
|
||||||
|
======================
|
||||||
|
*/
|
||||||
|
void S_PauseBackgroundTrack( void ) {
|
||||||
|
s_backgroundPaused = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
======================
|
||||||
|
S_ResumeBackgroundTrack
|
||||||
|
======================
|
||||||
|
*/
|
||||||
|
void S_ResumeBackgroundTrack( void ) {
|
||||||
|
s_backgroundPaused = false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
======================
|
======================
|
||||||
S_StopBackgroundTrack
|
S_StopBackgroundTrack
|
||||||
|
@ -996,6 +1017,8 @@ void S_Base_StartBackgroundTrack( const char *intro, const char *loop ){
|
||||||
s_backgroundLoop[MAX_QPATH-1] = '\0';
|
s_backgroundLoop[MAX_QPATH-1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s_backgroundPaused = false;
|
||||||
|
|
||||||
// close the background track, but DON'T reset s_rawend
|
// close the background track, but DON'T reset s_rawend
|
||||||
// if restarting the same back ground track
|
// if restarting the same back ground track
|
||||||
if(s_backgroundStream)
|
if(s_backgroundStream)
|
||||||
|
@ -1011,9 +1034,9 @@ void S_Base_StartBackgroundTrack( const char *intro, const char *loop ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s_backgroundStream->info.channels != 2 || s_backgroundStream->info.rate != 22050) {
|
//if(s_backgroundStream->info.channels != 2 || s_backgroundStream->info.rate != 22050) {
|
||||||
Con_Printf( "WARNING: music file %s is %d channels and %d Hz\n", intro, s_backgroundStream->info.channels, s_backgroundStream->info.rate );
|
// Con_Printf( "WARNING: music file %s is %d channels and %d Hz\n", intro, s_backgroundStream->info.channels, s_backgroundStream->info.rate );
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1032,11 +1055,16 @@ void S_UpdateBackgroundTrack( void ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this means setting the music volume to 0 pauses it.. not sure if that's great
|
||||||
// don't bother playing anything if musicvolume is 0
|
// don't bother playing anything if musicvolume is 0
|
||||||
if ( bgmvolume.value <= 0 ) {
|
if ( bgmvolume.value <= 0 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( s_backgroundPaused ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// see how many samples should be copied into the raw buffer
|
// see how many samples should be copied into the raw buffer
|
||||||
if ( s_rawend[0] < soundtime ) {
|
if ( s_rawend[0] < soundtime ) {
|
||||||
s_rawend[0] = soundtime;
|
s_rawend[0] = soundtime;
|
||||||
|
|
|
@ -140,6 +140,8 @@ void SNDDMA_BlockSound(void);
|
||||||
/* unblocks the output upon window focus gain */
|
/* unblocks the output upon window focus gain */
|
||||||
void SNDDMA_UnblockSound(void);
|
void SNDDMA_UnblockSound(void);
|
||||||
|
|
||||||
|
void S_PauseBackgroundTrack( void );
|
||||||
|
void S_ResumeBackgroundTrack( void );
|
||||||
void S_Base_StopBackgroundTrack( void );
|
void S_Base_StopBackgroundTrack( void );
|
||||||
void S_Base_StartBackgroundTrack( const char *intro, const char *loop );
|
void S_Base_StartBackgroundTrack( const char *intro, const char *loop );
|
||||||
void S_UpdateBackgroundTrack( void );
|
void S_UpdateBackgroundTrack( void );
|
||||||
|
|
Loading…
Reference in a new issue