aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/base-backend.cpp9
-rw-r--r--backends/base-backend.h5
-rw-r--r--backends/modular-backend.cpp11
-rw-r--r--backends/modular-backend.h8
-rw-r--r--backends/platform/android/android.cpp2
-rw-r--r--backends/platform/dc/dc.h3
-rw-r--r--backends/platform/dc/dcmain.cpp4
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp9
-rw-r--r--backends/platform/iphone/osys_main.cpp2
-rw-r--r--backends/platform/n64/osys_n64_base.cpp3
-rw-r--r--backends/platform/null/null.cpp3
-rw-r--r--backends/platform/ps2/systemps2.cpp43
-rw-r--r--backends/platform/psp/osys_psp.cpp2
-rw-r--r--backends/platform/sdl/sdl.cpp2
-rw-r--r--backends/platform/wii/osystem.cpp2
-rw-r--r--common/system.cpp14
-rw-r--r--common/system.h23
-rw-r--r--test/module.mk2
18 files changed, 82 insertions, 65 deletions
diff --git a/backends/base-backend.cpp b/backends/base-backend.cpp
index 40e702495a..ca46129aa6 100644
--- a/backends/base-backend.cpp
+++ b/backends/base-backend.cpp
@@ -25,7 +25,6 @@
#include "backends/base-backend.h"
#include "backends/events/default/default-events.h"
-#include "backends/audiocd/default/default-audiocd.h"
#include "gui/message.h"
void BaseBackend::displayMessageOnOSD(const char *msg) {
@@ -69,11 +68,9 @@ void BaseBackend::fillScreen(uint32 col) {
#endif
BaseBackend::BaseBackend() {
- _audiocdManager = 0;
}
BaseBackend::~BaseBackend() {
- delete _audiocdManager;
}
Common::SeekableReadStream *BaseBackend::createConfigReadStream() {
@@ -90,11 +87,5 @@ Common::WriteStream *BaseBackend::createConfigWriteStream() {
#endif
}
-AudioCDManager *BaseBackend::getAudioCDManager() {
- if (!_audiocdManager)
- _audiocdManager = new DefaultAudioCDManager();
- return _audiocdManager;
-}
-
void BaseBackend::resetGraphicsScale() {
}
diff --git a/backends/base-backend.h b/backends/base-backend.h
index 864c11544a..b6ac8c4ee6 100644
--- a/backends/base-backend.h
+++ b/backends/base-backend.h
@@ -38,12 +38,7 @@ public:
virtual Common::SeekableReadStream *createConfigReadStream();
virtual Common::WriteStream *createConfigWriteStream();
- virtual AudioCDManager *getAudioCDManager();
-
virtual void resetGraphicsScale();
-
-protected:
- AudioCDManager *_audiocdManager;
};
diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp
index a1c227b33f..d56c9479b9 100644
--- a/backends/modular-backend.cpp
+++ b/backends/modular-backend.cpp
@@ -25,7 +25,6 @@
#include "backends/modular-backend.h"
#include "backends/fs/fs-factory.h"
-#include "backends/audiocd/audiocd.h"
#include "backends/graphics/graphics.h"
#include "backends/mutex/mutex.h"
@@ -42,8 +41,7 @@ ModularBackend::ModularBackend()
_timerManager(0),
_mutexManager(0),
_graphicsManager(0),
- _mixer(0),
- _audiocdManager(0) {
+ _mixer(0) {
}
@@ -56,8 +54,6 @@ ModularBackend::~ModularBackend() {
_eventManager = 0;
delete _mixer;
_mixer = 0;
- delete _audiocdManager;
- _audiocdManager = 0;
delete _savefileManager;
_savefileManager = 0;
delete _timerManager;
@@ -257,11 +253,6 @@ Audio::Mixer *ModularBackend::getMixer() {
return (Audio::Mixer *)_mixer;
}
-AudioCDManager *ModularBackend::getAudioCDManager() {
- assert(_audiocdManager);
- return _audiocdManager;
-}
-
void ModularBackend::displayMessageOnOSD(const char *msg) {
_graphicsManager->displayMessageOnOSD(msg);
}
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index 74603e35a3..8dbfd1c8af 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -135,13 +135,6 @@ public:
//@}
- /** @name Audio CD */
- //@{
-
- virtual AudioCDManager *getAudioCDManager();
-
- //@}
-
/** @name Miscellaneous */
//@{
@@ -163,7 +156,6 @@ protected:
MutexManager *_mutexManager;
GraphicsManager *_graphicsManager;
Audio::Mixer *_mixer;
- AudioCDManager *_audiocdManager;
//@}
};
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index bb20184009..a67ee51b4d 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -388,6 +388,8 @@ void OSystem_Android::initBackend() {
warning("couldn't renice the main thread");
JNI::setReadyForEvents(true);
+
+ BaseBackend::initBackend();
}
void OSystem_Android::addPluginDirectories(Common::FSList &dirs) const {
diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h
index 0ae4e09afb..c7659e8292 100644
--- a/backends/platform/dc/dc.h
+++ b/backends/platform/dc/dc.h
@@ -161,8 +161,6 @@ public:
// Returns true if an event was retrieved.
bool pollEvent(Common::Event &event);
- AudioCDManager *getAudioCDManager() { return _cdManager; }
-
// Quit
void quit();
@@ -206,7 +204,6 @@ public:
Audio::MixerImpl *_mixer;
DefaultTimerManager *_timer;
SoftKeyboard _softkbd;
- DCCDManager *_cdManager;
int _ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_old_x, _ms_old_y;
int _ms_hotspot_x, _ms_hotspot_y, _ms_visible, _devpoll, _last_screen_refresh;
diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp
index 916dfb8229..8f7c989304 100644
--- a/backends/platform/dc/dcmain.cpp
+++ b/backends/platform/dc/dcmain.cpp
@@ -63,7 +63,9 @@ void OSystem_Dreamcast::initBackend()
_mixer = new Audio::MixerImpl(this, sampleRate);
_mixer->setReady(true);
- _cdManager = new DCCDManager();
+ _audiocdManager = new DCCDManager();
+
+ BaseBackend::initBackend();
}
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index db274b723f..e65402c604 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -41,6 +41,8 @@
#include "touchkeyboard.h"
#include "backends/fs/ds/ds-fs-factory.h"
+#include "backends/audiocd/default/default-audiocd.h"
+
#ifdef ENABLE_AGI
#include "wordcompletion.h"
#endif
@@ -118,7 +120,12 @@ void OSystem_DS::initBackend() {
_mixer = new Audio::MixerImpl(this, DS::getSoundFrequency());
_mixer->setReady(true);
- OSystem::initBackend();
+ /* TODO/FIXME: The NDS should use a custom AudioCD manager instance!
+ if (!_audiocdManager)
+ _audiocdManager = new DSAudioCDManager();
+ */
+
+ BaseBackend::initBackend();
}
bool OSystem_DS::hasFeature(Feature f) {
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index 12317ad935..75156b9544 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -101,7 +101,7 @@ void OSystem_IPHONE::initBackend() {
setTimerCallback(&OSystem_IPHONE::timerHandler, 10);
- OSystem::initBackend();
+ BaseBackend::initBackend();
}
bool OSystem_IPHONE::hasFeature(Feature f) {
diff --git a/backends/platform/n64/osys_n64_base.cpp b/backends/platform/n64/osys_n64_base.cpp
index facdc23d99..62fe145bcc 100644
--- a/backends/platform/n64/osys_n64_base.cpp
+++ b/backends/platform/n64/osys_n64_base.cpp
@@ -194,8 +194,7 @@ void OSystem_N64::initBackend() {
setupMixer();
- OSystem::initBackend();
-
+ BaseBackend::initBackend();
}
bool OSystem_N64::hasFeature(Feature f) {
diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index 7a0bb109f1..207453ad0d 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -78,7 +78,6 @@ void OSystem_NULL::initBackend() {
_eventManager = new DefaultEventManager(this);
_savefileManager = new DefaultSaveFileManager();
_graphicsManager = new NullGraphicsManager();
- _audiocdManager = new DefaultAudioCDManager();
_mixer = new Audio::MixerImpl(this, 22050);
((Audio::MixerImpl *)_mixer)->setReady(false);
@@ -87,7 +86,7 @@ void OSystem_NULL::initBackend() {
// this way; they need to be hooked into the system somehow to
// be functional. Of course, can't do that in a NULL backend :).
- OSystem::initBackend();
+ BaseBackend::initBackend();
}
bool OSystem_NULL::pollEvent(Common::Event &event) {
diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp
index 210454c9aa..aa1a9ade9f 100644
--- a/backends/platform/ps2/systemps2.cpp
+++ b/backends/platform/ps2/systemps2.cpp
@@ -33,36 +33,42 @@
#include <assert.h>
#include <iopcontrol.h>
#include <iopheap.h>
-#include "common/scummsys.h"
-#include "engines/engine.h"
-#include "backends/platform/ps2/systemps2.h"
-#include "backends/platform/ps2/Gs2dScreen.h"
-#include "backends/platform/ps2/ps2input.h"
-#include "backends/platform/ps2/irxboot.h"
+
#include <sjpcm.h>
#include <libhdd.h>
-#include "backends/platform/ps2/savefilemgr.h"
-#include "common/file.h"
-#include "backends/platform/ps2/sysdefs.h"
-#include "backends/platform/ps2/fileio.h"
#include <libmc.h>
#include <libpad.h>
-#include "backends/platform/ps2/cd.h"
#include <fileXio_rpc.h>
-#include "backends/platform/ps2/asyncfio.h"
#include "eecodyvdfs.h"
-#include "graphics/surface.h"
-#include "graphics/font.h"
-#include "backends/timer/default/default-timer.h"
-#include "audio/mixer_intern.h"
+
+#include "common/config-manager.h"
#include "common/events.h"
+#include "common/file.h"
+#include "common/scummsys.h"
+
+#include "backends/platform/ps2/asyncfio.h"
+#include "backends/platform/ps2/cd.h"
+#include "backends/platform/ps2/fileio.h"
+#include "backends/platform/ps2/Gs2dScreen.h"
+#include "backends/platform/ps2/irxboot.h"
#include "backends/platform/ps2/ps2debug.h"
-#include "backends/fs/ps2/ps2-fs-factory.h"
+#include "backends/platform/ps2/ps2input.h"
+#include "backends/platform/ps2/savefilemgr.h"
+#include "backends/platform/ps2/sysdefs.h"
+#include "backends/platform/ps2/systemps2.h"
+#include "backends/fs/ps2/ps2-fs-factory.h"
#include "backends/plugins/ps2/ps2-provider.h"
#include "backends/saves/default/default-saves.h"
-#include "common/config-manager.h"
+#include "backends/timer/default/default-timer.h"
+
+#include "audio/mixer_intern.h"
+
+#include "engines/engine.h"
+
+#include "graphics/font.h"
+#include "graphics/surface.h"
#include "icon.h"
#include "ps2temp.h"
@@ -345,6 +351,7 @@ void OSystem_PS2::init(void) {
_scummTimerManager = new DefaultTimerManager();
_scummMixer = new Audio::MixerImpl(this, 48000);
_scummMixer->setReady(true);
+
initTimer();
sioprintf("Starting SavefileManager\n");
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index eb629376d2..16688698e2 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -100,7 +100,7 @@ void OSystem_PSP::initBackend() {
setupMixer();
- OSystem::initBackend();
+ BaseBackend::initBackend();
}
// Let's us know an engine
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index a3fb719ca4..527520a7ea 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -206,6 +206,8 @@ void OSystem_SDL::initBackend() {
setupIcon();
_inited = true;
+
+ ModularBackend::initBackend();
}
void OSystem_SDL::initSDL() {
diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp
index d2938284a9..c16578d9b3 100644
--- a/backends/platform/wii/osystem.cpp
+++ b/backends/platform/wii/osystem.cpp
@@ -150,7 +150,7 @@ void OSystem_Wii::initBackend() {
initSfx();
initEvents();
- OSystem::initBackend();
+ BaseBackend::initBackend();
}
void OSystem_Wii::quit() {
diff --git a/common/system.cpp b/common/system.cpp
index 34fc076492..dcdc38c0db 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -26,6 +26,9 @@
#include "common/system.h"
#include "common/str.h"
+#include "common/textconsole.h"
+
+#include "backends/audiocd/default/default-audiocd.h"
#ifdef __PLAYSTATION2__
// for those replaced fopen/fread/etc functions
@@ -45,9 +48,20 @@
OSystem *g_system = 0;
OSystem::OSystem() {
+ _audiocdManager = 0;
}
OSystem::~OSystem() {
+ delete _audiocdManager;
+}
+
+void OSystem::initBackend() {
+#ifndef DISABLE_DEFAULT_AUDIOCD_MANAGER
+ if (!_audiocdManager)
+ _audiocdManager = new DefaultAudioCDManager();
+#endif
+ if (!_audiocdManager)
+ error("Backend failed to instantiate AudioCD manager");
}
bool OSystem::setGraphicsMode(const char *name) {
diff --git a/common/system.h b/common/system.h
index 243343ce0d..4b85f143b7 100644
--- a/common/system.h
+++ b/common/system.h
@@ -96,6 +96,23 @@ protected:
OSystem();
virtual ~OSystem();
+protected:
+ /**
+ * For backend authors only, this pointer may be set by OSystem
+ * subclasses to an AudioCDManager instance. This is only useful
+ * if your backend does not want to use the DefaultAudioCDManager.
+ *
+ * This instance is returned by OSystem::getAudioCDManager(),
+ * and it is deleted by the OSystem destructor.
+ *
+ * A backend may set this pointer in its initBackend() method,
+ * its constructor or somewhere in between; but it must
+ * set it no later than in its initBackend() implementation, because
+ * OSystem::initBackend() will by default create a DefaultAudioCDManager
+ * instance if _audiocdManager has not yet been set.
+ */
+ AudioCDManager *_audiocdManager;
+
public:
/**
@@ -106,7 +123,7 @@ public:
* parent class. They should do so near the end of their own
* implementation.
*/
- virtual void initBackend() { }
+ virtual void initBackend();
/**
* Allows the backend to perform engine specific init.
@@ -921,7 +938,9 @@ public:
* Return the audio cd manager. For more information, refer to the
* AudioCDManager documentation.
*/
- virtual AudioCDManager *getAudioCDManager() = 0;
+ inline AudioCDManager *getAudioCDManager() {
+ return _audiocdManager;
+ }
//@}
diff --git a/test/module.mk b/test/module.mk
index 4e5cbf62e1..bed2dff04f 100644
--- a/test/module.mk
+++ b/test/module.mk
@@ -6,7 +6,7 @@
######################################################################
TESTS := $(srcdir)/test/common/*.h $(srcdir)/test/audio/*.h
-TEST_LIBS := audio/libaudio.a common/libcommon.a
+TEST_LIBS := backends/libbackends.a audio/libaudio.a common/libcommon.a
#
TEST_FLAGS := --runner=StdioPrinter --no-std --no-eh