aboutsummaryrefslogtreecommitdiff
path: root/engines/toltecs
diff options
context:
space:
mode:
authorFilippos Karapetis2012-09-11 00:33:32 +0300
committerFilippos Karapetis2012-09-11 00:34:31 +0300
commit5ea896b069df70e7c1fa8467b89457b200e33dc0 (patch)
tree0229a1fd2ba2e1b1ac74f1d64b0fef0d295c7595 /engines/toltecs
parentde75d25725bb58870b74f780d4941eb7f66639b0 (diff)
downloadscummvm-rg350-5ea896b069df70e7c1fa8467b89457b200e33dc0.tar.gz
scummvm-rg350-5ea896b069df70e7c1fa8467b89457b200e33dc0.tar.bz2
scummvm-rg350-5ea896b069df70e7c1fa8467b89457b200e33dc0.zip
TOLTECS: Stop reallocating the chunk buffer on each movie frame
This somewhat reduces the stuttering in the intro movie (but it's still there)
Diffstat (limited to 'engines/toltecs')
-rw-r--r--engines/toltecs/movie.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/engines/toltecs/movie.cpp b/engines/toltecs/movie.cpp
index 5f6fe2cac6..79cdd08ec1 100644
--- a/engines/toltecs/movie.cpp
+++ b/engines/toltecs/movie.cpp
@@ -97,12 +97,12 @@ void MoviePlayer::playMovie(uint resIndex) {
fetchAudioChunks();
uint32 lastTime = _vm->_mixer->getSoundElapsedTime(_audioStreamHandle);
+ byte *chunkBuffer = NULL;
+ uint32 prevChunkSize = 0;
while (_chunkCount--) {
-
byte chunkType = _vm->_arc->readByte();
uint32 chunkSize = _vm->_arc->readUint32LE();
- byte *chunkBuffer = NULL;
debug(0, "chunkType = %d; chunkSize = %d", chunkType, chunkSize);
@@ -111,7 +111,13 @@ void MoviePlayer::playMovie(uint resIndex) {
if (chunkType == kChunkAudio) {
_vm->_arc->skip(chunkSize);
} else {
- chunkBuffer = new byte[chunkSize];
+ // Only reallocate the chunk buffer if it's smaller than the previous frame
+ if (chunkSize > prevChunkSize) {
+ delete[] chunkBuffer;
+ chunkBuffer = new byte[chunkSize];
+ }
+
+ prevChunkSize = chunkSize;
_vm->_arc->read(chunkBuffer, chunkSize);
}
@@ -172,14 +178,13 @@ void MoviePlayer::playMovie(uint resIndex) {
default:
error("MoviePlayer::playMovie(%04X) Unknown chunk type %d at %08X", resIndex, chunkType, _vm->_arc->pos() - 5 - chunkSize);
}
-
- delete[] chunkBuffer;
-
+
if (!handleInput())
break;
-
}
+ delete[] chunkBuffer;
+
_audioStream->finish();
_vm->_mixer->stopHandle(_audioStreamHandle);