aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--base/main.cpp12
-rw-r--r--sound/audiocd.h8
2 files changed, 20 insertions, 0 deletions
diff --git a/base/main.cpp b/base/main.cpp
index d108512416..f9ebe7ae56 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -45,9 +45,12 @@
#include "common/file.h"
#include "common/fs.h"
#include "common/system.h"
+
#include "gui/GuiManager.h"
#include "gui/message.h"
+#include "sound/audiocd.h"
+
#include "backends/keymapper/keymapper.h"
#if defined(_WIN32_WCE)
@@ -416,6 +419,15 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
warning("Could not find any engine capable of running the selected game");
}
+ // We will destory the AudioCDManager singleton here to save some memory.
+ // This will not make the CD audio stop, one would have to enable this:
+ //AudioCD.stop();
+ // but the engine is responsible for stopping CD playback anyway and
+ // this way we catch engines not doing it properly. For some more
+ // information about why AudioCDManager::destroy does not stop the CD
+ // playback read the FIXME in sound/audiocd.h
+ Audio::AudioCDManager::destroy();
+
// reset the graphics to default
setupGraphics(system);
launcherDialog();
diff --git a/sound/audiocd.h b/sound/audiocd.h
index 4c4ff26147..2dc379ca27 100644
--- a/sound/audiocd.h
+++ b/sound/audiocd.h
@@ -67,6 +67,14 @@ private:
friend class Common::Singleton<SingletonBaseType>;
AudioCDManager();
+ // FIXME: It might make sense to stop CD playback, when the AudioCDManager singleton
+ // is destroyed. Currently we can not do this, since in worst case the OSystem and
+ // along wiht it the Mixer will be destroyed before the AudioCDManager, thus
+ // leading to invalid memory access. If we can fix up the code to destroy the
+ // AudioCDManager before OSystem in *all* cases, that is including calling
+ // OSystem::quit, we might be able to implement it via a simple "stop()"
+ // call in a custom destructor of AudioCDManager.
+
/* used for emulated CD music */
SoundHandle _handle;
bool _emulating;