mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-27 19:30:41 +00:00
VIDEO: Fix QuickTime audio buffering on the last frame
svn-id: r55450
This commit is contained in:
parent
bcf62fa8b9
commit
257a6b2e6d
@ -1419,24 +1419,30 @@ void QuickTimeDecoder::updateAudioBuffer() {
|
||||
if (!_audStream)
|
||||
return;
|
||||
|
||||
STSDEntry *entry = &_streams[_audioStreamIndex]->stsdEntries[0];
|
||||
|
||||
// Calculate the amount of chunks we need in memory until the next frame
|
||||
uint32 timeToNextFrame = getTimeToNextFrame();
|
||||
uint32 numberOfChunksNeeded = 0;
|
||||
uint32 timeFilled = 0;
|
||||
uint32 curAudioChunk = _curAudioChunk - _audStream->numQueuedStreams();
|
||||
|
||||
for (; timeFilled < timeToNextFrame && curAudioChunk < _streams[_audioStreamIndex]->chunk_count; numberOfChunksNeeded++, curAudioChunk++) {
|
||||
uint32 sampleCount = getAudioChunkSampleCount(curAudioChunk);
|
||||
assert(sampleCount);
|
||||
if (_curFrame == (int32)_streams[_videoStreamIndex]->nb_frames - 1) {
|
||||
// If we're on the last frame, make sure all audio remaining is buffered
|
||||
numberOfChunksNeeded = _streams[_audioStreamIndex]->chunk_count;
|
||||
} else {
|
||||
STSDEntry *entry = &_streams[_audioStreamIndex]->stsdEntries[0];
|
||||
|
||||
timeFilled += sampleCount * 1000 / entry->sampleRate;
|
||||
// Calculate the amount of chunks we need in memory until the next frame
|
||||
uint32 timeToNextFrame = getTimeToNextFrame();
|
||||
uint32 timeFilled = 0;
|
||||
uint32 curAudioChunk = _curAudioChunk - _audStream->numQueuedStreams();
|
||||
|
||||
for (; timeFilled < timeToNextFrame && curAudioChunk < _streams[_audioStreamIndex]->chunk_count; numberOfChunksNeeded++, curAudioChunk++) {
|
||||
uint32 sampleCount = getAudioChunkSampleCount(curAudioChunk);
|
||||
assert(sampleCount);
|
||||
|
||||
timeFilled += sampleCount * 1000 / entry->sampleRate;
|
||||
}
|
||||
|
||||
// Add a couple extra to ensure we don't underrun
|
||||
numberOfChunksNeeded += 3;
|
||||
}
|
||||
|
||||
// Add a couple extra to ensure we don't underrun
|
||||
numberOfChunksNeeded += 3;
|
||||
|
||||
// Keep three streams in buffer so that if/when the first two end, it goes right into the next
|
||||
while (_audStream->numQueuedStreams() < numberOfChunksNeeded && _curAudioChunk < _streams[_audioStreamIndex]->chunk_count)
|
||||
readNextAudioChunk();
|
||||
|
Loading…
Reference in New Issue
Block a user