diff options
author | Martin Kiewitz | 2015-06-10 00:04:20 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-06-10 07:14:15 +0200 |
commit | 256158cbe225c2c8f2d663c7620d9d9ed9587b38 (patch) | |
tree | ebcb50390290eb8d29cc9ba434f06d8350a8b450 /engines | |
parent | 6aaee559dc7f26240678421043baa865608b7d58 (diff) | |
download | scummvm-rg350-256158cbe225c2c8f2d663c7620d9d9ed9587b38.tar.gz scummvm-rg350-256158cbe225c2c8f2d663c7620d9d9ed9587b38.tar.bz2 scummvm-rg350-256158cbe225c2c8f2d663c7620d9d9ed9587b38.zip |
SHERLOCK: free midi music buffer
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sherlock/music.cpp | 23 | ||||
-rw-r--r-- | engines/sherlock/music.h | 3 |
2 files changed, 20 insertions, 6 deletions
diff --git a/engines/sherlock/music.cpp b/engines/sherlock/music.cpp index 346d087a1e..23ce07aa6f 100644 --- a/engines/sherlock/music.cpp +++ b/engines/sherlock/music.cpp @@ -198,6 +198,9 @@ Music::Music(SherlockEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { _musicPlaying = false; _musicOn = false; + _midiMusicData = NULL; + _midiMusicDataSize = 0; + if (_vm->getPlatform() == Common::kPlatform3DO) { // 3DO - uses digital samples for music _musicOn = true; @@ -274,6 +277,7 @@ Music::~Music() { _midiDriver->close(); delete _midiDriver; } + freeSong(); } bool Music::loadSong(int songNumber) { @@ -330,11 +334,10 @@ bool Music::playMusic(const Common::String &name) { Common::String midiMusicName = name + ".MUS"; Common::SeekableReadStream *stream = _vm->_res->load(midiMusicName, "MUSIC.LIB"); - byte *data = new byte[stream->size()]; - int32 dataSize = stream->size(); - assert(data); + _midiMusicData = new byte[stream->size()]; + _midiMusicDataSize = stream->size(); - stream->read(data, dataSize); + stream->read(_midiMusicData, _midiMusicDataSize); delete stream; // for dumping the music tracks @@ -346,12 +349,14 @@ bool Music::playMusic(const Common::String &name) { outFile.close(); #endif - if (dataSize < 14) { + if (_midiMusicDataSize < 14) { warning("Music: not enough data in music file"); return false; } - byte *dataPos = data; + byte *dataPos = _midiMusicData; + int32 dataSize = _midiMusicDataSize; + if (memcmp(" ", dataPos, 12)) { warning("Music: expected header not found in music file"); return false; @@ -435,6 +440,12 @@ void Music::startSong() { void Music::freeSong() { // TODO warning("TODO: Sound::freeSong"); + if (_midiMusicData) { + // free midi data buffer + delete[] _midiMusicData; + _midiMusicData = NULL; + _midiMusicDataSize = 0; + } } void Music::waitTimerRoland(uint time) { diff --git a/engines/sherlock/music.h b/engines/sherlock/music.h index f8cad3fd73..1e2b91a603 100644 --- a/engines/sherlock/music.h +++ b/engines/sherlock/music.h @@ -71,6 +71,9 @@ public: private: MusicType _musicType; + byte *_midiMusicData; + int32 _midiMusicDataSize; + public: /** * Saves sound-related settings |