mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Fix possible Vorbis buffer underruns.
There're two possible problems with the calculation of the number of sound buffers for Vorbis if OpenAL is in use: * We assume that the (more or less) maximum number buffers is allocated during map load. This is not correct if in a multiplayer game a lot of custom models with custom sound connect at a later time. * 64 buffers (about 3 seconds worth of music) may be too low in some situations. Work around this by recalculating the number of buffers if necessary. We're now reserving about 256 (== 12 seconds) buffers. This may fix issue #252.
This commit is contained in:
parent
7b6340ddff
commit
1396741904
1 changed files with 5 additions and 11 deletions
|
@ -636,18 +636,12 @@ OGG_Stream(void)
|
||||||
/* Calculate the number of buffers used
|
/* Calculate the number of buffers used
|
||||||
for storing decoded OGG/Vorbis data.
|
for storing decoded OGG/Vorbis data.
|
||||||
We take the number of active buffers
|
We take the number of active buffers
|
||||||
at startup (at this point most of the
|
and add 256. 256 are about 12 seconds
|
||||||
samples should be precached and loaded
|
worth of sound, more than enough to
|
||||||
into buffers) and add 64. Empircal
|
be resilent against underruns. */
|
||||||
testing showed, that at most times
|
if (ogg_numbufs == 0 || active_buffers < ogg_numbufs - 256)
|
||||||
at least 52 buffers remain available
|
|
||||||
for OGG/Vorbis, enough for about 3
|
|
||||||
seconds playback. The music won't
|
|
||||||
stutter as long as the framerate
|
|
||||||
stayes over 1 FPS. */
|
|
||||||
if (ogg_numbufs == 0)
|
|
||||||
{
|
{
|
||||||
ogg_numbufs = active_buffers + 64;
|
ogg_numbufs = active_buffers + 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* active_buffers are all active OpenAL buffers,
|
/* active_buffers are all active OpenAL buffers,
|
||||||
|
|
Loading…
Reference in a new issue