libvgm: Fix track ending without glitches
Track rendering returns the number of bytes rendered, which also cuts short when the track ends. So properly react to this count when running the player, so we don't keep trying to render, or pick up uninitialized data from the buffer. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
471fc2f725
commit
0263367639
1 changed files with 8 additions and 3 deletions
|
@ -242,11 +242,16 @@ const int masterVol = 0x10000; // Fixed point 16.16
|
|||
|
||||
int numSamples = framesToDo * numChannels * (numBitsPerSample / 8);
|
||||
|
||||
mainPlr->Render(numSamples, buf);
|
||||
UINT32 numRendered = mainPlr->Render(numSamples, buf);
|
||||
|
||||
buf = (void*)(((uint8_t*)buf) + numSamples);
|
||||
buf = (void*)(((uint8_t*)buf) + numRendered);
|
||||
|
||||
framesDone += framesToDo;
|
||||
UINT32 framesRendered = numRendered / (numChannels * (numBitsPerSample / 8));
|
||||
|
||||
framesDone += framesRendered;
|
||||
|
||||
if(framesRendered < framesToDo)
|
||||
break;
|
||||
}
|
||||
|
||||
[chunk setStreamTimestamp:streamTimestamp];
|
||||
|
|
Loading…
Reference in a new issue