NULL: Make use of NullMixerManager

This commit is contained in:
Cameron Cawley 2019-11-30 21:48:17 +00:00 committed by Eugene Sandulenko
parent b9d2b87085
commit e16844b6e9
4 changed files with 15 additions and 25 deletions

View File

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

View File

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

View File

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

View File

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