diff options
author | Filippos Karapetis | 2009-03-12 08:14:05 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-03-12 08:14:05 +0000 |
commit | fd14ebba143f0c9775d80d38b45c63bee4a8e61c (patch) | |
tree | 22f2ef27f52d4d43830ac015e8571c8d9edc4987 /engines | |
parent | 6a2efdd36df220581cdbf0742910007bada5147b (diff) | |
download | scummvm-rg350-fd14ebba143f0c9775d80d38b45c63bee4a8e61c.tar.gz scummvm-rg350-fd14ebba143f0c9775d80d38b45c63bee4a8e61c.tar.bz2 scummvm-rg350-fd14ebba143f0c9775d80d38b45c63bee4a8e61c.zip |
PMV player: stop reallocating the frame buffer on every frame, if its size hasn't been changed
svn-id: r39354
Diffstat (limited to 'engines')
-rw-r--r-- | engines/made/pmvplayer.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/engines/made/pmvplayer.cpp b/engines/made/pmvplayer.cpp index 5240a3980d..9796b01dfc 100644 --- a/engines/made/pmvplayer.cpp +++ b/engines/made/pmvplayer.cpp @@ -45,7 +45,7 @@ bool PmvPlayer::play(const char *filename) { return false; } - uint32 chunkType, chunkSize; + uint32 chunkType, chunkSize, prevChunkSize = 0; readChunk(chunkType, chunkSize); // "MOVE" if (chunkType != MKID_BE('MOVE')) { @@ -95,7 +95,7 @@ bool PmvPlayer::play(const char *filename) { uint32 soundSize = 0; uint32 soundChunkOfs = 0, palChunkOfs = 0; uint32 palSize = 0; - byte *frameData, *audioData, *soundData, *palData, *imageData; + byte *frameData = 0, *audioData, *soundData, *palData, *imageData; bool firstTime = true; uint32 soundStartTime = 0, skipFrames = 0; @@ -120,7 +120,16 @@ bool PmvPlayer::play(const char *filename) { if (_fd->eos()) break; - frameData = new byte[chunkSize]; + // Only reallocate the frame data buffer if its size has changed + if (prevChunkSize != chunkSize || !frameData) { + if (frameData) + delete[] frameData; + + frameData = new byte[chunkSize]; + } + + prevChunkSize = chunkSize; + bytesRead = _fd->read(frameData, chunkSize); if (bytesRead < chunkSize || _fd->eos()) @@ -182,8 +191,6 @@ bool PmvPlayer::play(const char *filename) { handleEvents(); updateScreen(); - delete[] frameData; - if (skipFrames == 0) { int32 waitTime = (frameCount * frameDelay) - (g_system->getMillis() - soundStartTime) - (_vm->_system->getMillis() - frameTime); @@ -201,6 +208,8 @@ bool PmvPlayer::play(const char *filename) { } + delete[] frameData; + _audioStream->finish(); _mixer->stopHandle(_audioStreamHandle); |