From: molivier Date: Thu, 15 Jun 2006 06:13:08 +0000 (+0000) Subject: Fixed OGG Vorbis code when using OGGs with a sound frequency smaller than the sound... X-Git-Tag: xonotic-v0.1.0preview~3898 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=2644e744ff4c4aa8170b90ff0afe548721080458;p=xonotic%2Fdarkplaces.git Fixed OGG Vorbis code when using OGGs with a sound frequency smaller than the sound output frequency (the code was wrongly using the OGG sound format instead of the output sound format to compute the streaming buffer size). Thanks to Dresk for reporting this problem git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6480 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/snd_ogg.c b/snd_ogg.c index 0a6f7fdd..8a268203 100644 --- a/snd_ogg.c +++ b/snd_ogg.c @@ -410,7 +410,6 @@ static const snd_buffer_t* OGG_FetchSound (channel_t* ch, unsigned int* start, u ogg_stream_perchannel_t* per_ch; sfx_t* sfx; ogg_stream_persfx_t* per_sfx; - snd_format_t* ogg_format; snd_buffer_t* sb; int newlength, done, ret, bigendian; unsigned int real_start; @@ -419,14 +418,18 @@ static const snd_buffer_t* OGG_FetchSound (channel_t* ch, unsigned int* start, u per_ch = (ogg_stream_perchannel_t *)ch->fetcher_data; sfx = ch->sfx; per_sfx = (ogg_stream_persfx_t *)sfx->fetcher_data; - ogg_format = &per_sfx->format; // If there's no fetcher structure attached to the channel yet if (per_ch == NULL) { size_t buff_len, memsize; + snd_format_t sb_format; - buff_len = STREAM_BUFFER_SIZE(ogg_format); + sb_format.speed = snd_renderbuffer->format.speed; + sb_format.width = per_sfx->format.width; + sb_format.channels = per_sfx->format.channels; + + buff_len = STREAM_BUFFER_SIZE(&sb_format); memsize = sizeof (*per_ch) - sizeof (per_ch->sb.samples) + buff_len; per_ch = (ogg_stream_perchannel_t *)Mem_Alloc (snd_mempool, memsize); sfx->memsize += memsize; @@ -444,9 +447,7 @@ static const snd_buffer_t* OGG_FetchSound (channel_t* ch, unsigned int* start, u per_ch->bs = 0; per_ch->sb_offset = 0; - per_ch->sb.format.speed = snd_renderbuffer->format.speed; - per_ch->sb.format.width = ogg_format->width; - per_ch->sb.format.channels = ogg_format->channels; + per_ch->sb.format = sb_format; per_ch->sb.nbframes = 0; per_ch->sb.maxframes = buff_len / (per_ch->sb.format.channels * per_ch->sb.format.width);