aboutsummaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
authortjw <tjw@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-08-03 02:29:47 +0000
committertjw <tjw@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-08-03 02:29:47 +0000
commitcb3275a714bd6cfc492097353b8a56bcea21338c (patch)
tree355760b1845a842fb13a05e82b6f781125e09c32 /code
parenteca4dc8aae61005b39d73eef9a63d7f17b5ce811 (diff)
downloadioquake3-aero-cb3275a714bd6cfc492097353b8a56bcea21338c.tar.gz
ioquake3-aero-cb3275a714bd6cfc492097353b8a56bcea21338c.zip
bug 2747
* open music stream in S_AL_StartBackgroundTrack() instead of relying on S_AL_MusicProcess() to open it. This allows S_AL_MusicProcess() to return early when called whenever there is no open music stream to prevent a segfault. git-svn-id: svn://svn.icculus.org/quake3/trunk@832 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code')
-rw-r--r--code/client/snd_openal.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/code/client/snd_openal.c b/code/client/snd_openal.c
index 1cbd714..ad1baa5 100644
--- a/code/client/snd_openal.c
+++ b/code/client/snd_openal.c
@@ -1369,6 +1369,9 @@ void S_AL_MusicProcess(ALuint b)
int l;
ALuint format;
+ if(!mus_stream)
+ return;
+
l = S_CodecReadStream(mus_stream, MUSIC_BUFFER_SIZE, decode_buffer);
// Run out data to read, start at the beginning again
@@ -1443,6 +1446,13 @@ void S_AL_StartBackgroundTrack( const char *intro, const char *loop )
if(musicSourceHandle == -1)
return;
+ mus_stream = S_CodecOpenStream(s_backgroundLoop);
+ if(!mus_stream)
+ {
+ S_AL_MusicSourceFree();
+ return;
+ }
+
// Generate the musicBuffers
qalGenBuffers(NUM_MUSIC_BUFFERS, musicBuffers);
@@ -1450,19 +1460,6 @@ void S_AL_StartBackgroundTrack( const char *intro, const char *loop )
for(i = 0; i < NUM_MUSIC_BUFFERS; i++)
{
S_AL_MusicProcess(musicBuffers[i]);
-
- // check whether our stream still exists.
- if(!mus_stream)
- {
- // there was an error in reading which resulted in a
- // closed stream. We must bail out or we'll crash.
-
- // deallocate everything we allocated so far:
- qalDeleteBuffers(NUM_MUSIC_BUFFERS, musicBuffers);
- S_AL_MusicSourceFree();
-
- return;
- }
}
qalSourceQueueBuffers(musicSource, NUM_MUSIC_BUFFERS, musicBuffers);