[Scummvm-cvs-logs] SF.net SVN: scummvm:[55450] scummvm/trunk/graphics/video/qt_decoder.cpp
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Sun Jan 23 00:31:21 CET 2011
Revision: 55450
http://scummvm.svn.sourceforge.net/scummvm/?rev=55450&view=rev
Author: mthreepwood
Date: 2011-01-22 23:31:21 +0000 (Sat, 22 Jan 2011)
Log Message:
-----------
VIDEO: Fix QuickTime audio buffering on the last frame
Modified Paths:
--------------
scummvm/trunk/graphics/video/qt_decoder.cpp
Modified: scummvm/trunk/graphics/video/qt_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/qt_decoder.cpp 2011-01-22 21:58:33 UTC (rev 55449)
+++ scummvm/trunk/graphics/video/qt_decoder.cpp 2011-01-22 23:31:21 UTC (rev 55450)
@@ -1419,24 +1419,30 @@
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();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list