Handle the case where the WAVE magic number was already read in a non-seekable
authorSam Lantinga <slouken@libsdl.org>
Tue, 11 Sep 2001 18:52:45 +0000
changeset 171 02e27b705645
parent 170 9427fb48592a
child 172 37e3ca9254c7
Handle the case where the WAVE magic number was already read in a non-seekable stream. I don't know if the code works with non-seekable streams anyway, but ...
src/audio/SDL_wave.c
--- a/src/audio/SDL_wave.c	Tue Sep 04 23:22:23 2001 +0000
+++ b/src/audio/SDL_wave.c	Tue Sep 11 18:52:45 2001 +0000
@@ -434,7 +434,13 @@
 	/* Check the magic header */
 	RIFFchunk	= SDL_ReadLE32(src);
 	wavelen		= SDL_ReadLE32(src);
-	WAVEmagic	= SDL_ReadLE32(src);
+	if ( wavelen == WAVE ) { /* The RIFFchunk has already been read */
+		WAVEmagic = wavelen;
+		wavelen   = RIFFchunk;
+		RIFFchunk = RIFF;
+	} else {
+		WAVEmagic = SDL_ReadLE32(src);
+	}
 	if ( (RIFFchunk != RIFF) || (WAVEmagic != WAVE) ) {
 		SDL_SetError("Unrecognized file type (not WAVE)");
 		was_error = 1;