aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--base/main.cpp11
-rw-r--r--common/system.cpp14
-rw-r--r--common/system.h12
-rw-r--r--engines/engine.cpp19
-rw-r--r--engines/engine.h3
5 files changed, 48 insertions, 11 deletions
diff --git a/base/main.cpp b/base/main.cpp
index ced240973f..6c97e4243b 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -44,6 +44,7 @@
#include "gui/newgui.h"
#include "gui/message.h"
#include "sound/mididrv.h"
+#include "sound/mixer.h"
#if defined(_WIN32_WCE)
#include "backends/platform/wince/CELauncherDialog.h"
@@ -225,6 +226,11 @@ static int runGame(const Plugin *plugin, OSystem &system, const Common::String &
return result;
}
+
+// FIXME: Temporary hack, to be removed soon
+Audio::Mixer *g_mixer = 0;
+
+
extern "C" int scummvm_main(int argc, char *argv[]) {
Common::String specialDebug;
Common::String command;
@@ -284,6 +290,8 @@ extern "C" int scummvm_main(int argc, char *argv[]) {
// Create the timer services
Common::g_timer = new DefaultTimerManager(&system);
+
+ g_mixer = new Audio::Mixer();
// Set initial window caption
system.setWindowCaption(gScummVMFullVersion);
@@ -328,6 +336,9 @@ extern "C" int scummvm_main(int argc, char *argv[]) {
launcherDialog(system);
}
+ // Deinit the mixer
+ delete g_mixer;
+
// Deinit the timer
delete Common::g_timer;
diff --git a/common/system.cpp b/common/system.cpp
index 614dff6199..d15f026df0 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -31,6 +31,7 @@
#include "common/config-manager.h"
#include "common/system.h"
+#include "common/timer.h"
#include "common/util.h"
OSystem *g_system = 0;
@@ -63,9 +64,22 @@ void OSystem::displayMessageOnOSD(const char *msg) {
}
Common::SaveFileManager *OSystem::getSavefileManager() {
+ // TODO: Change this to always return the same
+ // instance, instead of a new one each time around...
return new DefaultSaveFileManager();
}
+Audio::Mixer *OSystem::getMixer() {
+ // FIXME
+ extern Audio::Mixer *g_mixer;
+ return g_mixer;
+}
+
+Common::TimerManager *OSystem::getTimerManager() {
+ // FIXME
+ return Common::g_timer;
+}
+
bool OSystem::openCD(int drive) {
return false;
diff --git a/common/system.h b/common/system.h
index 9508520cc1..1682426ab0 100644
--- a/common/system.h
+++ b/common/system.h
@@ -28,12 +28,17 @@
#include "common/mutex.h"
#include "common/rect.h"
+namespace Audio {
+ class Mixer;
+}
+
namespace Graphics {
struct Surface;
}
namespace Common {
class SaveFileManager;
+ class TimerManager;
}
/**
@@ -970,6 +975,13 @@ public:
/** Savefile management. */
virtual Common::SaveFileManager *getSavefileManager();
+
+ /** TODO */
+ virtual Audio::Mixer *getMixer();
+
+ /** TODO */
+ virtual Common::TimerManager *getTimerManager();
+
//@}
};
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 0790c19a1b..c2b01ac715 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -26,32 +26,31 @@
#include "common/timer.h"
#include "common/savefile.h"
#include "common/system.h"
-#include "sound/mixer.h"
#include "gui/message.h"
+#include "sound/mixer.h"
#ifdef _WIN32_WCE
extern bool isSmartphone(void);
#endif
-/* FIXME - BIG HACK for MidiEmu */
+// FIXME - BIG HACK for MidiEmu & error()
Engine *g_engine = 0;
+
Engine::Engine(OSystem *syst)
: _system(syst),
+ _mixer(_system->getMixer()),
+ _timer(_system->getTimerManager()),
+ _saveFileMan(_system->getSavefileManager()),
_gameDataPath(ConfMan.get("path")),
- _targetName(ConfMan.getActiveDomainName()){
- g_engine = this;
- _mixer = new Audio::Mixer();
-
- _timer = Common::g_timer;
-
- _saveFileMan = _system->getSavefileManager();
+ _targetName(ConfMan.getActiveDomainName()) {
+ g_engine = this;
_autosavePeriod = ConfMan.getInt("autosave_period");
}
Engine::~Engine() {
- delete _mixer;
+ _mixer->stopAll(true);
delete _saveFileMan;
g_engine = NULL;
diff --git a/engines/engine.h b/engines/engine.h
index 85798c219b..62da2cc3ff 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -45,9 +45,10 @@ public:
Common::TimerManager * _timer;
protected:
+ Common::SaveFileManager *_saveFileMan;
+
const Common::String _targetName; // target name for saves
const Common::String _gameDataPath;
- Common::SaveFileManager *_saveFileMan;
private:
int _autosavePeriod;