summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorZack Middleton <zturtleman@gmail.com>2013-11-20 23:17:57 -0600
committerTim Angus <tim@ngus.net>2014-06-17 17:43:37 +0100
commitc98a54094cd6b4938fa4bb062bd71bb00bd707bf (patch)
tree3d9a3f19aa4ee431fbae458d76b92f8343919071 /src/client
parentb90e72cf5a5b6fa151746f412334779902ae4a86 (diff)
Fix signal 6 in S_Base_StartBackgroundTrack on OS X 10.9
In S_UpdateBackgroundTrack, s_backgroundLoop was passed to S_Base_StartBackgroundTrack and tried to copy to itself using Q_strncpyz.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/snd_dma.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/src/client/snd_dma.c b/src/client/snd_dma.c
index 081319ca..9ff982c4 100644
--- a/src/client/snd_dma.c
+++ b/src/client/snd_dma.c
@@ -1389,6 +1389,32 @@ void S_Base_StopBackgroundTrack( void ) {
/*
======================
+S_OpenBackgroundStream
+======================
+*/
+static void S_OpenBackgroundStream( const char *filename ) {
+ // close the background track, but DON'T reset s_rawend
+ // if restarting the same back ground track
+ if(s_backgroundStream)
+ {
+ S_CodecCloseStream(s_backgroundStream);
+ s_backgroundStream = NULL;
+ }
+
+ // Open stream
+ s_backgroundStream = S_CodecOpenStream(filename);
+ if(!s_backgroundStream) {
+ Com_Printf( S_COLOR_YELLOW "WARNING: couldn't open music file %s\n", filename );
+ return;
+ }
+
+ if(s_backgroundStream->info.channels != 2 || s_backgroundStream->info.rate != 22050) {
+ Com_Printf(S_COLOR_YELLOW "WARNING: music file %s is not 22k stereo\n", filename );
+ }
+}
+
+/*
+======================
S_StartBackgroundTrack
======================
*/
@@ -1413,24 +1439,7 @@ void S_Base_StartBackgroundTrack( const char *intro, const char *loop ){
Q_strncpyz( s_backgroundLoop, loop, sizeof( s_backgroundLoop ) );
}
- // close the background track, but DON'T reset s_rawend
- // if restarting the same back ground track
- if(s_backgroundStream)
- {
- S_CodecCloseStream(s_backgroundStream);
- s_backgroundStream = NULL;
- }
-
- // Open stream
- s_backgroundStream = S_CodecOpenStream(intro);
- if(!s_backgroundStream) {
- Com_Printf( S_COLOR_YELLOW "WARNING: couldn't open music file %s\n", intro );
- return;
- }
-
- if(s_backgroundStream->info.channels != 2 || s_backgroundStream->info.rate != 22050) {
- Com_Printf(S_COLOR_YELLOW "WARNING: music file %s is not 22k stereo\n", intro );
- }
+ S_OpenBackgroundStream( intro );
}
/*
@@ -1493,9 +1502,7 @@ void S_UpdateBackgroundTrack( void ) {
// loop
if(s_backgroundLoop[0])
{
- S_CodecCloseStream(s_backgroundStream);
- s_backgroundStream = NULL;
- S_Base_StartBackgroundTrack( s_backgroundLoop, s_backgroundLoop );
+ S_OpenBackgroundStream( s_backgroundLoop );
if(!s_backgroundStream)
return;
}