From 57eae5da918e905d6c9582c16e5cbf2b2c7cc4d1 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Wed, 20 Nov 2013 23:17:57 -0600 Subject: [PATCH] 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. --- code/client/snd_dma.c | 49 ++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/code/client/snd_dma.c b/code/client/snd_dma.c index 1e78f350..d623ec4c 100644 --- a/code/client/snd_dma.c +++ b/code/client/snd_dma.c @@ -1371,6 +1371,32 @@ void S_Base_StopBackgroundTrack( void ) { s_rawend[0] = 0; } +/* +====================== +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 @@ -1397,24 +1423,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 ); } /* @@ -1477,9 +1486,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; }