[Scummvm-cvs-logs] SF.net SVN: scummvm:[39354] scummvm/trunk/engines/made/pmvplayer.cpp
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Thu Mar 12 09:14:06 CET 2009
Revision: 39354
http://scummvm.svn.sourceforge.net/scummvm/?rev=39354&view=rev
Author: thebluegr
Date: 2009-03-12 08:14:05 +0000 (Thu, 12 Mar 2009)
Log Message:
-----------
PMV player: stop reallocating the frame buffer on every frame, if its size hasn't been changed
Modified Paths:
--------------
scummvm/trunk/engines/made/pmvplayer.cpp
Modified: scummvm/trunk/engines/made/pmvplayer.cpp
===================================================================
--- scummvm/trunk/engines/made/pmvplayer.cpp 2009-03-12 03:26:58 UTC (rev 39353)
+++ scummvm/trunk/engines/made/pmvplayer.cpp 2009-03-12 08:14:05 UTC (rev 39354)
@@ -45,7 +45,7 @@
return false;
}
- uint32 chunkType, chunkSize;
+ uint32 chunkType, chunkSize, prevChunkSize = 0;
readChunk(chunkType, chunkSize); // "MOVE"
if (chunkType != MKID_BE('MOVE')) {
@@ -95,7 +95,7 @@
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 @@
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 @@
handleEvents();
updateScreen();
- delete[] frameData;
-
if (skipFrames == 0) {
int32 waitTime = (frameCount * frameDelay) -
(g_system->getMillis() - soundStartTime) - (_vm->_system->getMillis() - frameTime);
@@ -201,6 +208,8 @@
}
+ delete[] frameData;
+
_audioStream->finish();
_mixer->stopHandle(_audioStreamHandle);
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