r832 - trunk/code/client

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Aug 2 22:29:47 EDT 2006


Author: tjw
Date: 2006-08-02 22:29:47 -0400 (Wed, 02 Aug 2006)
New Revision: 832

Modified:
   trunk/code/client/snd_openal.c
Log:
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.


Modified: trunk/code/client/snd_openal.c
===================================================================
--- trunk/code/client/snd_openal.c	2006-08-02 05:12:20 UTC (rev 831)
+++ trunk/code/client/snd_openal.c	2006-08-03 02:29:47 UTC (rev 832)
@@ -1369,6 +1369,9 @@
 	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 @@
 	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 @@
 	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);




More information about the quake3-commits mailing list