mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-27 06:42:23 +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
|
||||
for storing decoded OGG/Vorbis data.
|
||||
We take the number of active buffers
|
||||
at startup (at this point most of the
|
||||
samples should be precached and loaded
|
||||
into buffers) and add 64. Empircal
|
||||
testing showed, that at most times
|
||||
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)
|
||||
and add 256. 256 are about 12 seconds
|
||||
worth of sound, more than enough to
|
||||
be resilent against underruns. */
|
||||
if (ogg_numbufs == 0 || active_buffers < ogg_numbufs - 256)
|
||||
{
|
||||
ogg_numbufs = active_buffers + 64;
|
||||
ogg_numbufs = active_buffers + 256;
|
||||
}
|
||||
|
||||
/* active_buffers are all active OpenAL buffers,
|
||||
|
|
Loading…
Reference in a new issue