Added an error message when the sound mixer requests more samples from a stream than...
authormolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 11 Apr 2004 17:34:51 +0000 (17:34 +0000)
committermolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 11 Apr 2004 17:34:51 +0000 (17:34 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4093 d7cf8633-e32d-0410-b094-e92efae38249

snd_ogg.c

index 6c78a67..abfe3bc 100644 (file)
--- a/snd_ogg.c
+++ b/snd_ogg.c
@@ -415,13 +415,20 @@ static const sfxbuffer_t* OGG_FetchSound (channel_t* ch, unsigned int start, uns
        }
 
        sb = &per_ch->sb;
+       factor = per_ch->format.width * per_ch->format.channels;
+
+       // If the stream buffer can't contain that much samples anyway
+       if (nbsamples * factor > STREAM_BUFFER_SIZE)
+       {
+               Con_Printf ("OGG_FetchSound: stream buffer too small (%u bytes required)\n", nbsamples * factor);
+               return NULL;
+       }
 
        // If the data we need has already been decompressed in the sfxbuffer, just return it
        if (sb->offset <= start && sb->offset + sb->length >= start + nbsamples)
                return sb;
 
        newlength = sb->offset + sb->length - start;
-       factor = per_ch->format.width * per_ch->format.channels;
 
        // If we need to skip some data before decompressing the rest, or if the stream has looped
        if (newlength < 0 || sb->offset > start)