From 511b27b0fbc65c9e74067fc32d707c6e84191d1e Mon Sep 17 00:00:00 2001 From: molivier Date: Sun, 11 Apr 2004 17:34:51 +0000 Subject: [PATCH] Added an error message when the sound mixer requests more samples from a stream than its buffer can contain git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4093 d7cf8633-e32d-0410-b094-e92efae38249 --- snd_ogg.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/snd_ogg.c b/snd_ogg.c index 6c78a676..abfe3bc1 100644 --- 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) -- 2.39.2