diff options
author | Max Horn | 2006-10-22 16:05:07 +0000 |
---|---|---|
committer | Max Horn | 2006-10-22 16:05:07 +0000 |
commit | f4d8920f2bb14bb56d4a1120c3c7e5a71178992c (patch) | |
tree | 4ed45c18b259e3ca8546b54c2b47994bdac244c1 /backends/platform/sdl | |
parent | b635a2fb842ab4d5d9a048dfe52b731469e0c28d (diff) | |
download | scummvm-rg350-f4d8920f2bb14bb56d4a1120c3c7e5a71178992c.tar.gz scummvm-rg350-f4d8920f2bb14bb56d4a1120c3c7e5a71178992c.tar.bz2 scummvm-rg350-f4d8920f2bb14bb56d4a1120c3c7e5a71178992c.zip |
SDL backend: got rid of setTimerCallback and clearSoundCallback
svn-id: r24446
Diffstat (limited to 'backends/platform/sdl')
-rw-r--r-- | backends/platform/sdl/sdl-common.h | 7 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.cpp | 30 |
2 files changed, 20 insertions, 17 deletions
diff --git a/backends/platform/sdl/sdl-common.h b/backends/platform/sdl/sdl-common.h index aeb9c5bf37..41e33b5b5d 100644 --- a/backends/platform/sdl/sdl-common.h +++ b/backends/platform/sdl/sdl-common.h @@ -135,7 +135,6 @@ public: // Set function that generates samples typedef void (*SoundProc)(void *param, byte *buf, int len); virtual bool setSoundCallback(SoundProc proc, void *param); // overloaded by CE backend - void clearSoundCallback(); virtual Audio::Mixer *getMixer(); // Poll CD status @@ -154,10 +153,6 @@ public: // Quit virtual void quit(); // overloaded by CE backend - - // Add a callback timer - typedef int (*TimerProc)(int interval); - void setTimerCallback(TimerProc callback, int timer); virtual Common::TimerManager *getTimerManager(); // Mutex handling @@ -373,6 +368,8 @@ protected: Common::SaveFileManager *_savefile; Audio::Mixer *_mixer; + + SDL_TimerID _timerID; Common::TimerManager *_timer; diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index b4677eac0f..3e2416a791 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -46,9 +46,9 @@ int __stdcall WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpC } #endif -static int timer_handler(int t) { - DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager(); - return tm->handler(t); +static Uint32 timer_handler(Uint32 interval, void *param) { + ((DefaultTimerManager *)param)->handler(); + return interval; } int main(int argc, char *argv[]) { @@ -196,8 +196,15 @@ void OSystem_SDL::initBackend() { // Create and hook up the timer manager, if none exists yet (we check for // this to allow subclasses to provide their own). if (_timer == 0) { + // TODO: We could implement a custom SDLTimerManager by using + // SDL_AddTimer. That might yield better timer resolution, but it would + // also change the semantics of a timer: Right now, ScummVM timers + // *never* run in parallel, due to the way they are implemented. If we + // switched to SDL_AddTimer, each timer might run in a separate thread. + // Unfortunately, not all our code is prepared for that, so we can't just + // switch. But it's a long term goal to do just that! _timer = new DefaultTimerManager(); - setTimerCallback(&timer_handler, 10); + _timerID = SDL_AddTimer(10, &timer_handler, _timer); } OSystem::initBackend(); @@ -240,10 +247,17 @@ OSystem_SDL::OSystem_SDL() } OSystem_SDL::~OSystem_SDL() { + SDL_RemoveTimer(_timerID); + SDL_CloseAudio(); + free(_dirtyChecksums); free(_currentPalette); free(_cursorPalette); free(_mouseData); + + delete _savefile; + delete _mixer; + delete _timer; } uint32 OSystem_SDL::getMillis() { @@ -254,10 +268,6 @@ void OSystem_SDL::delayMillis(uint msecs) { SDL_Delay(msecs); } -void OSystem_SDL::setTimerCallback(TimerProc callback, int timer) { - SDL_SetTimer(timer, (SDL_TimerCallback) callback); -} - Common::TimerManager *OSystem_SDL::getTimerManager() { assert(_timer); return _timer; @@ -445,10 +455,6 @@ bool OSystem_SDL::setSoundCallback(SoundProc proc, void *param) { return true; } -void OSystem_SDL::clearSoundCallback() { - SDL_CloseAudio(); -} - int OSystem_SDL::getOutputSampleRate() const { return _samplesPerSec; } |