diff options
author | Torbjörn Andersson | 2004-05-31 08:46:36 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2004-05-31 08:46:36 +0000 |
commit | cddf02fc3253668174707dad515a8152f1c47460 (patch) | |
tree | 938b5d69b553011e8a3a7632d5d7c900d960f0f9 /saga | |
parent | f3014b9f4cbaf036271ea9ec9fa2b8010a38e723 (diff) | |
download | scummvm-rg350-cddf02fc3253668174707dad515a8152f1c47460.tar.gz scummvm-rg350-cddf02fc3253668174707dad515a8152f1c47460.tar.bz2 scummvm-rg350-cddf02fc3253668174707dad515a8152f1c47460.zip |
Make sure music is unloaded and the parser object deleted before starting a
new piece of music.
svn-id: r13909
Diffstat (limited to 'saga')
-rw-r--r-- | saga/music.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/saga/music.cpp b/saga/music.cpp index bb45607ffb..cb97dbb687 100644 --- a/saga/music.cpp +++ b/saga/music.cpp @@ -48,14 +48,14 @@ static const byte mt32_to_gm[128] = { 47, 117, 127, 118, 118, 116, 115, 119, 115, 112, 55, 124, 123, 0, 14, 117 // 7x }; -MusicPlayer::MusicPlayer(MidiDriver *driver) : _driver(driver), _looping(false), _isPlaying(false) { +MusicPlayer::MusicPlayer(MidiDriver *driver) : _parser(0), _driver(driver), _looping(false), _isPlaying(false) { memset(_channel, 0, sizeof(_channel)); this->open(); } MusicPlayer::~MusicPlayer() { _driver->setTimerCallback(NULL, NULL); - _parser->unloadMusic(); + stopMusic(); this->close(); } @@ -145,7 +145,10 @@ void MusicPlayer::playMusic() { void MusicPlayer::stopMusic() { _isPlaying = false; - _parser->unloadMusic(); + if (_parser) { + _parser->unloadMusic(); + delete _parser; + } } Music::Music(MidiDriver *driver, int enabled) : _enabled(enabled) { @@ -216,6 +219,8 @@ int Music::play(uint32 music_rn, uint16 flags) { } } + _player->stopMusic(); + // FIXME: Is resource_data ever freed? if (f_midi.isOpen()) { |