NULL: Make use of NullMixerManager
This commit is contained in:
parent
b9d2b87085
commit
e16844b6e9
4 changed files with 15 additions and 25 deletions
|
@ -26,7 +26,6 @@
|
||||||
NullMixerManager::NullMixerManager() : MixerManager() {
|
NullMixerManager::NullMixerManager() : MixerManager() {
|
||||||
_outputRate = 22050;
|
_outputRate = 22050;
|
||||||
_callsCounter = 0;
|
_callsCounter = 0;
|
||||||
_callbackPeriod = 10;
|
|
||||||
_samples = 8192;
|
_samples = 8192;
|
||||||
while (_samples * 16 > _outputRate * 2)
|
while (_samples * 16 > _outputRate * 2)
|
||||||
_samples >>= 1;
|
_samples >>= 1;
|
||||||
|
@ -55,12 +54,12 @@ int NullMixerManager::resumeAudio() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NullMixerManager::update() {
|
void NullMixerManager::update(uint8 callbackPeriod) {
|
||||||
if (_audioSuspended) {
|
if (_audioSuspended) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_callsCounter++;
|
_callsCounter++;
|
||||||
if ((_callsCounter % _callbackPeriod) == 0) {
|
if ((_callsCounter % callbackPeriod) == 0) {
|
||||||
assert(_mixer);
|
assert(_mixer);
|
||||||
_mixer->mixCallback(_samplesBuf, _samples);
|
_mixer->mixCallback(_samplesBuf, _samples);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
virtual ~NullMixerManager();
|
virtual ~NullMixerManager();
|
||||||
|
|
||||||
virtual void init();
|
virtual void init();
|
||||||
void update();
|
void update(uint8 callbackPeriod = 10);
|
||||||
|
|
||||||
virtual void suspendAudio();
|
virtual void suspendAudio();
|
||||||
virtual int resumeAudio();
|
virtual int resumeAudio();
|
||||||
|
@ -48,7 +48,6 @@ public:
|
||||||
private:
|
private:
|
||||||
uint32 _outputRate;
|
uint32 _outputRate;
|
||||||
uint32 _callsCounter;
|
uint32 _callsCounter;
|
||||||
uint8 _callbackPeriod;
|
|
||||||
uint32 _samples;
|
uint32 _samples;
|
||||||
uint8 *_samplesBuf;
|
uint8 *_samplesBuf;
|
||||||
};
|
};
|
||||||
|
|
|
@ -300,6 +300,11 @@ MODULE_OBJS += \
|
||||||
fs/n64/romfsstream.o
|
fs/n64/romfsstream.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(BACKEND),null)
|
||||||
|
MODULE_OBJS += \
|
||||||
|
mixer/null/null-mixer.o
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(BACKEND),openpandora)
|
ifeq ($(BACKEND),openpandora)
|
||||||
MODULE_OBJS += \
|
MODULE_OBJS += \
|
||||||
events/openpandora/op-events.o \
|
events/openpandora/op-events.o \
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "backends/saves/default/default-saves.h"
|
#include "backends/saves/default/default-saves.h"
|
||||||
#include "backends/timer/default/default-timer.h"
|
#include "backends/timer/default/default-timer.h"
|
||||||
#include "backends/events/default/default-events.h"
|
#include "backends/events/default/default-events.h"
|
||||||
|
#include "backends/mixer/null/null-mixer.h"
|
||||||
#include "backends/mutex/null/null-mutex.h"
|
#include "backends/mutex/null/null-mutex.h"
|
||||||
#include "backends/graphics/null/null-graphics.h"
|
#include "backends/graphics/null/null-graphics.h"
|
||||||
#include "audio/mixer_intern.h"
|
#include "audio/mixer_intern.h"
|
||||||
|
@ -65,7 +66,7 @@
|
||||||
#include "backends/fs/windows/windows-fs-factory.h"
|
#include "backends/fs/windows/windows-fs-factory.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class OSystem_NULL : public ModularMutexBackend, public ModularGraphicsBackend, Common::EventSource {
|
class OSystem_NULL : public ModularMutexBackend, public ModularMixerBackend, public ModularGraphicsBackend, Common::EventSource {
|
||||||
public:
|
public:
|
||||||
OSystem_NULL();
|
OSystem_NULL();
|
||||||
virtual ~OSystem_NULL();
|
virtual ~OSystem_NULL();
|
||||||
|
@ -78,21 +79,17 @@ public:
|
||||||
virtual void delayMillis(uint msecs);
|
virtual void delayMillis(uint msecs);
|
||||||
virtual void getTimeAndDate(TimeDate &t) const;
|
virtual void getTimeAndDate(TimeDate &t) const;
|
||||||
|
|
||||||
virtual Audio::Mixer *getMixer();
|
|
||||||
|
|
||||||
virtual void quit();
|
virtual void quit();
|
||||||
|
|
||||||
virtual void logMessage(LogMessageType::Type type, const char *message);
|
virtual void logMessage(LogMessageType::Type type, const char *message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Audio::MixerImpl *_mixer;
|
|
||||||
|
|
||||||
#ifdef POSIX
|
#ifdef POSIX
|
||||||
timeval _startTime;
|
timeval _startTime;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
OSystem_NULL::OSystem_NULL() : _mixer(0) {
|
OSystem_NULL::OSystem_NULL() {
|
||||||
#if defined(__amigaos4__)
|
#if defined(__amigaos4__)
|
||||||
_fsFactory = new AmigaOSFilesystemFactory();
|
_fsFactory = new AmigaOSFilesystemFactory();
|
||||||
#elif defined(__MORPHOS__)
|
#elif defined(__MORPHOS__)
|
||||||
|
@ -109,8 +106,6 @@ OSystem_NULL::OSystem_NULL() : _mixer(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
OSystem_NULL::~OSystem_NULL() {
|
OSystem_NULL::~OSystem_NULL() {
|
||||||
delete _mixer;
|
|
||||||
_mixer = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef POSIX
|
#ifdef POSIX
|
||||||
|
@ -136,19 +131,16 @@ void OSystem_NULL::initBackend() {
|
||||||
_eventManager = new DefaultEventManager(this);
|
_eventManager = new DefaultEventManager(this);
|
||||||
_savefileManager = new DefaultSaveFileManager();
|
_savefileManager = new DefaultSaveFileManager();
|
||||||
_graphicsManager = new NullGraphicsManager();
|
_graphicsManager = new NullGraphicsManager();
|
||||||
_mixer = new Audio::MixerImpl(22050);
|
_mixerManager = new NullMixerManager();
|
||||||
|
// Setup and start mixer
|
||||||
_mixer->setReady(false);
|
_mixerManager->init();
|
||||||
|
|
||||||
// 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 :).
|
|
||||||
|
|
||||||
BaseBackend::initBackend();
|
BaseBackend::initBackend();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OSystem_NULL::pollEvent(Common::Event &event) {
|
bool OSystem_NULL::pollEvent(Common::Event &event) {
|
||||||
((DefaultTimerManager *)getTimerManager())->checkTimers();
|
((DefaultTimerManager *)getTimerManager())->checkTimers();
|
||||||
|
((NullMixerManager *)_mixerManager)->update(1);
|
||||||
|
|
||||||
#ifdef POSIX
|
#ifdef POSIX
|
||||||
if (intReceived) {
|
if (intReceived) {
|
||||||
|
@ -202,11 +194,6 @@ void OSystem_NULL::getTimeAndDate(TimeDate &td) const {
|
||||||
td.tm_wday = t.tm_wday;
|
td.tm_wday = t.tm_wday;
|
||||||
}
|
}
|
||||||
|
|
||||||
Audio::Mixer *OSystem_NULL::getMixer() {
|
|
||||||
assert(_mixer);
|
|
||||||
return (Audio::Mixer *)_mixer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OSystem_NULL::quit() {
|
void OSystem_NULL::quit() {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue