Fixed sound looping when stream length is a multiply of buffer size

https://forum.zdoom.org/viewtopic.php?t=57164
This commit is contained in:
alexey.lysiuk 2017-07-09 13:28:16 +03:00
parent 58b348e75a
commit afe1199b69

View file

@ -339,18 +339,12 @@ bool SndFileSong::Read(SoundStream *stream, void *vbuff, int ilen, void *userdat
if (currentpos + framestoread > song->Loop_End)
{
size_t endblock = (song->Loop_End - currentpos) * song->Channels * 2;
size_t endlen = song->Decoder->read(buff, 0 == endblock ? len : endblock);
if (endlen != 0)
{
buff = buff + endlen;
len -= endlen;
song->Decoder->seek(song->Loop_Start, false, true);
}
else
{
song->CritSec.Leave();
return false;
}
size_t endlen = song->Decoder->read(buff, endblock);
// Even if zero bytes was read give it a chance to start from the beginning
buff = buff + endlen;
len -= endlen;
song->Decoder->seek(song->Loop_Start, false, true);
}
while (len > 0)
{