bgmusic.c (BGM_UpdateStream): avoid a possible endless loop.

(just a paranoid safeguard, shouldn't happen in real life.)

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1311 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Ozkan Sezer 2016-06-23 08:03:43 +00:00
parent 0ff9c26db7
commit 623f8c6698

View file

@ -366,6 +366,7 @@ void BGM_Resume (void)
static void BGM_UpdateStream (void)
{
qboolean did_rewind = false;
int res; /* Number of bytes read. */
int bufferSamples;
int fileSamples;
@ -415,11 +416,19 @@ static void BGM_UpdateStream (void)
bgmstream->info.width,
bgmstream->info.channels,
raw, bgmvolume.value);
did_rewind = false;
}
else if (res == 0) /* EOF */
{
if (bgmloop)
{
if (did_rewind)
{
Con_Printf("Stream keeps returning EOF.\n");
BGM_Stop();
return;
}
res = S_CodecRewindStream(bgmstream);
if (res != 0)
{
@ -427,6 +436,7 @@ static void BGM_UpdateStream (void)
BGM_Stop();
return;
}
did_rewind = true;
}
else
{