Skip to content

Commit

Permalink
TOLTECS: Adapt the movie chunk buffer allocation code
Browse files Browse the repository at this point in the history
Thanks to wjp and LordHoto for their feedback
  • Loading branch information
bluegr committed Sep 14, 2012
1 parent f16bb13 commit 3919c51
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions engines/toltecs/movie.cpp
Expand Up @@ -98,7 +98,7 @@ void MoviePlayer::playMovie(uint resIndex) {

uint32 lastTime = _vm->_mixer->getSoundElapsedTime(_audioStreamHandle);
byte *chunkBuffer = NULL;
uint32 prevChunkSize = 0;
uint32 chunkBufferSize = 0;

while (_chunkCount--) {
byte chunkType = _vm->_arc->readByte();
Expand All @@ -111,13 +111,13 @@ void MoviePlayer::playMovie(uint resIndex) {
if (chunkType == kChunkAudio) {
_vm->_arc->skip(chunkSize);
} else {
// Only reallocate the chunk buffer if it's smaller than the previous frame
if (chunkSize > prevChunkSize) {
// Only reallocate the chunk buffer if the new chunk is bigger
if (chunkSize > chunkBufferSize) {
delete[] chunkBuffer;
chunkBuffer = new byte[chunkSize];
chunkBufferSize = chunkSize;
}

prevChunkSize = chunkSize;
_vm->_arc->read(chunkBuffer, chunkSize);
}

Expand Down

0 comments on commit 3919c51

Please sign in to comment.