[Scummvm-cvs-logs] SF.net SVN: scummvm:[38947] scummvm/trunk/engines/sci

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Feb 28 07:14:42 CET 2009


Revision: 38947
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38947&view=rev
Author:   fingolfin
Date:     2009-02-28 06:14:42 +0000 (Sat, 28 Feb 2009)

Log Message:
-----------
SCI: Get rid of extra layer around our timer manager

Modified Paths:
--------------
    scummvm/trunk/engines/sci/module.mk
    scummvm/trunk/engines/sci/sfx/core.cpp
    scummvm/trunk/engines/sci/sfx/sfx_pcm.h

Removed Paths:
-------------
    scummvm/trunk/engines/sci/sfx/sfx_timer.h
    scummvm/trunk/engines/sci/sfx/timer.cpp

Modified: scummvm/trunk/engines/sci/module.mk
===================================================================
--- scummvm/trunk/engines/sci/module.mk	2009-02-28 00:21:08 UTC (rev 38946)
+++ scummvm/trunk/engines/sci/module.mk	2009-02-28 06:14:42 UTC (rev 38947)
@@ -71,7 +71,6 @@
 	sfx/pcm-iterator.o \
 	sfx/songlib.o \
 	sfx/time.o \
-	sfx/timer.o \
 	sfx/device/devices.o \
 	sfx/mixer/soft.o \
 	sfx/player/players.o \

Modified: scummvm/trunk/engines/sci/sfx/core.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/core.cpp	2009-02-28 00:21:08 UTC (rev 38946)
+++ scummvm/trunk/engines/sci/sfx/core.cpp	2009-02-28 06:14:42 UTC (rev 38947)
@@ -26,14 +26,13 @@
 /* Sound subsystem core: Event handler, sound player dispatching */
 
 #include "sci/tools.h"
-#include "sci/sfx/sfx_timer.h"
 #include "sci/sfx/sfx_iterator_internal.h"
 #include "sci/sfx/sfx_player.h"
 #include "sci/sfx/mixer.h"
 #include "sci/sfx/sci_midi.h"
 
-#include "common/mutex.h"
 #include "common/system.h"
+#include "common/timer.h"
 
 namespace Sci {
 
@@ -46,8 +45,6 @@
 static sfx_player_t *player = NULL;
 sfx_pcm_mixer_t *mixer = NULL;
 static sfx_pcm_device_t *pcm_device = NULL;
-static sfx_timer_t *timer = NULL;
-extern sfx_timer_t sfx_timer_scummvm;
 extern sfx_pcm_device_t sfx_pcm_driver_scummvm;
 
 int sfx_pcm_available() {
@@ -355,19 +352,19 @@
 	return 0;
 }
 
-static void _sfx_timer_callback(void *data) {
-	if (timer) {
-		/* First run the player, to give it a chance to fill
-		** the audio buffer  */
+#define FREQ 60
+#define DELAY (1000000 / FREQ)
 
-		if (player)
-			player->maintenance();
 
-		assert(timer);
+static void _sfx_timer_callback(void *data) {
+	/* First run the player, to give it a chance to fill
+	** the audio buffer  */
 
-		if (mixer)
-			mixer->process(mixer);
-	}
+	if (player)
+		player->maintenance();
+
+	if (mixer)
+		mixer->process(mixer);
 }
 
 void sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) {
@@ -421,7 +418,7 @@
 	if (!resmgr) {
 		sciprintf("[SFX] Warning: No resource manager present, cannot initialise player\n");
 		player = NULL;
-	} else if (player->init(resmgr, timer ? timer->delay_ms : 0)) {
+	} else if (player->init(resmgr, DELAY / 1000)) {
 		sciprintf("[SFX] Song player '%s' reported error, disabled\n", player->name);
 		player = NULL;
 	}
@@ -440,21 +437,9 @@
 	// still being initialized.
 
 	if (pcm_device || (player && player->maintenance)) {
-		timer = &sfx_timer_scummvm;
-
-		if (!timer) {
-			fprintf(stderr, "[SFX] " __FILE__": Could not find timing mechanism\n");
-			fprintf(stderr, "[SFX] Disabled sound support\n");
-			pcm_device = NULL;
-			player = NULL;
-			mixer = NULL;
-			return;
-		}
-
-		if (timer->init(_sfx_timer_callback, NULL)) {
+		if (!g_system->getTimerManager()->installTimerProc(&_sfx_timer_callback, DELAY, NULL)) {
 			warning("[SFX] " __FILE__": Timer failed to initialize");
 			warning("[SFX] Disabled sound support");
-			timer = NULL;
 			pcm_device = NULL;
 			player = NULL;
 			mixer = NULL;
@@ -465,15 +450,12 @@
 }
 
 void sfx_exit(sfx_state_t *self) {
-	if (timer && timer->exit())
-		warning("[SFX] Timer reported error on exit");
+	g_system->getTimerManager()->removeTimerProc(&_sfx_timer_callback);
 
 	// The timer API guarantees no more callbacks are running or will be
 	// run from this point onward, so we can now safely exit the mixer and
 	// player.
 
-	timer = NULL;
-
 #ifdef DEBUG_SONG_API
 	fprintf(stderr, "[sfx-core] Uninitialising\n");
 #endif

Modified: scummvm/trunk/engines/sci/sfx/sfx_pcm.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/sfx_pcm.h	2009-02-28 00:21:08 UTC (rev 38946)
+++ scummvm/trunk/engines/sci/sfx/sfx_pcm.h	2009-02-28 06:14:42 UTC (rev 38947)
@@ -27,7 +27,6 @@
 #define SCI_SFX_SFX_PCM_H
 
 #include "sci/sfx/sfx_core.h"
-#include "sci/sfx/sfx_timer.h"
 #include "sci/sfx/sfx_time.h"
 
 namespace Sci {

Deleted: scummvm/trunk/engines/sci/sfx/sfx_timer.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/sfx_timer.h	2009-02-28 00:21:08 UTC (rev 38946)
+++ scummvm/trunk/engines/sci/sfx/sfx_timer.h	2009-02-28 06:14:42 UTC (rev 38947)
@@ -1,56 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef SCI_SFX_SFX_TIMER_H
-#define SCI_SFX_SFX_TIMER_H
-
-#include "sci/sfx/sfx_core.h"
-
-namespace Sci {
-
-struct sfx_timer_t {
-	int delay_ms; /* Approximate delay (in milliseconds) between calls */
-
-	int (*init)(void (*callback)(void *data), void *data);
-	/* Initializes the timer
-	** Parameters: (void* -> void) callback:
-	**                                   'data' must contain the next argument:
-	**             (void *) data: Must always be passed to the callback
-	** Returns   : (int) SFX_OK on success, SFX_ERROR on failure
-	** This does not start the timer yet, it just specifies and initializes it.
-	** This function is called exactly once (provided that the timer is used at all).
-	*/
-
-	int (*exit)();
-	/* Stops the timer
-	** Returns   : (int) SFX_OK on success, SFX_ERROR on failure
-	** All resources allocated with the timer should be freed as an effect
-	** of this.
-	*/
-};
-
-} // End of namespace Sci
-
-#endif // SCI_SFX_SFX_TIMER_H

Deleted: scummvm/trunk/engines/sci/sfx/timer.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/timer.cpp	2009-02-28 00:21:08 UTC (rev 38946)
+++ scummvm/trunk/engines/sci/sfx/timer.cpp	2009-02-28 06:14:42 UTC (rev 38947)
@@ -1,78 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/timer.h"
-#include "engines/engine.h"
-#include "sci/sfx/sfx_timer.h"
-
-namespace Sci {
-
-#define FREQ 60
-#define DELAY (1000000 / FREQ)
-
-typedef void (*scummvm_timer_callback_t)(void *);
-static scummvm_timer_callback_t scummvm_timer_callback = NULL;
-static void *scummvm_timer_callback_data = NULL;
-extern ::Engine *g_engine;
-
-void scummvm_timer_update_internal(void *ptr) {
-	if (scummvm_timer_callback)
-		scummvm_timer_callback(scummvm_timer_callback_data);
-}
-
-int scummvm_timer_start(void (*func)(void *), void *data) {
-	if (scummvm_timer_callback) {
-		fprintf(stderr,
-		        "Error: Attempt to initialize gametick timer more than once\n");
-		return SFX_ERROR;
-	}
-
-	if (!func) {
-		fprintf(stderr,
-		        "Error: Attempt to initialize gametick timer w/o callback\n");
-		return SFX_ERROR;
-	}
-
-	scummvm_timer_callback = func;
-	scummvm_timer_callback_data = data;
-
-	::g_engine->getTimerManager()->installTimerProc(&scummvm_timer_update_internal, DELAY, NULL);
-	return SFX_OK;
-}
-
-int scummvm_timer_stop() {
-	::g_engine->getTimerManager()->removeTimerProc(&scummvm_timer_update_internal);
-	scummvm_timer_callback = NULL;
-	return SFX_OK;
-}
-
-
-sfx_timer_t sfx_timer_scummvm = {
-	DELAY / 1000,
-	&scummvm_timer_start,
-	&scummvm_timer_stop
-};
-
-} // End of namespace Sci


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