aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorJoost Peters2008-06-29 23:36:44 +0000
committerJoost Peters2008-06-29 23:36:44 +0000
commit0a3d03797a29203d8ea3970b54a893d9ac53e20d (patch)
treee3bf528eef42c42ce04e8a6dd8972f6f8aada650 /backends/platform
parentf0df79bb88b61140999afd7af36bf25b34b35e46 (diff)
downloadscummvm-rg350-0a3d03797a29203d8ea3970b54a893d9ac53e20d.tar.gz
scummvm-rg350-0a3d03797a29203d8ea3970b54a893d9ac53e20d.tar.bz2
scummvm-rg350-0a3d03797a29203d8ea3970b54a893d9ac53e20d.zip
changes required for new mixer API + implement getMillis() and delayMillis() using gettimeofday() and usleep() resp.
svn-id: r32846
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/null/null.cpp33
1 files changed, 24 insertions, 9 deletions
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 <unistd.h>
+#include <sys/time.h>
+#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() {
}