From 044bcd5430a9ba1b19e10d4d4e3a193358166991 Mon Sep 17 00:00:00 2001 From: Jamieson Christian Date: Sun, 28 Sep 2003 00:03:24 +0000 Subject: [PATCH] Added terminate() to the MusicEngine and publicized the iMuse implementation. This allows the termination sequence to be done BEFORE object destruction, so that the destructor is not making calls that may not be appropriate during object destruction. (Virtual functions were the concern, although I'm not sure any of that was happening anyway. Oh well, better to be safe than sorry.) I implemented an empty terminate() in the base class, but the other MusicEngine derivatives may have stuff in their destructors that should be moved to this method. I didn't check. svn-id: r10452 --- scumm/imuse.cpp | 5 +---- scumm/imuse.h | 1 + scumm/imuse_internal.h | 1 - scumm/music.h | 1 + scumm/scummvm.cpp | 5 ++++- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp index 30ca18ba981..9076cec2d4f 100644 --- a/scumm/imuse.cpp +++ b/scumm/imuse.cpp @@ -69,10 +69,6 @@ _snm_trigger_index(0) memset(_active_notes,0,sizeof(_active_notes)); } -IMuseInternal::~IMuseInternal() { - terminate(); -} - byte *IMuseInternal::findStartOfSound(int sound) { byte *ptr = NULL; int32 size, pos; @@ -1783,6 +1779,7 @@ int32 IMuse::doCommand (int numargs, int args[]) { in(); int32 ret = _target->do int IMuse::clear_queue() { in(); int ret = _target->clear_queue(); out(); return ret; } void IMuse::setBase(byte **base) { in(); _target->setBase(base); out(); } uint32 IMuse::property(int prop, uint32 value) { in(); uint32 ret = _target->property(prop, value); out(); return ret; } +void IMuse::terminate() { in(); _target->terminate(); out(); } // The IMuse::create method provides a front-end factory // for creating IMuseInternal without exposing that class diff --git a/scumm/imuse.h b/scumm/imuse.h index 3337f08b5e2..62012de460a 100644 --- a/scumm/imuse.h +++ b/scumm/imuse.h @@ -74,6 +74,7 @@ public: int clear_queue(); void setBase(byte **base); uint32 property(int prop, uint32 value); + void terminate(); // Factory methods static IMuse *create(OSystem *syst, SoundMixer *mixer, MidiDriver *midi); diff --git a/scumm/imuse_internal.h b/scumm/imuse_internal.h index 6363fa4c3d5..0bc88e7a5eb 100644 --- a/scumm/imuse_internal.h +++ b/scumm/imuse_internal.h @@ -440,7 +440,6 @@ protected: public: IMuseInternal(); - ~IMuseInternal(); int initialize(OSystem *syst, SoundMixer *mixer, MidiDriver *midi); void reallocateMidiChannels(MidiDriver *midi); diff --git a/scumm/music.h b/scumm/music.h index ff08d18e89f..c3b730d7a00 100644 --- a/scumm/music.h +++ b/scumm/music.h @@ -37,6 +37,7 @@ public: virtual void stopAllSounds() = 0; virtual int getSoundStatus(int sound) const = 0; // virtual int getMusicTimer() const = 0; + virtual void terminate() {} }; #endif diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index fcdad80ae99..410458be5c8 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -824,7 +824,10 @@ Scumm::~Scumm () { delete _confirmExitDialog; delete _sound; - delete _musicEngine; + if (_musicEngine) { + _musicEngine->terminate(); + delete _musicEngine; + } free(_languageBuffer); free(_audioNames);