mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
Fixed crash with very short music loop
https://forum.zdoom.org/viewtopic.php?t=59883
This commit is contained in:
parent
fae6f22a2b
commit
d58169f1b0
1 changed files with 10 additions and 5 deletions
|
@ -419,13 +419,18 @@ bool SndFileSong::Read(SoundStream *stream, void *vbuff, int ilen, void *userdat
|
|||
{
|
||||
// This looks a bit more complicated than necessary because libmpg123 will not read the full requested length for the last block in the file.
|
||||
if (currentpos + framestoread > song->Loop_End)
|
||||
{
|
||||
// Loop can be very short, make sure the current position doesn't exceed it
|
||||
if (currentpos < song->Loop_End)
|
||||
{
|
||||
size_t endblock = (song->Loop_End - currentpos) * song->Channels * 2;
|
||||
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;
|
||||
buff += endlen;
|
||||
len -= endlen;
|
||||
}
|
||||
|
||||
song->Decoder->seek(song->Loop_Start, false, true);
|
||||
}
|
||||
while (len > 0)
|
||||
|
|
Loading…
Reference in a new issue