[Scummvm-cvs-logs] SF.net SVN: scummvm: [24446] scummvm/trunk/backends/platform/sdl

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Oct 22 18:05:12 CEST 2006


Revision: 24446
          http://svn.sourceforge.net/scummvm/?rev=24446&view=rev
Author:   fingolfin
Date:     2006-10-22 09:05:07 -0700 (Sun, 22 Oct 2006)

Log Message:
-----------
SDL backend: got rid of setTimerCallback and clearSoundCallback

Modified Paths:
--------------
    scummvm/trunk/backends/platform/sdl/sdl-common.h
    scummvm/trunk/backends/platform/sdl/sdl.cpp

Modified: scummvm/trunk/backends/platform/sdl/sdl-common.h
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl-common.h	2006-10-22 16:04:14 UTC (rev 24445)
+++ scummvm/trunk/backends/platform/sdl/sdl-common.h	2006-10-22 16:05:07 UTC (rev 24446)
@@ -135,7 +135,6 @@
 	// 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 @@
 	// 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 @@
 
 	Common::SaveFileManager *_savefile;
 	Audio::Mixer *_mixer;
+	
+	SDL_TimerID _timerID;
 	Common::TimerManager *_timer;
 
 

Modified: scummvm/trunk/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.cpp	2006-10-22 16:04:14 UTC (rev 24445)
+++ scummvm/trunk/backends/platform/sdl/sdl.cpp	2006-10-22 16:05:07 UTC (rev 24446)
@@ -46,9 +46,9 @@
 }
 #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 @@
 	// 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() {
+	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 @@
 	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 @@
 	return true;
 }
 
-void OSystem_SDL::clearSoundCallback() {
-	SDL_CloseAudio();
-}
-
 int OSystem_SDL::getOutputSampleRate() const {
 	return _samplesPerSec;
 }


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