[Scummvm-git-logs] scummvm master -> e16844b6e9c9c7c08be0f4291ffed4c106a40a3c
sev-
sev at scummvm.org
Mon Aug 24 12:22:43 UTC 2020
This automated email contains information about 9 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
6c22f92301 BACKENDS: Move implementation of getMixer() out of ModularBackend
ee11bc20b2 MAEMO: Remove some debug code
9a61a99590 BACKENDS: Add init() to OSystem
75852a786a BACKENDS: Split ModularBackend into two separate classes
7745ffdac1 BACKENDS: Simplify EventsBaseBackend
697d1a8672 BACKENDS: Added an abstract MixerManager class
d1bfa2c4ec BACKENDS: Modify the null mixer manager to not require SDL
b9d2b87085 BACKENDS: Move MixerManager code into ModularMixerBackend
e16844b6e9 NULL: Make use of NullMixerManager
Commit: 6c22f92301ca751cca3c4c3e3d69ecff28e5c5f6
https://github.com/scummvm/scummvm/commit/6c22f92301ca751cca3c4c3e3d69ecff28e5c5f6
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-08-24T14:22:35+02:00
Commit Message:
BACKENDS: Move implementation of getMixer() out of ModularBackend
Changed paths:
backends/modular-backend.cpp
backends/modular-backend.h
backends/platform/null/null.cpp
diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp
index 5073ceae7e..1fd3428c20 100644
--- a/backends/modular-backend.cpp
+++ b/backends/modular-backend.cpp
@@ -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);
}
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index ca4356de52..e57dbf174f 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -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;
//@}
};
diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index 2da3266e99..636ad5004b 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -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);
}
Commit: ee11bc20b29b3578ccd7f1723c9942a313a92286
https://github.com/scummvm/scummvm/commit/ee11bc20b29b3578ccd7f1723c9942a313a92286
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-08-24T14:22:35+02:00
Commit Message:
MAEMO: Remove some debug code
Changed paths:
backends/events/maemosdl/maemosdl-events.cpp
diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp
index 7f0419add6..5fce11d9f1 100644
--- a/backends/events/maemosdl/maemosdl-events.cpp
+++ b/backends/events/maemosdl/maemosdl-events.cpp
@@ -51,9 +51,6 @@ static const KeymapEntry keymapEntries[] = {
bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
- Model model = Model(((OSystem_SDL_Maemo *)g_system)->getModel());
- debug(10, "Model: %s %u %s %s", model.hwId, model.modelType, model.hwAlias, model.hasHwKeyboard ? "true" : "false");
-
// List of special N810 keys:
// SDLK_F4 -> menu
// SDLK_F5 -> home
Commit: 9a61a995908cba3c1d0edc256d258583845bc7c6
https://github.com/scummvm/scummvm/commit/9a61a995908cba3c1d0edc256d258583845bc7c6
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-08-24T14:22:35+02:00
Commit Message:
BACKENDS: Add init() to OSystem
Changed paths:
backends/platform/androidsdl/androidsdl-main.cpp
backends/platform/dingux/main.cpp
backends/platform/gph/gph-main.cpp
backends/platform/maemo/main.cpp
backends/platform/openpandora/op-main.cpp
backends/platform/samsungtv/main.cpp
backends/platform/sdl/amigaos/amigaos-main.cpp
backends/platform/sdl/macosx/macosx-main.cpp
backends/platform/sdl/posix/posix-main.cpp
backends/platform/sdl/ps3/ps3-main.cpp
backends/platform/sdl/psp2/psp2-main.cpp
backends/platform/sdl/riscos/riscos-main.cpp
backends/platform/sdl/sdl.h
backends/platform/sdl/switch/switch-main.cpp
backends/platform/sdl/win32/win32-main.cpp
backends/platform/symbian/src/SymbianMain.cpp
common/system.h
diff --git a/backends/platform/androidsdl/androidsdl-main.cpp b/backends/platform/androidsdl/androidsdl-main.cpp
index 304bce11a9..64f45cdbc0 100644
--- a/backends/platform/androidsdl/androidsdl-main.cpp
+++ b/backends/platform/androidsdl/androidsdl-main.cpp
@@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
assert(g_system);
// Pre initialize the backend
- ((OSystem_POSIX *)g_system)->init();
+ g_system->init();
// Invoke the actual ScummVM main entry point:
int res = scummvm_main(argc, argv);
diff --git a/backends/platform/dingux/main.cpp b/backends/platform/dingux/main.cpp
index 7ec90ab1ed..12f82cc867 100644
--- a/backends/platform/dingux/main.cpp
+++ b/backends/platform/dingux/main.cpp
@@ -32,7 +32,7 @@ int main(int argc, char* argv[]) {
g_system = new OSystem_SDL_Dingux();
assert(g_system);
- ((OSystem_SDL_Dingux *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/gph/gph-main.cpp b/backends/platform/gph/gph-main.cpp
index 3b829de0db..8267470107 100644
--- a/backends/platform/gph/gph-main.cpp
+++ b/backends/platform/gph/gph-main.cpp
@@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
assert(g_system);
// Pre initialize the backend
- ((OSystem_GPH *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/maemo/main.cpp b/backends/platform/maemo/main.cpp
index 72253bb32c..901e31c544 100644
--- a/backends/platform/maemo/main.cpp
+++ b/backends/platform/maemo/main.cpp
@@ -30,7 +30,7 @@ int main(int argc, char* argv[]) {
g_system = new Maemo::OSystem_SDL_Maemo();
assert(g_system);
- ((Maemo::OSystem_SDL_Maemo *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/openpandora/op-main.cpp b/backends/platform/openpandora/op-main.cpp
index 09da93a942..2365bafef6 100644
--- a/backends/platform/openpandora/op-main.cpp
+++ b/backends/platform/openpandora/op-main.cpp
@@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
assert(g_system);
// Pre initialize the backend
- ((OSystem_OP *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/samsungtv/main.cpp b/backends/platform/samsungtv/main.cpp
index 7db2d90980..35a9dec8f5 100644
--- a/backends/platform/samsungtv/main.cpp
+++ b/backends/platform/samsungtv/main.cpp
@@ -40,7 +40,7 @@ extern "C" int Game_Main(char *path, char *) {
assert(g_system);
// Pre initialize the backend
- ((OSystem_POSIX *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/sdl/amigaos/amigaos-main.cpp b/backends/platform/sdl/amigaos/amigaos-main.cpp
index 9149085183..e63f40091d 100644
--- a/backends/platform/sdl/amigaos/amigaos-main.cpp
+++ b/backends/platform/sdl/amigaos/amigaos-main.cpp
@@ -69,7 +69,7 @@ int main(int argc, char *argv[]) {
assert(g_system);
// Pre-initialize the backend.
- ((OSystem_AmigaOS *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/sdl/macosx/macosx-main.cpp b/backends/platform/sdl/macosx/macosx-main.cpp
index 3053d30e55..2f16b8cd6f 100644
--- a/backends/platform/sdl/macosx/macosx-main.cpp
+++ b/backends/platform/sdl/macosx/macosx-main.cpp
@@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
assert(g_system);
// Pre initialize the backend
- ((OSystem_MacOSX *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/sdl/posix/posix-main.cpp b/backends/platform/sdl/posix/posix-main.cpp
index 92e4acae15..f42d244b62 100644
--- a/backends/platform/sdl/posix/posix-main.cpp
+++ b/backends/platform/sdl/posix/posix-main.cpp
@@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
assert(g_system);
// Pre initialize the backend
- ((OSystem_POSIX *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/sdl/ps3/ps3-main.cpp b/backends/platform/sdl/ps3/ps3-main.cpp
index 23dc740202..2a7c61dc57 100644
--- a/backends/platform/sdl/ps3/ps3-main.cpp
+++ b/backends/platform/sdl/ps3/ps3-main.cpp
@@ -40,7 +40,7 @@ int main(int argc, char *argv[]) {
assert(g_system);
// Pre initialize the backend
- ((OSystem_PS3 *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/sdl/psp2/psp2-main.cpp b/backends/platform/sdl/psp2/psp2-main.cpp
index aca14832ae..8f90d9fcda 100644
--- a/backends/platform/sdl/psp2/psp2-main.cpp
+++ b/backends/platform/sdl/psp2/psp2-main.cpp
@@ -46,7 +46,7 @@ int main(int argc, char *argv[]) {
assert(g_system);
// Pre initialize the backend
- ((OSystem_PSP2 *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/sdl/riscos/riscos-main.cpp b/backends/platform/sdl/riscos/riscos-main.cpp
index c075c2d097..76372df625 100644
--- a/backends/platform/sdl/riscos/riscos-main.cpp
+++ b/backends/platform/sdl/riscos/riscos-main.cpp
@@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
assert(g_system);
// Pre initialize the backend
- ((OSystem_RISCOS *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 4397aab051..31cfd0b913 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -46,7 +46,7 @@ public:
* instantiating the backend. Early needed managers are
* created here.
*/
- virtual void init();
+ virtual void init() override;
/**
* Get the Mixer Manager instance. Not to confuse with getMixer(),
diff --git a/backends/platform/sdl/switch/switch-main.cpp b/backends/platform/sdl/switch/switch-main.cpp
index 71d80c144d..c24bd94579 100644
--- a/backends/platform/sdl/switch/switch-main.cpp
+++ b/backends/platform/sdl/switch/switch-main.cpp
@@ -39,7 +39,7 @@ int main(int argc, char *argv[]) {
assert(g_system);
// Pre initialize the backend
- ((OSystem_Switch *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/sdl/win32/win32-main.cpp b/backends/platform/sdl/win32/win32-main.cpp
index 0a7c1dd8e2..aa234efc8d 100644
--- a/backends/platform/sdl/win32/win32-main.cpp
+++ b/backends/platform/sdl/win32/win32-main.cpp
@@ -61,7 +61,7 @@ int main(int argc, char *argv[]) {
assert(g_system);
// Pre initialize the backend
- ((OSystem_Win32 *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/backends/platform/symbian/src/SymbianMain.cpp b/backends/platform/symbian/src/SymbianMain.cpp
index 03cf407138..f6350abf0b 100644
--- a/backends/platform/symbian/src/SymbianMain.cpp
+++ b/backends/platform/symbian/src/SymbianMain.cpp
@@ -79,7 +79,7 @@ int main(int argc, char *argv[]) {
assert(g_system);
// Pre initialize the backend
- ((OSystem_SDL_Symbian *)g_system)->init();
+ g_system->init();
#ifdef DYNAMIC_MODULES
PluginManager::instance().addPluginProvider(new SDLPluginProvider());
diff --git a/common/system.h b/common/system.h
index 542c4b15ca..32838c001d 100644
--- a/common/system.h
+++ b/common/system.h
@@ -243,6 +243,11 @@ public:
*/
void destroy();
+ /**
+ * The following method should be called once, after g_system is created.
+ */
+ virtual void init() {}
+
/**
* The following method is called once, from main.cpp, after all
* config data (including command line params etc.) are fully loaded.
Commit: 75852a786af88ddc4e150cdce761481ab8df3024
https://github.com/scummvm/scummvm/commit/75852a786af88ddc4e150cdce761481ab8df3024
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-08-24T14:22:35+02:00
Commit Message:
BACKENDS: Split ModularBackend into two separate classes
Changed paths:
backends/events/sdl/sdl-events.cpp
backends/fs/symbian/symbian-fs.cpp
backends/fs/symbian/symbianstream.cpp
backends/modular-backend.cpp
backends/modular-backend.h
backends/platform/android/android.cpp
backends/platform/android/android.h
backends/platform/null/null.cpp
backends/platform/sdl/sdl.cpp
backends/platform/sdl/sdl.h
backends/platform/symbian/src/SymbianOS.cpp
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
index fe1a497d24..abbe3374d1 100644
--- a/backends/events/sdl/sdl-events.cpp
+++ b/backends/events/sdl/sdl-events.cpp
@@ -426,7 +426,7 @@ bool SdlEventSource::pollEvent(Common::Event &event) {
#endif
// If the screen changed, send an Common::EVENT_SCREEN_CHANGED
- int screenID = ((OSystem_SDL *)g_system)->getGraphicsManager()->getScreenChangeID();
+ int screenID = g_system->getScreenChangeID();
if (screenID != _lastScreenID) {
_lastScreenID = screenID;
event.type = Common::EVENT_SCREEN_CHANGED;
@@ -963,7 +963,7 @@ bool SdlEventSource::handleResizeEvent(Common::Event &event, int w, int h) {
_graphicsManager->notifyResize(w, h);
// If the screen changed, send an Common::EVENT_SCREEN_CHANGED
- int screenID = ((OSystem_SDL *)g_system)->getGraphicsManager()->getScreenChangeID();
+ int screenID = g_system->getScreenChangeID();
if (screenID != _lastScreenID) {
_lastScreenID = screenID;
event.type = Common::EVENT_SCREEN_CHANGED;
diff --git a/backends/fs/symbian/symbian-fs.cpp b/backends/fs/symbian/symbian-fs.cpp
index 96fa84aa95..243a8eae57 100644
--- a/backends/fs/symbian/symbian-fs.cpp
+++ b/backends/fs/symbian/symbian-fs.cpp
@@ -71,7 +71,7 @@ SymbianFilesystemNode::SymbianFilesystemNode(const Common::String &path) {
TPtrC8 ptr((const unsigned char*)_path.c_str(),_path.size());
fname.Copy(ptr);
- if (static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession().Entry(fname, fileAttribs) == KErrNone) {
+ if (dynamic_cast<OSystem_SDL_Symbian *>(g_system)->FsSession().Entry(fname, fileAttribs) == KErrNone) {
_isValid = true;
_isDirectory = fileAttribs.IsDir();
} else {
@@ -88,7 +88,7 @@ bool SymbianFilesystemNode::exists() const {
TFileName fname;
TPtrC8 ptr((const unsigned char*) _path.c_str(), _path.size());
fname.Copy(ptr);
- bool fileExists = BaflUtils::FileExists(static_cast<OSystem_SDL_Symbian *> (g_system)->FsSession(), fname);
+ bool fileExists = BaflUtils::FileExists(dynamic_cast<OSystem_SDL_Symbian *> (g_system)->FsSession(), fname);
if (!fileExists) {
TParsePtrC parser(fname);
if (parser.PathPresent() && parser.Path().Compare(_L("\\")) == KErrNone && !parser.NameOrExtPresent()) {
diff --git a/backends/fs/symbian/symbianstream.cpp b/backends/fs/symbian/symbianstream.cpp
index 549bc54452..2cc21bfb2f 100644
--- a/backends/fs/symbian/symbianstream.cpp
+++ b/backends/fs/symbian/symbianstream.cpp
@@ -70,22 +70,22 @@ TSymbianFileEntry* CreateSymbianFileEntry(const char* name, const char* mode) {
switch (mode[0]) {
case 'a':
- if (fileEntry->_fileHandle.Open(static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) {
- if (fileEntry->_fileHandle.Create(static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) {
+ if (fileEntry->_fileHandle.Open(dynamic_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) {
+ if (fileEntry->_fileHandle.Create(dynamic_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) {
delete fileEntry;
fileEntry = NULL;
}
}
break;
case 'r':
- if (fileEntry->_fileHandle.Open(static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) {
+ if (fileEntry->_fileHandle.Open(dynamic_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) {
delete fileEntry;
fileEntry = NULL;
}
break;
case 'w':
- if (fileEntry->_fileHandle.Replace(static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) {
+ if (fileEntry->_fileHandle.Replace(dynamic_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) {
delete fileEntry;
fileEntry = NULL;
}
diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp
index 1fd3428c20..75ac7be1a2 100644
--- a/backends/modular-backend.cpp
+++ b/backends/modular-backend.cpp
@@ -29,153 +29,147 @@
#include "common/timer.h"
#include "graphics/pixelformat.h"
-ModularBackend::ModularBackend()
+ModularGraphicsBackend::ModularGraphicsBackend()
:
- _mutexManager(0),
_graphicsManager(0) {
}
-ModularBackend::~ModularBackend() {
+ModularGraphicsBackend::~ModularGraphicsBackend() {
delete _graphicsManager;
_graphicsManager = 0;
- // _timerManager needs to be deleted before _mutexManager to avoid a crash.
- delete _timerManager;
- _timerManager = 0;
- delete _mutexManager;
- _mutexManager = 0;
}
-bool ModularBackend::hasFeature(Feature f) {
+bool ModularGraphicsBackend::hasFeature(Feature f) {
return _graphicsManager->hasFeature(f);
}
-void ModularBackend::setFeatureState(Feature f, bool enable) {
+void ModularGraphicsBackend::setFeatureState(Feature f, bool enable) {
_graphicsManager->setFeatureState(f, enable);
}
-bool ModularBackend::getFeatureState(Feature f) {
+bool ModularGraphicsBackend::getFeatureState(Feature f) {
return _graphicsManager->getFeatureState(f);
}
-GraphicsManager *ModularBackend::getGraphicsManager() {
+GraphicsManager *ModularGraphicsBackend::getGraphicsManager() {
assert(_graphicsManager);
return (GraphicsManager *)_graphicsManager;
}
-const OSystem::GraphicsMode *ModularBackend::getSupportedGraphicsModes() const {
+const OSystem::GraphicsMode *ModularGraphicsBackend::getSupportedGraphicsModes() const {
return _graphicsManager->getSupportedGraphicsModes();
}
-int ModularBackend::getDefaultGraphicsMode() const {
+int ModularGraphicsBackend::getDefaultGraphicsMode() const {
return _graphicsManager->getDefaultGraphicsMode();
}
-bool ModularBackend::setGraphicsMode(int mode) {
+bool ModularGraphicsBackend::setGraphicsMode(int mode) {
return _graphicsManager->setGraphicsMode(mode);
}
-int ModularBackend::getGraphicsMode() const {
+int ModularGraphicsBackend::getGraphicsMode() const {
return _graphicsManager->getGraphicsMode();
}
-const OSystem::GraphicsMode *ModularBackend::getSupportedShaders() const {
+const OSystem::GraphicsMode *ModularGraphicsBackend::getSupportedShaders() const {
return _graphicsManager->getSupportedShaders();
}
-int ModularBackend::getDefaultShader() const {
+int ModularGraphicsBackend::getDefaultShader() const {
return _graphicsManager->getDefaultShader();
}
-bool ModularBackend::setShader(int id) {
+bool ModularGraphicsBackend::setShader(int id) {
return _graphicsManager->setShader(id);
}
-int ModularBackend::getShader() const {
+int ModularGraphicsBackend::getShader() const {
return _graphicsManager->getShader();
}
-const OSystem::GraphicsMode *ModularBackend::getSupportedStretchModes() const {
+const OSystem::GraphicsMode *ModularGraphicsBackend::getSupportedStretchModes() const {
return _graphicsManager->getSupportedStretchModes();
}
-int ModularBackend::getDefaultStretchMode() const {
+int ModularGraphicsBackend::getDefaultStretchMode() const {
return _graphicsManager->getDefaultStretchMode();
}
-bool ModularBackend::setStretchMode(int mode) {
+bool ModularGraphicsBackend::setStretchMode(int mode) {
return _graphicsManager->setStretchMode(mode);
}
-int ModularBackend::getStretchMode() const {
+int ModularGraphicsBackend::getStretchMode() const {
return _graphicsManager->getStretchMode();
}
-void ModularBackend::resetGraphicsScale() {
+void ModularGraphicsBackend::resetGraphicsScale() {
_graphicsManager->resetGraphicsScale();
}
#ifdef USE_RGB_COLOR
-Graphics::PixelFormat ModularBackend::getScreenFormat() const {
+Graphics::PixelFormat ModularGraphicsBackend::getScreenFormat() const {
return _graphicsManager->getScreenFormat();
}
-Common::List<Graphics::PixelFormat> ModularBackend::getSupportedFormats() const {
+Common::List<Graphics::PixelFormat> ModularGraphicsBackend::getSupportedFormats() const {
return _graphicsManager->getSupportedFormats();
}
#endif
-void ModularBackend::initSize(uint w, uint h, const Graphics::PixelFormat *format ) {
+void ModularGraphicsBackend::initSize(uint w, uint h, const Graphics::PixelFormat *format ) {
_graphicsManager->initSize(w, h, format);
}
-void ModularBackend::initSizeHint(const Graphics::ModeList &modes) {
+void ModularGraphicsBackend::initSizeHint(const Graphics::ModeList &modes) {
_graphicsManager->initSizeHint(modes);
}
-int ModularBackend::getScreenChangeID() const {
+int ModularGraphicsBackend::getScreenChangeID() const {
return _graphicsManager->getScreenChangeID();
}
-void ModularBackend::beginGFXTransaction() {
+void ModularGraphicsBackend::beginGFXTransaction() {
_graphicsManager->beginGFXTransaction();
}
-OSystem::TransactionError ModularBackend::endGFXTransaction() {
+OSystem::TransactionError ModularGraphicsBackend::endGFXTransaction() {
return _graphicsManager->endGFXTransaction();
}
-int16 ModularBackend::getHeight() {
+int16 ModularGraphicsBackend::getHeight() {
return _graphicsManager->getHeight();
}
-int16 ModularBackend::getWidth() {
+int16 ModularGraphicsBackend::getWidth() {
return _graphicsManager->getWidth();
}
-PaletteManager *ModularBackend::getPaletteManager() {
+PaletteManager *ModularGraphicsBackend::getPaletteManager() {
return _graphicsManager;
}
-void ModularBackend::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
+void ModularGraphicsBackend::copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h) {
_graphicsManager->copyRectToScreen(buf, pitch, x, y, w, h);
}
-Graphics::Surface *ModularBackend::lockScreen() {
+Graphics::Surface *ModularGraphicsBackend::lockScreen() {
return _graphicsManager->lockScreen();
}
-void ModularBackend::unlockScreen() {
+void ModularGraphicsBackend::unlockScreen() {
_graphicsManager->unlockScreen();
}
-void ModularBackend::fillScreen(uint32 col) {
+void ModularGraphicsBackend::fillScreen(uint32 col) {
_graphicsManager->fillScreen(col);
}
-void ModularBackend::updateScreen() {
+void ModularGraphicsBackend::updateScreen() {
#ifdef ENABLE_EVENTRECORDER
g_eventRec.preDrawOverlayGui();
#endif
@@ -187,90 +181,105 @@ void ModularBackend::updateScreen() {
#endif
}
-void ModularBackend::setShakePos(int shakeXOffset, int shakeYOffset) {
+void ModularGraphicsBackend::setShakePos(int shakeXOffset, int shakeYOffset) {
_graphicsManager->setShakePos(shakeXOffset, shakeYOffset);
}
-void ModularBackend::setFocusRectangle(const Common::Rect& rect) {
+void ModularGraphicsBackend::setFocusRectangle(const Common::Rect& rect) {
_graphicsManager->setFocusRectangle(rect);
}
-void ModularBackend::clearFocusRectangle() {
+void ModularGraphicsBackend::clearFocusRectangle() {
_graphicsManager->clearFocusRectangle();
}
-void ModularBackend::showOverlay() {
+void ModularGraphicsBackend::showOverlay() {
_graphicsManager->showOverlay();
}
-void ModularBackend::hideOverlay() {
+void ModularGraphicsBackend::hideOverlay() {
_graphicsManager->hideOverlay();
}
-Graphics::PixelFormat ModularBackend::getOverlayFormat() const {
+Graphics::PixelFormat ModularGraphicsBackend::getOverlayFormat() const {
return _graphicsManager->getOverlayFormat();
}
-void ModularBackend::clearOverlay() {
+void ModularGraphicsBackend::clearOverlay() {
_graphicsManager->clearOverlay();
}
-void ModularBackend::grabOverlay(void *buf, int pitch) {
+void ModularGraphicsBackend::grabOverlay(void *buf, int pitch) {
_graphicsManager->grabOverlay(buf, pitch);
}
-void ModularBackend::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) {
+void ModularGraphicsBackend::copyRectToOverlay(const void *buf, int pitch, int x, int y, int w, int h) {
_graphicsManager->copyRectToOverlay(buf, pitch, x, y, w, h);
}
-int16 ModularBackend::getOverlayHeight() {
+int16 ModularGraphicsBackend::getOverlayHeight() {
return _graphicsManager->getOverlayHeight();
}
-int16 ModularBackend::getOverlayWidth() {
+int16 ModularGraphicsBackend::getOverlayWidth() {
return _graphicsManager->getOverlayWidth();
}
-bool ModularBackend::showMouse(bool visible) {
+bool ModularGraphicsBackend::showMouse(bool visible) {
return _graphicsManager->showMouse(visible);
}
-void ModularBackend::warpMouse(int x, int y) {
+void ModularGraphicsBackend::warpMouse(int x, int y) {
_eventManager->purgeMouseEvents();
_graphicsManager->warpMouse(x, y);
}
-void ModularBackend::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) {
+void ModularGraphicsBackend::setMouseCursor(const void *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) {
_graphicsManager->setMouseCursor(buf, w, h, hotspotX, hotspotY, keycolor, dontScale, format);
}
-void ModularBackend::setCursorPalette(const byte *colors, uint start, uint num) {
+void ModularGraphicsBackend::setCursorPalette(const byte *colors, uint start, uint num) {
_graphicsManager->setCursorPalette(colors, start, num);
}
-OSystem::MutexRef ModularBackend::createMutex() {
+void ModularGraphicsBackend::displayMessageOnOSD(const char *msg) {
+ _graphicsManager->displayMessageOnOSD(msg);
+}
+
+void ModularGraphicsBackend::displayActivityIconOnOSD(const Graphics::Surface *icon) {
+ _graphicsManager->displayActivityIconOnOSD(icon);
+}
+
+
+ModularMutexBackend::ModularMutexBackend()
+ :
+ _mutexManager(0) {
+
+}
+
+ModularMutexBackend::~ModularMutexBackend() {
+ // _timerManager needs to be deleted before _mutexManager to avoid a crash.
+ delete _timerManager;
+ _timerManager = 0;
+ delete _mutexManager;
+ _mutexManager = 0;
+}
+
+OSystem::MutexRef ModularMutexBackend::createMutex() {
assert(_mutexManager);
return _mutexManager->createMutex();
}
-void ModularBackend::lockMutex(MutexRef mutex) {
+void ModularMutexBackend::lockMutex(MutexRef mutex) {
assert(_mutexManager);
_mutexManager->lockMutex(mutex);
}
-void ModularBackend::unlockMutex(MutexRef mutex) {
+void ModularMutexBackend::unlockMutex(MutexRef mutex) {
assert(_mutexManager);
_mutexManager->unlockMutex(mutex);
}
-void ModularBackend::deleteMutex(MutexRef mutex) {
+void ModularMutexBackend::deleteMutex(MutexRef mutex) {
assert(_mutexManager);
_mutexManager->deleteMutex(mutex);
}
-
-void ModularBackend::displayMessageOnOSD(const char *msg) {
- _graphicsManager->displayMessageOnOSD(msg);
-}
-
-void ModularBackend::displayActivityIconOnOSD(const Graphics::Surface *icon) {
- _graphicsManager->displayActivityIconOnOSD(icon);
-}
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index e57dbf174f..1fa30e3e50 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -29,12 +29,12 @@ class GraphicsManager;
class MutexManager;
/**
- * Base class for modular backends.
+ * Base classes for modular backends.
*
- * It wraps most functions to their manager equivalent, but not
+ * They wrap most functions to their manager equivalent, but not
* all OSystem functions are implemented here.
*
- * A backend derivated from this class, will need to implement
+ * A backend derivated from these classes, will need to implement
* these functions on its own:
* OSystem::pollEvent()
* OSystem::getMillis()
@@ -46,10 +46,10 @@ class MutexManager;
* And, it should also initialize all the managers variables
* declared in this class, or override their related functions.
*/
-class ModularBackend : public BaseBackend {
+class ModularGraphicsBackend : virtual public BaseBackend {
public:
- ModularBackend();
- virtual ~ModularBackend();
+ ModularGraphicsBackend();
+ virtual ~ModularGraphicsBackend();
/** @name Features */
//@{
@@ -116,21 +116,35 @@ public:
//@}
- /** @name Mutex handling */
+ /** @name Miscellaneous */
//@{
- virtual MutexRef createMutex() override final;
- virtual void lockMutex(MutexRef mutex) override final;
- virtual void unlockMutex(MutexRef mutex) override final;
- virtual void deleteMutex(MutexRef mutex) override final;
+ virtual void displayMessageOnOSD(const char *msg) override final;
+ virtual void displayActivityIconOnOSD(const Graphics::Surface *icon) override final;
//@}
- /** @name Miscellaneous */
+protected:
+ /** @name Managers variables */
//@{
- virtual void displayMessageOnOSD(const char *msg) override final;
- virtual void displayActivityIconOnOSD(const Graphics::Surface *icon) override final;
+ GraphicsManager *_graphicsManager;
+
+ //@}
+};
+
+class ModularMutexBackend : virtual public BaseBackend {
+public:
+ ModularMutexBackend();
+ virtual ~ModularMutexBackend();
+
+ /** @name Mutex handling */
+ //@{
+
+ virtual MutexRef createMutex() override final;
+ virtual void lockMutex(MutexRef mutex) override final;
+ virtual void unlockMutex(MutexRef mutex) override final;
+ virtual void deleteMutex(MutexRef mutex) override final;
//@}
@@ -139,7 +153,6 @@ protected:
//@{
MutexManager *_mutexManager;
- GraphicsManager *_graphicsManager;
//@}
};
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 786fdd7683..3d89ca1125 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -368,7 +368,7 @@ void OSystem_Android::initBackend() {
JNI::setReadyForEvents(true);
- ModularBackend::initBackend();
+ BaseBackend::initBackend();
}
bool OSystem_Android::hasFeature(Feature f) {
@@ -379,7 +379,7 @@ bool OSystem_Android::hasFeature(Feature f) {
f == kFeatureClipboardSupport) {
return true;
}
- return ModularBackend::hasFeature(f);
+ return ModularGraphicsBackend::hasFeature(f);
}
void OSystem_Android::setFeatureState(Feature f, bool enable) {
@@ -399,7 +399,7 @@ void OSystem_Android::setFeatureState(Feature f, bool enable) {
JNI::showKeyboardControl(enable);
break;
default:
- ModularBackend::setFeatureState(f, enable);
+ ModularGraphicsBackend::setFeatureState(f, enable);
break;
}
}
@@ -413,7 +413,7 @@ bool OSystem_Android::getFeatureState(Feature f) {
case kFeatureOnScreenControl:
return ConfMan.getBool("onscreen_control");
default:
- return ModularBackend::getFeatureState(f);
+ return ModularGraphicsBackend::getFeatureState(f);
}
}
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index da31674576..89124aed50 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -56,7 +56,7 @@ extern const char *android_log_tag;
#define ENTER(fmt, args...) do { } while (false)
#endif
-class OSystem_Android : public ModularBackend, Common::EventSource {
+class OSystem_Android : public ModularMutexBackend, public ModularGraphicsBackend, Common::EventSource {
private:
// passed from the dark side
int _audio_sample_rate;
diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index 636ad5004b..0840b457f6 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -65,7 +65,7 @@
#include "backends/fs/windows/windows-fs-factory.h"
#endif
-class OSystem_NULL : public ModularBackend, Common::EventSource {
+class OSystem_NULL : public ModularMutexBackend, public ModularGraphicsBackend, Common::EventSource {
public:
OSystem_NULL();
virtual ~OSystem_NULL();
@@ -145,7 +145,7 @@ void OSystem_NULL::initBackend() {
// into the system somehow to be functional. Of course, can't do
// that in a NULL backend :).
- ModularBackend::initBackend();
+ BaseBackend::initBackend();
}
bool OSystem_NULL::pollEvent(Common::Event &event) {
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index ca8291f57a..662676aa96 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -91,7 +91,7 @@ OSystem_SDL::~OSystem_SDL() {
SDL_ShowCursor(SDL_ENABLE);
// Delete the various managers here. Note that the ModularBackend
- // destructor would also take care of this for us. However, various
+ // destructors would also take care of this for us. However, various
// of our managers must be deleted *before* we call SDL_Quit().
// Hence, we perform the destruction on our own.
delete _savefileManager;
@@ -170,7 +170,7 @@ bool OSystem_SDL::hasFeature(Feature f) {
if (f == kFeatureJoystickDeadzone || f == kFeatureKbdMouseSpeed) {
return _eventSource->isJoystickConnected();
}
- return ModularBackend::hasFeature(f);
+ return ModularGraphicsBackend::hasFeature(f);
}
void OSystem_SDL::initBackend() {
@@ -266,7 +266,7 @@ void OSystem_SDL::initBackend() {
_inited = true;
- ModularBackend::initBackend();
+ BaseBackend::initBackend();
// We have to initialize the graphics manager before the event manager
// so the virtual keyboard can be initialized, but we have to add the
@@ -376,7 +376,7 @@ void OSystem_SDL::fatalError() {
}
Common::KeymapArray OSystem_SDL::getGlobalKeymaps() {
- Common::KeymapArray globalMaps = ModularBackend::getGlobalKeymaps();
+ Common::KeymapArray globalMaps = BaseBackend::getGlobalKeymaps();
SdlGraphicsManager *graphicsManager = dynamic_cast<SdlGraphicsManager *>(_graphicsManager);
globalMaps.push_back(graphicsManager->getKeymap());
@@ -447,7 +447,7 @@ Common::String OSystem_SDL::getSystemLanguage() const {
// Detect the language from the locale
if (locale.empty()) {
- return ModularBackend::getSystemLanguage();
+ return BaseBackend::getSystemLanguage();
} else {
int length = 0;
@@ -465,7 +465,7 @@ Common::String OSystem_SDL::getSystemLanguage() const {
return Common::String(locale.c_str(), length);
}
#else // USE_DETECTLANG
- return ModularBackend::getSystemLanguage();
+ return BaseBackend::getSystemLanguage();
#endif // USE_DETECTLANG
}
@@ -781,6 +781,6 @@ char *OSystem_SDL::convertEncoding(const char *to, const char *from, const char
SDL_free(result);
return finalResult;
#else
- return ModularBackend::convertEncoding(to, from, string, length);
+ return BaseBackend::convertEncoding(to, from, string, length);
#endif // SDL_VERSION_ATLEAST(1, 2, 10)
}
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 31cfd0b913..4722b1fd1f 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -36,7 +36,7 @@
/**
* Base OSystem class for all SDL ports.
*/
-class OSystem_SDL : public ModularBackend {
+class OSystem_SDL : public ModularMutexBackend, public ModularGraphicsBackend {
public:
OSystem_SDL();
virtual ~OSystem_SDL();
diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp
index ee11858477..b4ec7a83a5 100644
--- a/backends/platform/symbian/src/SymbianOS.cpp
+++ b/backends/platform/symbian/src/SymbianOS.cpp
@@ -88,7 +88,7 @@ void OSystem_SDL_Symbian::initBackend() {
TFileName fname;
TPtrC8 ptr((const unsigned char*)currentPath.c_str(), currentPath.size());
fname.Copy(ptr);
- BaflUtils::EnsurePathExistsL(static_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), fname);
+ BaflUtils::EnsurePathExistsL(dynamic_cast<OSystem_SDL_Symbian *>(g_system)->FsSession(), fname);
ConfMan.setBool("FM_high_quality", false);
#if !defined(S60) || defined(S60V3) // S60 has low quality as default
Commit: 7745ffdac1ccae59471e24eaeb1b081ea8fceecd
https://github.com/scummvm/scummvm/commit/7745ffdac1ccae59471e24eaeb1b081ea8fceecd
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-08-24T14:22:35+02:00
Commit Message:
BACKENDS: Simplify EventsBaseBackend
Changed paths:
backends/base-backend.cpp
backends/base-backend.h
backends/platform/3ds/config.cpp
backends/platform/3ds/osystem-audio.cpp
backends/platform/3ds/osystem-events.cpp
backends/platform/android/android.h
backends/platform/ds/arm9/source/wordcompletion.cpp
backends/platform/ios7/ios7_osys_main.cpp
backends/platform/n64/osys_n64_utilities.cpp
backends/platform/null/null.cpp
backends/platform/sdl/sdl.h
common/system.h
diff --git a/backends/base-backend.cpp b/backends/base-backend.cpp
index 9164b8d721..d232a193a8 100644
--- a/backends/base-backend.cpp
+++ b/backends/base-backend.cpp
@@ -40,12 +40,6 @@ void BaseBackend::displayMessageOnOSD(const char *msg) {
}
void BaseBackend::initBackend() {
- // Init Event manager
-#ifndef DISABLE_DEFAULT_EVENT_MANAGER
- if (!_eventManager)
- _eventManager = new DefaultEventManager(getDefaultEventSource());
-#endif
-
// Init audio CD manager
#ifndef DISABLE_DEFAULT_AUDIOCD_MANAGER
if (!_audiocdManager)
@@ -61,3 +55,13 @@ void BaseBackend::fillScreen(uint32 col) {
screen->fillRect(Common::Rect(screen->w, screen->h), col);
unlockScreen();
}
+
+void EventsBaseBackend::initBackend() {
+ // Init Event manager
+#ifndef DISABLE_DEFAULT_EVENT_MANAGER
+ if (!_eventManager)
+ _eventManager = new DefaultEventManager(this);
+#endif
+
+ BaseBackend::initBackend();
+}
diff --git a/backends/base-backend.h b/backends/base-backend.h
index 6d074a4c3e..657a24a099 100644
--- a/backends/base-backend.h
+++ b/backends/base-backend.h
@@ -27,8 +27,6 @@
#include "common/events.h"
class BaseBackend : public OSystem {
-protected:
- virtual Common::EventSource *getDefaultEventSource() = 0;
public:
virtual void initBackend();
@@ -37,10 +35,9 @@ public:
virtual void fillScreen(uint32 col);
};
-class EventsBaseBackend : public BaseBackend, Common::EventSource {
-protected:
- virtual Common::EventSource *getDefaultEventSource() { return this; }
+class EventsBaseBackend : virtual public BaseBackend, Common::EventSource {
public:
+ virtual void initBackend();
};
diff --git a/backends/platform/3ds/config.cpp b/backends/platform/3ds/config.cpp
index a160ac9950..0fe7f700aa 100644
--- a/backends/platform/3ds/config.cpp
+++ b/backends/platform/3ds/config.cpp
@@ -74,7 +74,7 @@ void loadConfig() {
gspLcdExit();
}
- OSystem_3DS *osys = (OSystem_3DS *)g_system;
+ OSystem_3DS *osys = dynamic_cast<OSystem_3DS *>(g_system);
osys->updateConfig();
}
diff --git a/backends/platform/3ds/osystem-audio.cpp b/backends/platform/3ds/osystem-audio.cpp
index 6f16a58ad1..b9a4cc7a3e 100644
--- a/backends/platform/3ds/osystem-audio.cpp
+++ b/backends/platform/3ds/osystem-audio.cpp
@@ -29,7 +29,7 @@ static bool hasAudio = false;
static void audioThreadFunc(void *arg) {
Audio::MixerImpl *mixer = (Audio::MixerImpl *)arg;
- OSystem_3DS *osys = (OSystem_3DS *)g_system;
+ OSystem_3DS *osys = dynamic_cast<OSystem_3DS *>(g_system);
const int channel = 0;
int bufferIndex = 0;
diff --git a/backends/platform/3ds/osystem-events.cpp b/backends/platform/3ds/osystem-events.cpp
index 7f4928d691..c26306a2ed 100644
--- a/backends/platform/3ds/osystem-events.cpp
+++ b/backends/platform/3ds/osystem-events.cpp
@@ -91,7 +91,7 @@ static void doJoyEvent(Common::Queue<Common::Event> *queue, u32 keysPressed, u32
}
static void eventThreadFunc(void *arg) {
- OSystem_3DS *osys = (OSystem_3DS *)g_system;
+ OSystem_3DS *osys = dynamic_cast<OSystem_3DS *>(g_system);
Common::Queue<Common::Event> *eventQueue = (Common::Queue<Common::Event> *)arg;
uint32 touchStartTime = osys->getMillis();
@@ -206,7 +206,7 @@ static void eventThreadFunc(void *arg) {
}
static void aptHookFunc(APT_HookType hookType, void *param) {
- OSystem_3DS *osys = (OSystem_3DS *)g_system;
+ OSystem_3DS *osys = dynamic_cast<OSystem_3DS *>(g_system);
switch (hookType) {
case APTHOOK_ONSUSPEND:
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 89124aed50..050efd804e 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -81,9 +81,6 @@ private:
Common::String getSystemProperty(const char *name) const;
-protected:
- virtual Common::EventSource *getDefaultEventSource() { return this; }
-
public:
OSystem_Android(int audio_sample_rate, int audio_buffer_size);
virtual ~OSystem_Android();
diff --git a/backends/platform/ds/arm9/source/wordcompletion.cpp b/backends/platform/ds/arm9/source/wordcompletion.cpp
index 2257c49005..eb0d5d7914 100644
--- a/backends/platform/ds/arm9/source/wordcompletion.cpp
+++ b/backends/platform/ds/arm9/source/wordcompletion.cpp
@@ -104,7 +104,7 @@ bool findWordCompletions(const char *input) {
if (wordBufferPtrPos == 0)
return false;
- OSystem_DS *system = (OSystem_DS *) g_system;
+ OSystem_DS *system = dynamic_cast<OSystem_DS *>(g_system);
system->clearAutoComplete();
int start = 0;
diff --git a/backends/platform/ios7/ios7_osys_main.cpp b/backends/platform/ios7/ios7_osys_main.cpp
index 23278a30df..90bb5d6933 100644
--- a/backends/platform/ios7/ios7_osys_main.cpp
+++ b/backends/platform/ios7/ios7_osys_main.cpp
@@ -353,7 +353,7 @@ void OSystem_iOS7::addSysArchivesToSearchSet(Common::SearchSet &s, int priority)
}
bool iOS7_touchpadModeEnabled() {
- OSystem_iOS7 *sys = (OSystem_iOS7 *) g_system;
+ OSystem_iOS7 *sys = dynamic_cast<OSystem_iOS7 *>(g_system);
return sys && sys->touchpadModeEnabled();
}
diff --git a/backends/platform/n64/osys_n64_utilities.cpp b/backends/platform/n64/osys_n64_utilities.cpp
index b3b6d50667..defe60a0a5 100644
--- a/backends/platform/n64/osys_n64_utilities.cpp
+++ b/backends/platform/n64/osys_n64_utilities.cpp
@@ -24,7 +24,7 @@
#include "backends/timer/default/default-timer.h"
void checkTimers(void) {
- OSystem_N64 *osys = (OSystem_N64 *)g_system;
+ OSystem_N64 *osys = dynamic_cast<OSystem_N64 *>(g_system);
uint32 curTime = osys->getMillis();
@@ -46,7 +46,7 @@ void disableAudioPlayback(void) {
void enableAudioPlayback(void) {
static bool _firstRun = true;
- OSystem_N64 *osys = (OSystem_N64 *)g_system;
+ OSystem_N64 *osys = dynamic_cast<OSystem_N64 *>(g_system);
Audio::MixerImpl *localmixer = (Audio::MixerImpl *)osys->getMixer();
uint32 sampleBufferSize = 3072;
@@ -83,7 +83,7 @@ void vblCallback(void) {
sndCallback();
}
- ((OSystem_N64 *)g_system)->readControllerAnalogInput();
+ dynamic_cast<OSystem_N64 *>(g_system)->readControllerAnalogInput();
}
void sndCallback() {
@@ -95,7 +95,7 @@ void sndCallback() {
void refillAudioBuffers(void) {
if (!_audioEnabled) return;
- OSystem_N64 *osys = (OSystem_N64 *)g_system;
+ OSystem_N64 *osys = dynamic_cast<OSystem_N64 *>(g_system);
byte *sndBuf;
Audio::MixerImpl *localmixer = (Audio::MixerImpl *)osys->getMixer();
diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index 0840b457f6..cd6677c60d 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -72,7 +72,6 @@ public:
virtual void initBackend();
- virtual Common::EventSource *getDefaultEventSource() { return this; }
virtual bool pollEvent(Common::Event &event);
virtual uint32 getMillis(bool skipRecord = false);
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 4722b1fd1f..0acb9beb9c 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -124,8 +124,6 @@ protected:
*/
SdlWindow *_window;
- virtual Common::EventSource *getDefaultEventSource() override { return _eventSource; }
-
/**
* Initialze the SDL library.
*/
diff --git a/common/system.h b/common/system.h
index 32838c001d..a808e85278 100644
--- a/common/system.h
+++ b/common/system.h
@@ -149,7 +149,7 @@ protected:
/**
* No default value is provided for _eventManager by OSystem.
- * However, BaseBackend::initBackend() does set a default value
+ * However, EventsBaseBackend::initBackend() does set a default value
* if none has been set before.
*
* @note _eventManager is deleted by the OSystem destructor.
Commit: 697d1a86722fa9b5a89b2e002245ef4791685fdf
https://github.com/scummvm/scummvm/commit/697d1a86722fa9b5a89b2e002245ef4791685fdf
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-08-24T14:22:35+02:00
Commit Message:
BACKENDS: Added an abstract MixerManager class
Changed paths:
A backends/mixer/mixer.h
backends/mixer/sdl/sdl-mixer.cpp
backends/mixer/sdl/sdl-mixer.h
backends/platform/sdl/sdl.cpp
backends/platform/sdl/sdl.h
gui/EventRecorder.cpp
gui/EventRecorder.h
diff --git a/backends/mixer/mixer.h b/backends/mixer/mixer.h
new file mode 100644
index 0000000000..1bb7d6fd04
--- /dev/null
+++ b/backends/mixer/mixer.h
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef BACKENDS_MIXER_ABSTRACT_H
+#define BACKENDS_MIXER_ABSTRACT_H
+
+#include "audio/mixer_intern.h"
+
+/**
+ * Abstract class for mixer manager. Subclasses
+ * implement the real functionality.
+ */
+class MixerManager {
+public:
+ MixerManager() : _mixer(0), _audioSuspended(false) {}
+ virtual ~MixerManager() { delete _mixer; }
+
+ /**
+ * Initialize and setups the mixer
+ */
+ virtual void init() = 0;
+
+ /**
+ * Get the audio mixer implementation
+ */
+ Audio::Mixer *getMixer() { return (Audio::Mixer *)_mixer; }
+
+ // Used by LinuxMoto Port
+
+ /**
+ * Pauses the audio system
+ */
+ virtual void suspendAudio() = 0;
+
+ /**
+ * Resumes the audio system
+ */
+ virtual int resumeAudio() = 0;
+
+protected:
+ /** The mixer implementation */
+ Audio::MixerImpl *_mixer;
+
+ /** State of the audio system */
+ bool _audioSuspended;
+};
+
+#endif
diff --git a/backends/mixer/sdl/sdl-mixer.cpp b/backends/mixer/sdl/sdl-mixer.cpp
index b0352a9914..25d267006f 100644
--- a/backends/mixer/sdl/sdl-mixer.cpp
+++ b/backends/mixer/sdl/sdl-mixer.cpp
@@ -38,21 +38,12 @@
#define SAMPLES_PER_SEC 44100
#endif
-SdlMixerManager::SdlMixerManager()
- :
- _mixer(0),
- _audioSuspended(false) {
-
-}
-
SdlMixerManager::~SdlMixerManager() {
_mixer->setReady(false);
SDL_CloseAudio();
SDL_QuitSubSystem(SDL_INIT_AUDIO);
-
- delete _mixer;
}
void SdlMixerManager::init() {
diff --git a/backends/mixer/sdl/sdl-mixer.h b/backends/mixer/sdl/sdl-mixer.h
index b967ca318f..6fda6f788f 100644
--- a/backends/mixer/sdl/sdl-mixer.h
+++ b/backends/mixer/sdl/sdl-mixer.h
@@ -24,7 +24,7 @@
#define BACKENDS_MIXER_SDL_H
#include "backends/platform/sdl/sdl-sys.h"
-#include "audio/mixer_intern.h"
+#include "backends/mixer/mixer.h"
/**
* SDL mixer manager. It wraps the actual implementation
@@ -32,9 +32,8 @@
* the SDL audio subsystem and the callback for the
* audio mixer implementation.
*/
-class SdlMixerManager {
+class SdlMixerManager : public MixerManager {
public:
- SdlMixerManager();
virtual ~SdlMixerManager();
/**
@@ -42,11 +41,6 @@ public:
*/
virtual void init();
- /**
- * Get the audio mixer implementation
- */
- Audio::Mixer *getMixer() { return (Audio::Mixer *)_mixer; }
-
// Used by Event recorder
/**
@@ -60,18 +54,12 @@ public:
virtual int resumeAudio();
protected:
- /** The mixer implementation */
- Audio::MixerImpl *_mixer;
-
/**
* The obtained audio specification after opening the
* audio system.
*/
SDL_AudioSpec _obtained;
- /** State of the audio system */
- bool _audioSuspended;
-
/**
* Returns the desired audio specification
*/
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 662676aa96..02c795b5c4 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -546,7 +546,7 @@ Audio::Mixer *OSystem_SDL::getMixer() {
return getMixerManager()->getMixer();
}
-SdlMixerManager *OSystem_SDL::getMixerManager() {
+MixerManager *OSystem_SDL::getMixerManager() {
assert(_mixerManager);
#ifdef ENABLE_EVENTRECORDER
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 0acb9beb9c..11d985a577 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -53,7 +53,7 @@ public:
* that returns Audio::Mixer. The Mixer Manager is a SDL wrapper class
* for the Audio::Mixer. Used by other managers.
*/
- virtual SdlMixerManager *getMixerManager();
+ virtual MixerManager *getMixerManager();
virtual bool hasFeature(Feature f) override;
@@ -111,7 +111,7 @@ protected:
* Mixer manager that configures and setups SDL for
* the wrapped Audio::Mixer, the true mixer.
*/
- SdlMixerManager *_mixerManager;
+ MixerManager *_mixerManager;
/**
* The event source we use for obtaining SDL events.
diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index 492b7bc9f4..b09cde8da5 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -31,7 +31,7 @@ DECLARE_SINGLETON(GUI::EventRecorder);
#include "common/debug-channels.h"
#include "backends/timer/sdl/sdl-timer.h"
-#include "backends/mixer/sdl/sdl-mixer.h"
+#include "backends/mixer/mixer.h"
#include "common/config-manager.h"
#include "common/md5.h"
#include "gui/gui-manager.h"
@@ -349,7 +349,7 @@ bool EventRecorder::checkGameHash(const ADGameDescription *gameDesc) {
return true;
}
-void EventRecorder::registerMixerManager(SdlMixerManager *mixerManager) {
+void EventRecorder::registerMixerManager(MixerManager *mixerManager) {
_realMixerManager = mixerManager;
}
@@ -362,7 +362,7 @@ void EventRecorder::switchMixer() {
}
}
-SdlMixerManager *EventRecorder::getMixerManager() {
+MixerManager *EventRecorder::getMixerManager() {
if (_recordMode == kPassthrough) {
return _realMixerManager;
} else {
diff --git a/gui/EventRecorder.h b/gui/EventRecorder.h
index 3aa4adf996..70597f4f7c 100644
--- a/gui/EventRecorder.h
+++ b/gui/EventRecorder.h
@@ -36,7 +36,7 @@
#include "common/mutex.h"
#include "common/array.h"
#include "common/memstream.h"
-#include "backends/mixer/sdl/sdl-mixer.h"
+#include "backends/mixer/mixer.h"
#include "common/hashmap.h"
#include "common/hash-str.h"
#include "backends/timer/sdl/sdl-timer.h"
@@ -142,10 +142,10 @@ public:
_needRedraw = redraw;
}
- void registerMixerManager(SdlMixerManager *mixerManager);
+ void registerMixerManager(MixerManager *mixerManager);
void registerTimerManager(DefaultTimerManager *timerManager);
- SdlMixerManager *getMixerManager();
+ MixerManager *getMixerManager();
DefaultTimerManager *getTimerManager();
void deleteRecord(const Common::String& fileName);
@@ -187,7 +187,7 @@ private:
Common::String _name;
Common::SaveFileManager *_realSaveManager;
- SdlMixerManager *_realMixerManager;
+ MixerManager *_realMixerManager;
DefaultTimerManager *_timerManager;
RecorderSaveFileManager _fakeSaveManager;
NullSdlMixerManager *_fakeMixerManager;
Commit: d1bfa2c4ec38b674feee3750e9f0cfa58730b3b9
https://github.com/scummvm/scummvm/commit/d1bfa2c4ec38b674feee3750e9f0cfa58730b3b9
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-08-24T14:22:35+02:00
Commit Message:
BACKENDS: Modify the null mixer manager to not require SDL
Changed paths:
A backends/mixer/null/null-mixer.cpp
A backends/mixer/null/null-mixer.h
R backends/mixer/nullmixer/nullsdl-mixer.cpp
R backends/mixer/nullmixer/nullsdl-mixer.h
backends/module.mk
gui/EventRecorder.cpp
gui/EventRecorder.h
diff --git a/backends/mixer/nullmixer/nullsdl-mixer.cpp b/backends/mixer/null/null-mixer.cpp
similarity index 73%
rename from backends/mixer/nullmixer/nullsdl-mixer.cpp
rename to backends/mixer/null/null-mixer.cpp
index 8f112e1fa0..a81ba72a51 100644
--- a/backends/mixer/nullmixer/nullsdl-mixer.cpp
+++ b/backends/mixer/null/null-mixer.cpp
@@ -20,10 +20,10 @@
*
*/
-#include "backends/mixer/nullmixer/nullsdl-mixer.h"
+#include "backends/mixer/null/null-mixer.h"
#include "common/savefile.h"
-NullSdlMixerManager::NullSdlMixerManager() : SdlMixerManager() {
+NullMixerManager::NullMixerManager() : MixerManager() {
_outputRate = 22050;
_callsCounter = 0;
_callbackPeriod = 10;
@@ -33,21 +33,21 @@ NullSdlMixerManager::NullSdlMixerManager() : SdlMixerManager() {
_samplesBuf = new uint8[_samples * 4];
}
-NullSdlMixerManager::~NullSdlMixerManager() {
+NullMixerManager::~NullMixerManager() {
delete _samplesBuf;
}
-void NullSdlMixerManager::init() {
+void NullMixerManager::init() {
_mixer = new Audio::MixerImpl(_outputRate);
assert(_mixer);
_mixer->setReady(true);
}
-void NullSdlMixerManager::suspendAudio() {
+void NullMixerManager::suspendAudio() {
_audioSuspended = true;
}
-int NullSdlMixerManager::resumeAudio() {
+int NullMixerManager::resumeAudio() {
if (!_audioSuspended) {
return -2;
}
@@ -55,21 +55,13 @@ int NullSdlMixerManager::resumeAudio() {
return 0;
}
-
-void NullSdlMixerManager::startAudio() {
-}
-
-void NullSdlMixerManager::callbackHandler(byte *samples, int len) {
- assert(_mixer);
- _mixer->mixCallback(samples, len);
-}
-
-void NullSdlMixerManager::update() {
+void NullMixerManager::update() {
if (_audioSuspended) {
return;
}
_callsCounter++;
if ((_callsCounter % _callbackPeriod) == 0) {
- callbackHandler(_samplesBuf, _samples);
+ assert(_mixer);
+ _mixer->mixCallback(_samplesBuf, _samples);
}
}
diff --git a/backends/mixer/nullmixer/nullsdl-mixer.h b/backends/mixer/null/null-mixer.h
similarity index 81%
rename from backends/mixer/nullmixer/nullsdl-mixer.h
rename to backends/mixer/null/null-mixer.h
index 2fc46efc39..90ba75d4b1 100644
--- a/backends/mixer/nullmixer/nullsdl-mixer.h
+++ b/backends/mixer/null/null-mixer.h
@@ -20,11 +20,10 @@
*
*/
-#ifndef BACKENDS_MIXER_NULLSDL_H
-#define BACKENDS_MIXER_NULLSDL_H
+#ifndef BACKENDS_MIXER_NULL_H
+#define BACKENDS_MIXER_NULL_H
-#include "backends/mixer/sdl/sdl-mixer.h"
-#include "common/str.h"
+#include "backends/mixer/mixer.h"
/** Audio mixer which in fact does not output audio.
*
@@ -35,10 +34,10 @@
* users could work without modifications.
*/
-class NullSdlMixerManager : public SdlMixerManager {
+class NullMixerManager : public MixerManager {
public:
- NullSdlMixerManager();
- virtual ~NullSdlMixerManager();
+ NullMixerManager();
+ virtual ~NullMixerManager();
virtual void init();
void update();
@@ -46,11 +45,6 @@ public:
virtual void suspendAudio();
virtual int resumeAudio();
-protected:
-
- virtual void startAudio();
- virtual void callbackHandler(byte *samples, int len);
-
private:
uint32 _outputRate;
uint32 _callsCounter;
diff --git a/backends/module.mk b/backends/module.mk
index 58a77c9344..794ba7b0b7 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -344,7 +344,7 @@ endif
ifdef ENABLE_EVENTRECORDER
MODULE_OBJS += \
- mixer/nullmixer/nullsdl-mixer.o \
+ mixer/null/null-mixer.o \
saves/recorder/recorder-saves.o
endif
diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index b09cde8da5..5f29314dcc 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -260,7 +260,7 @@ Common::String EventRecorder::generateRecordFileName(const Common::String &targe
void EventRecorder::init(Common::String recordFileName, RecordMode mode) {
- _fakeMixerManager = new NullSdlMixerManager();
+ _fakeMixerManager = new NullMixerManager();
_fakeMixerManager->init();
_fakeMixerManager->suspendAudio();
_fakeTimer = 0;
diff --git a/gui/EventRecorder.h b/gui/EventRecorder.h
index 70597f4f7c..08cf2700f9 100644
--- a/gui/EventRecorder.h
+++ b/gui/EventRecorder.h
@@ -43,7 +43,7 @@
#include "common/config-manager.h"
#include "common/recorderfile.h"
#include "backends/saves/recorder/recorder-saves.h"
-#include "backends/mixer/nullmixer/nullsdl-mixer.h"
+#include "backends/mixer/null/null-mixer.h"
#include "backends/saves/default/default-saves.h"
@@ -190,7 +190,7 @@ private:
MixerManager *_realMixerManager;
DefaultTimerManager *_timerManager;
RecorderSaveFileManager _fakeSaveManager;
- NullSdlMixerManager *_fakeMixerManager;
+ NullMixerManager *_fakeMixerManager;
GUI::OnScreenDialog *_controlPanel;
Common::RecorderEvent _nextEvent;
Commit: b9d2b870858ceef6cd6c5f554cb0808b3ab94e15
https://github.com/scummvm/scummvm/commit/b9d2b870858ceef6cd6c5f554cb0808b3ab94e15
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-08-24T14:22:35+02:00
Commit Message:
BACKENDS: Move MixerManager code into ModularMixerBackend
Changed paths:
backends/modular-backend.cpp
backends/modular-backend.h
backends/platform/sdl/sdl.cpp
backends/platform/sdl/sdl.h
diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp
index 75ac7be1a2..5940c2dd4a 100644
--- a/backends/modular-backend.cpp
+++ b/backends/modular-backend.cpp
@@ -22,7 +22,9 @@
#include "backends/modular-backend.h"
+#include "backends/audiocd/audiocd.h"
#include "backends/graphics/graphics.h"
+#include "backends/mixer/mixer.h"
#include "backends/mutex/mutex.h"
#include "gui/EventRecorder.h"
@@ -250,6 +252,31 @@ void ModularGraphicsBackend::displayActivityIconOnOSD(const Graphics::Surface *i
}
+ModularMixerBackend::ModularMixerBackend()
+ :
+ _mixerManager(0) {
+
+}
+
+ModularMixerBackend::~ModularMixerBackend() {
+ // _audiocdManager needs to be deleted before _mixerManager to avoid a crash.
+ delete _audiocdManager;
+ _audiocdManager = 0;
+ delete _mixerManager;
+ _mixerManager = 0;
+}
+
+MixerManager *ModularMixerBackend::getMixerManager() {
+ assert(_mixerManager);
+ return _mixerManager;
+}
+
+Audio::Mixer *ModularMixerBackend::getMixer() {
+ assert(_mixerManager);
+ return getMixerManager()->getMixer();
+}
+
+
ModularMutexBackend::ModularMutexBackend()
:
_mutexManager(0) {
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index 1fa30e3e50..103cd1de56 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -26,6 +26,7 @@
#include "backends/base-backend.h"
class GraphicsManager;
+class MixerManager;
class MutexManager;
/**
@@ -40,7 +41,6 @@ class MutexManager;
* OSystem::getMillis()
* OSystem::delayMillis()
* OSystem::getTimeAndDate()
- * OSystem::getMixer()
* OSystem::quit()
*
* And, it should also initialize all the managers variables
@@ -133,6 +133,28 @@ protected:
//@}
};
+class ModularMixerBackend : virtual public BaseBackend {
+public:
+ ModularMixerBackend();
+ virtual ~ModularMixerBackend();
+
+ /** @name Sound */
+ //@{
+
+ virtual MixerManager *getMixerManager();
+ virtual Audio::Mixer *getMixer() override final;
+
+ //@}
+
+protected:
+ /** @name Managers variables */
+ //@{
+
+ MixerManager *_mixerManager;
+
+ //@}
+};
+
class ModularMutexBackend : virtual public BaseBackend {
public:
ModularMutexBackend();
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 02c795b5c4..85e56bd208 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -81,7 +81,6 @@ OSystem_SDL::OSystem_SDL()
_initedSDLnet(false),
#endif
_logger(0),
- _mixerManager(0),
_eventSource(0),
_eventSourceWrapper(nullptr),
_window(0) {
@@ -541,11 +540,6 @@ void OSystem_SDL::getTimeAndDate(TimeDate &td) const {
td.tm_wday = t.tm_wday;
}
-Audio::Mixer *OSystem_SDL::getMixer() {
- assert(_mixerManager);
- return getMixerManager()->getMixer();
-}
-
MixerManager *OSystem_SDL::getMixerManager() {
assert(_mixerManager);
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 11d985a577..763e74bde4 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -36,7 +36,7 @@
/**
* Base OSystem class for all SDL ports.
*/
-class OSystem_SDL : public ModularMutexBackend, public ModularGraphicsBackend {
+class OSystem_SDL : public ModularMutexBackend, public ModularMixerBackend, public ModularGraphicsBackend {
public:
OSystem_SDL();
virtual ~OSystem_SDL();
@@ -48,13 +48,6 @@ public:
*/
virtual void init() override;
- /**
- * Get the Mixer Manager instance. Not to confuse with getMixer(),
- * that returns Audio::Mixer. The Mixer Manager is a SDL wrapper class
- * for the Audio::Mixer. Used by other managers.
- */
- virtual MixerManager *getMixerManager();
-
virtual bool hasFeature(Feature f) override;
// Override functions from ModularBackend and OSystem
@@ -83,7 +76,7 @@ public:
virtual uint32 getMillis(bool skipRecord = false) override;
virtual void delayMillis(uint msecs) override;
virtual void getTimeAndDate(TimeDate &td) const override;
- virtual Audio::Mixer *getMixer() override;
+ virtual MixerManager *getMixerManager() override;
virtual Common::TimerManager *getTimerManager() override;
virtual Common::SaveFileManager *getSavefileManager() override;
@@ -107,12 +100,6 @@ protected:
*/
Common::String _logFilePath;
- /**
- * Mixer manager that configures and setups SDL for
- * the wrapped Audio::Mixer, the true mixer.
- */
- MixerManager *_mixerManager;
-
/**
* The event source we use for obtaining SDL events.
*/
Commit: e16844b6e9c9c7c08be0f4291ffed4c106a40a3c
https://github.com/scummvm/scummvm/commit/e16844b6e9c9c7c08be0f4291ffed4c106a40a3c
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-08-24T14:22:35+02:00
Commit Message:
NULL: Make use of NullMixerManager
Changed paths:
backends/mixer/null/null-mixer.cpp
backends/mixer/null/null-mixer.h
backends/module.mk
backends/platform/null/null.cpp
diff --git a/backends/mixer/null/null-mixer.cpp b/backends/mixer/null/null-mixer.cpp
index a81ba72a51..303a8110f3 100644
--- a/backends/mixer/null/null-mixer.cpp
+++ b/backends/mixer/null/null-mixer.cpp
@@ -26,7 +26,6 @@
NullMixerManager::NullMixerManager() : MixerManager() {
_outputRate = 22050;
_callsCounter = 0;
- _callbackPeriod = 10;
_samples = 8192;
while (_samples * 16 > _outputRate * 2)
_samples >>= 1;
@@ -55,12 +54,12 @@ int NullMixerManager::resumeAudio() {
return 0;
}
-void NullMixerManager::update() {
+void NullMixerManager::update(uint8 callbackPeriod) {
if (_audioSuspended) {
return;
}
_callsCounter++;
- if ((_callsCounter % _callbackPeriod) == 0) {
+ if ((_callsCounter % callbackPeriod) == 0) {
assert(_mixer);
_mixer->mixCallback(_samplesBuf, _samples);
}
diff --git a/backends/mixer/null/null-mixer.h b/backends/mixer/null/null-mixer.h
index 90ba75d4b1..4adca53b95 100644
--- a/backends/mixer/null/null-mixer.h
+++ b/backends/mixer/null/null-mixer.h
@@ -40,7 +40,7 @@ public:
virtual ~NullMixerManager();
virtual void init();
- void update();
+ void update(uint8 callbackPeriod = 10);
virtual void suspendAudio();
virtual int resumeAudio();
@@ -48,7 +48,6 @@ public:
private:
uint32 _outputRate;
uint32 _callsCounter;
- uint8 _callbackPeriod;
uint32 _samples;
uint8 *_samplesBuf;
};
diff --git a/backends/module.mk b/backends/module.mk
index 794ba7b0b7..823c2f4bf3 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -300,6 +300,11 @@ MODULE_OBJS += \
fs/n64/romfsstream.o
endif
+ifeq ($(BACKEND),null)
+MODULE_OBJS += \
+ mixer/null/null-mixer.o
+endif
+
ifeq ($(BACKEND),openpandora)
MODULE_OBJS += \
events/openpandora/op-events.o \
diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index cd6677c60d..ab77059ffa 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -44,6 +44,7 @@
#include "backends/saves/default/default-saves.h"
#include "backends/timer/default/default-timer.h"
#include "backends/events/default/default-events.h"
+#include "backends/mixer/null/null-mixer.h"
#include "backends/mutex/null/null-mutex.h"
#include "backends/graphics/null/null-graphics.h"
#include "audio/mixer_intern.h"
@@ -65,7 +66,7 @@
#include "backends/fs/windows/windows-fs-factory.h"
#endif
-class OSystem_NULL : public ModularMutexBackend, public ModularGraphicsBackend, Common::EventSource {
+class OSystem_NULL : public ModularMutexBackend, public ModularMixerBackend, public ModularGraphicsBackend, Common::EventSource {
public:
OSystem_NULL();
virtual ~OSystem_NULL();
@@ -78,21 +79,17 @@ 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);
private:
- Audio::MixerImpl *_mixer;
-
#ifdef POSIX
timeval _startTime;
#endif
};
-OSystem_NULL::OSystem_NULL() : _mixer(0) {
+OSystem_NULL::OSystem_NULL() {
#if defined(__amigaos4__)
_fsFactory = new AmigaOSFilesystemFactory();
#elif defined(__MORPHOS__)
@@ -109,8 +106,6 @@ OSystem_NULL::OSystem_NULL() : _mixer(0) {
}
OSystem_NULL::~OSystem_NULL() {
- delete _mixer;
- _mixer = 0;
}
#ifdef POSIX
@@ -136,19 +131,16 @@ void OSystem_NULL::initBackend() {
_eventManager = new DefaultEventManager(this);
_savefileManager = new DefaultSaveFileManager();
_graphicsManager = new NullGraphicsManager();
- _mixer = new Audio::MixerImpl(22050);
-
- _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
- // that in a NULL backend :).
+ _mixerManager = new NullMixerManager();
+ // Setup and start mixer
+ _mixerManager->init();
BaseBackend::initBackend();
}
bool OSystem_NULL::pollEvent(Common::Event &event) {
((DefaultTimerManager *)getTimerManager())->checkTimers();
+ ((NullMixerManager *)_mixerManager)->update(1);
#ifdef POSIX
if (intReceived) {
@@ -202,11 +194,6 @@ 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);
}
More information about the Scummvm-git-logs
mailing list