BACKENDS: Unify AudioCD manager instantiation

This commit is contained in:
Max Horn 2011-06-06 15:02:33 +02:00
parent 338a859591
commit afb06b51cc
18 changed files with 84 additions and 67 deletions

View File

@ -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() {
}

View File

@ -38,12 +38,7 @@ public:
virtual Common::SeekableReadStream *createConfigReadStream();
virtual Common::WriteStream *createConfigWriteStream();
virtual AudioCDManager *getAudioCDManager();
virtual void resetGraphicsScale();
protected:
AudioCDManager *_audiocdManager;
};

View File

@ -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);
}

View File

@ -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;
//@}
};

View File

@ -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 {

View File

@ -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;

View File

@ -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();
}

View File

@ -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) {

View File

@ -101,7 +101,7 @@ void OSystem_IPHONE::initBackend() {
setTimerCallback(&OSystem_IPHONE::timerHandler, 10);
OSystem::initBackend();
BaseBackend::initBackend();
}
bool OSystem_IPHONE::hasFeature(Feature f) {

View File

@ -194,8 +194,7 @@ void OSystem_N64::initBackend() {
setupMixer();
OSystem::initBackend();
BaseBackend::initBackend();
}
bool OSystem_N64::hasFeature(Feature f) {

View File

@ -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) {

View File

@ -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/events.h"
#include "backends/platform/ps2/ps2debug.h"
#include "backends/fs/ps2/ps2-fs-factory.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/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");

View File

@ -100,7 +100,7 @@ void OSystem_PSP::initBackend() {
setupMixer();
OSystem::initBackend();
BaseBackend::initBackend();
}
// Let's us know an engine

View File

@ -206,6 +206,8 @@ void OSystem_SDL::initBackend() {
setupIcon();
_inited = true;
ModularBackend::initBackend();
}
void OSystem_SDL::initSDL() {

View File

@ -150,7 +150,7 @@ void OSystem_Wii::initBackend() {
initSfx();
initEvents();
OSystem::initBackend();
BaseBackend::initBackend();
}
void OSystem_Wii::quit() {

View File

@ -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) {

View File

@ -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;
}
//@}

View File

@ -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