BACKENDS: Move implementation of getMixer() out of ModularBackend

This commit is contained in:
Cameron Cawley 2020-08-01 22:51:35 +01:00 committed by Eugene Sandulenko
parent b76652120b
commit 6c22f92301
3 changed files with 16 additions and 21 deletions

View File

@ -26,23 +26,19 @@
#include "backends/mutex/mutex.h"
#include "gui/EventRecorder.h"
#include "audio/mixer.h"
#include "common/timer.h"
#include "graphics/pixelformat.h"
ModularBackend::ModularBackend()
:
_mutexManager(0),
_graphicsManager(0),
_mixer(0) {
_graphicsManager(0) {
}
ModularBackend::~ModularBackend() {
delete _graphicsManager;
_graphicsManager = 0;
delete _mixer;
_mixer = 0;
// _timerManager needs to be deleted before _mutexManager to avoid a crash.
delete _timerManager;
_timerManager = 0;
@ -271,11 +267,6 @@ void ModularBackend::deleteMutex(MutexRef mutex) {
_mutexManager->deleteMutex(mutex);
}
Audio::Mixer *ModularBackend::getMixer() {
assert(_mixer);
return (Audio::Mixer *)_mixer;
}
void ModularBackend::displayMessageOnOSD(const char *msg) {
_graphicsManager->displayMessageOnOSD(msg);
}

View File

@ -40,6 +40,7 @@ class MutexManager;
* OSystem::getMillis()
* OSystem::delayMillis()
* OSystem::getTimeAndDate()
* OSystem::getMixer()
* OSystem::quit()
*
* And, it should also initialize all the managers variables
@ -125,13 +126,6 @@ public:
//@}
/** @name Sound */
//@{
virtual Audio::Mixer *getMixer() override;
//@}
/** @name Miscellaneous */
//@{
@ -146,7 +140,6 @@ protected:
MutexManager *_mutexManager;
GraphicsManager *_graphicsManager;
Audio::Mixer *_mixer;
//@}
};

View File

@ -79,17 +79,21 @@ public:
virtual void delayMillis(uint msecs);
virtual void getTimeAndDate(TimeDate &t) const;
virtual Audio::Mixer *getMixer();
virtual void quit();
virtual void logMessage(LogMessageType::Type type, const char *message);
#ifdef POSIX
private:
Audio::MixerImpl *_mixer;
#ifdef POSIX
timeval _startTime;
#endif
};
OSystem_NULL::OSystem_NULL() {
OSystem_NULL::OSystem_NULL() : _mixer(0) {
#if defined(__amigaos4__)
_fsFactory = new AmigaOSFilesystemFactory();
#elif defined(__MORPHOS__)
@ -106,6 +110,8 @@ OSystem_NULL::OSystem_NULL() {
}
OSystem_NULL::~OSystem_NULL() {
delete _mixer;
_mixer = 0;
}
#ifdef POSIX
@ -133,7 +139,7 @@ void OSystem_NULL::initBackend() {
_graphicsManager = new NullGraphicsManager();
_mixer = new Audio::MixerImpl(22050);
((Audio::MixerImpl *)_mixer)->setReady(false);
_mixer->setReady(false);
// Note that the mixer is useless this way; it needs to be hooked
// into the system somehow to be functional. Of course, can't do
@ -197,6 +203,11 @@ void OSystem_NULL::getTimeAndDate(TimeDate &td) const {
td.tm_wday = t.tm_wday;
}
Audio::Mixer *OSystem_NULL::getMixer() {
assert(_mixer);
return (Audio::Mixer *)_mixer;
}
void OSystem_NULL::quit() {
exit(0);
}