[Scummvm-cvs-logs] SF.net SVN: scummvm: [32846] scummvm/trunk/backends/platform/null/null.cpp
joostp at users.sourceforge.net
joostp at users.sourceforge.net
Mon Jun 30 01:36:45 CEST 2008
Revision: 32846
http://scummvm.svn.sourceforge.net/scummvm/?rev=32846&view=rev
Author: joostp
Date: 2008-06-29 16:36:44 -0700 (Sun, 29 Jun 2008)
Log Message:
-----------
changes required for new mixer API + implement getMillis() and delayMillis() using gettimeofday() and usleep() resp.
Modified Paths:
--------------
scummvm/trunk/backends/platform/null/null.cpp
Modified: scummvm/trunk/backends/platform/null/null.cpp
===================================================================
--- scummvm/trunk/backends/platform/null/null.cpp 2008-06-29 19:59:16 UTC (rev 32845)
+++ scummvm/trunk/backends/platform/null/null.cpp 2008-06-29 23:36:44 UTC (rev 32846)
@@ -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 @@
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 @@
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 @@
}
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 @@
return true;
}
-int OSystem_NULL::getOutputSampleRate() const {
- return 22050;
-}
-
void OSystem_NULL::quit() {
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list