aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/system.cpp14
-rw-r--r--common/system.h23
2 files changed, 35 insertions, 2 deletions
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;
+ }
//@}