From 0a3d03797a29203d8ea3970b54a893d9ac53e20d Mon Sep 17 00:00:00 2001 From: Joost Peters Date: Sun, 29 Jun 2008 23:36:44 +0000 Subject: changes required for new mixer API + implement getMillis() and delayMillis() using gettimeofday() and usleep() resp. svn-id: r32846 --- backends/platform/null/null.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'backends/platform') diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp index 0c75bd1fcb..463e9d7b2d 100644 --- a/backends/platform/null/null.cpp +++ b/backends/platform/null/null.cpp @@ -28,11 +28,16 @@ #if defined(USE_NULL_DRIVER) +#ifdef UNIX +#include +#include +#endif + #include "common/rect.h" #include "backends/saves/default/default-saves.h" #include "backends/timer/default/default-timer.h" -#include "sound/mixer.h" +#include "sound/mixer_intern.h" /* * Include header files needed for the getFilesystemFactory() method. @@ -50,9 +55,10 @@ class OSystem_NULL : public OSystem { protected: Common::SaveFileManager *_savefile; - Audio::Mixer *_mixer; + Audio::MixerImpl *_mixer; Common::TimerManager *_timer; + timeval _startTime; public: OSystem_NULL(); @@ -106,8 +112,6 @@ public: typedef void (*SoundProc)(void *param, byte *buf, int len); virtual bool setSoundCallback(SoundProc proc, void *param); - virtual void clearSoundCallback(); - virtual int getOutputSampleRate() const; virtual void quit(); @@ -139,9 +143,14 @@ OSystem_NULL::~OSystem_NULL() { void OSystem_NULL::initBackend() { _savefile = new DefaultSaveFileManager(); - _mixer = new Audio::Mixer(); + _mixer = new Audio::MixerImpl(this); _timer = new DefaultTimerManager(); + _mixer->setOutputRate(22050); + _mixer->setReady(false); + + gettimeofday(&_startTime, NULL); + // Note that both the mixer and the timer manager are useless // this way; they need to be hooked into the system somehow to // be functional. Of course, can't do that in a NULL backend :). @@ -260,10 +269,20 @@ bool OSystem_NULL::pollEvent(Common::Event &event) { } uint32 OSystem_NULL::getMillis() { +#ifdef UNIX + timeval curTime; + gettimeofday(&curTime, NULL); + return (uint32)(((curTime.tv_sec - _startTime.tv_sec) * 1000) + \ + ((curTime.tv_usec - _startTime.tv_usec) / 1000)); +#else return 0; +#endif } void OSystem_NULL::delayMillis(uint msecs) { +#ifdef UNIX + usleep(msecs * 1000); +#endif } OSystem::MutexRef OSystem_NULL::createMutex(void) { @@ -283,10 +302,6 @@ bool OSystem_NULL::setSoundCallback(SoundProc proc, void *param) { return true; } -int OSystem_NULL::getOutputSampleRate() const { - return 22050; -} - void OSystem_NULL::quit() { } -- cgit v1.2.3