[Scummvm-cvs-logs] SF.net SVN: scummvm:[49053] scummvm/branches/branch-1-1-0
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Mon May 17 06:01:44 CEST 2010
Revision: 49053
http://scummvm.svn.sourceforge.net/scummvm/?rev=49053&view=rev
Author: eriktorbjorn
Date: 2010-05-17 04:01:44 +0000 (Mon, 17 May 2010)
Log Message:
-----------
Backported fix for bug #2976008 ("BS2: Game lockup in British Museum").
Modified Paths:
--------------
scummvm/branches/branch-1-1-0/NEWS
scummvm/branches/branch-1-1-0/engines/sword2/sound.cpp
Modified: scummvm/branches/branch-1-1-0/NEWS
===================================================================
--- scummvm/branches/branch-1-1-0/NEWS 2010-05-16 18:05:47 UTC (rev 49052)
+++ scummvm/branches/branch-1-1-0/NEWS 2010-05-17 04:01:44 UTC (rev 49053)
@@ -4,6 +4,8 @@
1.1.2 (????-??-??)
Broken Sword 2
- Fixed missing speech in some cutscenes.
+ - Fixed a memory leak that would eventually cause the game to hang.
+ (#2976008 - BS2: Game lockup in British Museum)
1.1.1 (2010-05-02)
New Ports:
Modified: scummvm/branches/branch-1-1-0/engines/sword2/sound.cpp
===================================================================
--- scummvm/branches/branch-1-1-0/engines/sword2/sound.cpp 2010-05-16 18:05:47 UTC (rev 49052)
+++ scummvm/branches/branch-1-1-0/engines/sword2/sound.cpp 2010-05-17 04:01:44 UTC (rev 49053)
@@ -214,13 +214,38 @@
assert(_vm->_resman->fetchType(data) == WAV_FILE);
- // In PSX version we have nothing to skip here, as data starts right away
- if (!Sword2Engine::isPsx()) {
- data += ResHeader::size();
- len -= ResHeader::size();
+ // We want to close the resource right away, so to be safe we make a
+ // private copy of the sound;
+ byte *soundData = (byte *)malloc(len);
+
+ if (soundData) {
+ memcpy(soundData, data, len);
+
+ Common::MemoryReadStream *stream = new Common::MemoryReadStream(soundData, len, DisposeAfterUse::YES);
+
+ // In PSX version we have nothing to skip here, as data starts
+ // right away.
+ if (!Sword2Engine::isPsx()) {
+ stream->seek(ResHeader::size());
+ }
+
+ Audio::RewindableAudioStream *input = 0;
+
+ if (Sword2Engine::isPsx()) {
+ input = Audio::makeVagStream(stream);
+ } else {
+ input = Audio::makeWAVStream(stream, DisposeAfterUse::YES);
+ }
+
+ _vm->_mixer->playInputStream(
+ Audio::Mixer::kMusicSoundType, handle, input,
+ -1, Audio::Mixer::kMaxChannelVolume, 0,
+ DisposeAfterUse::YES, false, isReverseStereo());
+ } else {
+ warning("Sound::playMovieSound: Could not allocate %d bytes\n", len);
}
- _vm->_sound->playFx(handle, data, len, Audio::Mixer::kMaxChannelVolume, 0, false, Audio::Mixer::kMusicSoundType);
+ _vm->_resman->closeResource(res);
}
void Sound::stopMovieSounds() {
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