[Scummvm-cvs-logs] scummvm master -> afb06b51cceb96cf3ac2baae1f562c673114d108

fingolfin max at quendi.de
Mon Jun 6 15:15:23 CEST 2011


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
338a859591 NULL: cleanup
afb06b51cc BACKENDS: Unify AudioCD manager instantiation


Commit: 338a859591c676eab46b1fc3523bc85bce8c15e2
    https://github.com/scummvm/scummvm/commit/338a859591c676eab46b1fc3523bc85bce8c15e2
Author: Max Horn (max at quendi.de)
Date: 2011-06-06T05:13:18-07:00

Commit Message:
NULL: cleanup

Changed paths:
    backends/platform/null/null.cpp



diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index b9e901b..7a0bb10 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -73,12 +73,12 @@ OSystem_NULL::~OSystem_NULL() {
 }
 
 void OSystem_NULL::initBackend() {
-	_mutexManager = (MutexManager *)new NullMutexManager();
+	_mutexManager = new NullMutexManager();
 	_timerManager = new DefaultTimerManager();
 	_eventManager = new DefaultEventManager(this);
 	_savefileManager = new DefaultSaveFileManager();
-	_graphicsManager = (GraphicsManager *)new NullGraphicsManager();
-	_audiocdManager = (AudioCDManager *)new DefaultAudioCDManager();
+	_graphicsManager = new NullGraphicsManager();
+	_audiocdManager = new DefaultAudioCDManager();
 	_mixer = new Audio::MixerImpl(this, 22050);
 
 	((Audio::MixerImpl *)_mixer)->setReady(false);


Commit: afb06b51cceb96cf3ac2baae1f562c673114d108
    https://github.com/scummvm/scummvm/commit/afb06b51cceb96cf3ac2baae1f562c673114d108
Author: Max Horn (max at quendi.de)
Date: 2011-06-06T06:02:33-07:00

Commit Message:
BACKENDS: Unify AudioCD manager instantiation

Changed paths:
    backends/base-backend.cpp
    backends/base-backend.h
    backends/modular-backend.cpp
    backends/modular-backend.h
    backends/platform/android/android.cpp
    backends/platform/dc/dc.h
    backends/platform/dc/dcmain.cpp
    backends/platform/ds/arm9/source/osystem_ds.cpp
    backends/platform/iphone/osys_main.cpp
    backends/platform/n64/osys_n64_base.cpp
    backends/platform/null/null.cpp
    backends/platform/ps2/systemps2.cpp
    backends/platform/psp/osys_psp.cpp
    backends/platform/sdl/sdl.cpp
    backends/platform/wii/osystem.cpp
    common/system.cpp
    common/system.h
    test/module.mk



diff --git a/backends/base-backend.cpp b/backends/base-backend.cpp
index 40e7024..ca46129 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 864c115..b6ac8c4 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 a1c227b..d56c947 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 74603e3..8dbfd1c 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 bb20184..a67ee51 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 0ae4e09..c7659e8 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 916dfb8..8f7c989 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 db274b7..e65402c 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 12317ad..75156b9 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 facdc23..62fe145 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 7a0bb10..207453a 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 210454c..aa1a9ad 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 eb62937..1668869 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 a3fb719..527520a 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 d293828..c16578d 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 34fc076..dcdc38c 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 243343c..4b85f14 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 4e5cbf6..bed2dff 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






More information about the Scummvm-git-logs mailing list