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

jvprat at users.sourceforge.net jvprat at users.sourceforge.net
Mon Feb 16 17:23:49 CET 2009


Revision: 38373
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38373&view=rev
Author:   jvprat
Date:     2009-02-16 16:23:48 +0000 (Mon, 16 Feb 2009)

Log Message:
-----------
SCI: Changed pcm_device and timer "driver" functionality to use directly the ScummVM modules

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

Added Paths:
-----------
    scummvm/trunk/engines/sci/sfx/pcm_device.cpp
    scummvm/trunk/engines/sci/sfx/timer.cpp

Removed Paths:
-------------
    scummvm/trunk/engines/sci/sfx/pcm_device/
    scummvm/trunk/engines/sci/sfx/timer/

Modified: scummvm/trunk/engines/sci/include/gfx_driver.h
===================================================================
--- scummvm/trunk/engines/sci/include/gfx_driver.h	2009-02-16 15:50:27 UTC (rev 38372)
+++ scummvm/trunk/engines/sci/include/gfx_driver.h	2009-02-16 16:23:48 UTC (rev 38373)
@@ -393,46 +393,4 @@
 
 } gfx_driver_t;
 
-
-
-gfx_driver_t *
-gfx_find_driver(char *, char *name);
-/* Attempts to match a graphics driver to a name
-** Parameters: (char *) path: The path to search in
-**             (char *) name: The name of the graphics driver to look for
-**                            or NULL for the default driver
-** Returns   : (gfx_driver_t *) The resulting driver, or NULL if none
-**                              was found
-*/
-
-const char *
-gfx_get_driver_name(int nr);
-/* Retreives the name of the driver with the specified number
-** Parameters: (int) nr: Number of the driver
-**             (char *) The driver's name
-** Note that this function only makes sense within a loop or if nr=0, since
-** the result value is valid iff nr >= 0 AND there does not exist an nr'
-** with 0 <= nr' < nr so that gfx_get_driver_name(nr') == NULL.
-*/
-
-/*** Utility functions for set_parameter implementations */
-
-int
-string_truep(char *value);
-/* Tests whether a string expresses truth
-** Parameters: (char *) value: The value to test
-** Returns   : non-zero iff 'value' contans a string expressing something
-** along the lines of "yes"
-*/
-
-int
-string_falsep(char *value);
-/* Tests whether a string expresses falsehood
-** Parameters: (char *) value: The value to test
-** Returns   : non-zero iff 'value' contans a string expressing something
-** along the lines of "no"
-*/
-
-
-
 #endif /* !_SCI_GFX_DRIVER_H_ */

Modified: scummvm/trunk/engines/sci/include/sfx_pcm.h
===================================================================
--- scummvm/trunk/engines/sci/include/sfx_pcm.h	2009-02-16 15:50:27 UTC (rev 38372)
+++ scummvm/trunk/engines/sci/include/sfx_pcm.h	2009-02-16 16:23:48 UTC (rev 38373)
@@ -223,13 +223,4 @@
 ** Returns   : (int) zero iff no PCM device is available
 */
 
-sfx_pcm_device_t *
-sfx_pcm_find_device(char *name);
-/* Finds a PCM device by name
-** Parameters: (char *) name: Name of the PCM device to look for, or NULL to
-**                            use the system default
-** Returns   : (sfx_pcm_device_t *) The requested device, or NULL if no matching
-**                                  device could be found
-*/
-
 #endif /* !defined(_SFX_PCM_H_) */

Modified: scummvm/trunk/engines/sci/include/sfx_timer.h
===================================================================
--- scummvm/trunk/engines/sci/include/sfx_timer.h	2009-02-16 15:50:27 UTC (rev 38372)
+++ scummvm/trunk/engines/sci/include/sfx_timer.h	2009-02-16 16:23:48 UTC (rev 38373)
@@ -83,14 +83,4 @@
 	*/
 } sfx_timer_t;
 
-extern sfx_timer_t *
-	sfx_find_timer(char *name);
-/* Finds a timer by name
-** Parameters: (char *) name: Name of the timer to look up, or NULL for default
-** Returns   : (sfx_timer_t *) The timer of matching name, or NULL
-**                             if not found
-** This does not consider timers provided by PCM devices; there must be
-** retrieved externally.
-*/
-
 #endif /* !_FREESCI_SFX_TIMER_H_ */

Modified: scummvm/trunk/engines/sci/module.mk
===================================================================
--- scummvm/trunk/engines/sci/module.mk	2009-02-16 15:50:27 UTC (rev 38372)
+++ scummvm/trunk/engines/sci/module.mk	2009-02-16 16:23:48 UTC (rev 38373)
@@ -70,14 +70,14 @@
 	sfx/adlib.o \
 	sfx/core.o \
 	sfx/iterator.o \
+	sfx/pcm_device.o \
 	sfx/pcm-iterator.o \
 	sfx/songlib.o \
 	sfx/time.o \
+	sfx/timer.o \
 	sfx/device/devices.o \
 	sfx/mixer/mixers.o \
 	sfx/mixer/soft.o \
-	sfx/pcm_device/pcm_devices.o \
-	sfx/pcm_device/scummvm.o \
 	sfx/player/players.o \
 	sfx/player/polled.o \
 	sfx/player/realtime.o \
@@ -86,9 +86,7 @@
 	sfx/softseq/opl2.o \
 	sfx/softseq/pcspeaker.o \
 	sfx/softseq/SN76496.o \
-	sfx/softseq/softsequencers.o \
-	sfx/timer/timer_scummvm.o \
-	sfx/timer/timers.o
+	sfx/softseq/softsequencers.o
 
 # FIXME: The following is supposed to be a set of *temporary* hacks
 CXXFLAGS += -Wno-variadic-macros

Modified: scummvm/trunk/engines/sci/sfx/core.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/core.cpp	2009-02-16 15:50:27 UTC (rev 38372)
+++ scummvm/trunk/engines/sci/sfx/core.cpp	2009-02-16 16:23:48 UTC (rev 38373)
@@ -45,6 +45,8 @@
 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;
 
 Common::Mutex* callbackMutex;
 
@@ -445,7 +447,7 @@
 	}
 
 	mixer = sfx_pcm_find_mixer(NULL);
-	pcm_device = sfx_pcm_find_device(NULL);
+	pcm_device = &sfx_pcm_driver_scummvm;
 	player = sfx_find_player(NULL);
 
 
@@ -461,7 +463,7 @@
 		if (pcm_device && pcm_device->timer)
 			timer = pcm_device->timer;
 		else
-			timer = sfx_find_timer(NULL);
+			timer = &sfx_timer_scummvm;
 
 		if (!timer) {
 			fprintf(stderr, "[SFX] " __FILE__": Could not find timing mechanism\n");

Copied: scummvm/trunk/engines/sci/sfx/pcm_device.cpp (from rev 38371, scummvm/trunk/engines/sci/sfx/pcm_device/scummvm.cpp)
===================================================================
--- scummvm/trunk/engines/sci/sfx/pcm_device.cpp	                        (rev 0)
+++ scummvm/trunk/engines/sci/sfx/pcm_device.cpp	2009-02-16 16:23:48 UTC (rev 38373)
@@ -0,0 +1,60 @@
+#include "sci/include/sfx_time.h"
+#include "sci/include/sfx_pcm.h"
+#include "engines/engine.h"
+#include "sound/audiostream.h"
+#include "sound/mixer.h"
+
+
+static int pcmout_scummvm_framesize;
+static Audio::AppendableAudioStream * pcmout_scummvm_audiostream;
+static Audio::SoundHandle pcmout_scummvm_sound_handle;
+
+
+static int pcmout_scummvm_init(sfx_pcm_device_t *self) {
+	int pcmout_scummvm_audiostream_flags = Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_STEREO;
+
+#ifdef SCUMM_LITTLE_ENDIAN
+	pcmout_scummvm_audiostream_flags |= Audio::Mixer::FLAG_LITTLE_ENDIAN;
+#endif
+
+	self->buf_size = 2048 << 1;
+	self->conf.rate = g_engine->_mixer->getOutputRate();
+	self->conf.stereo = SFX_PCM_STEREO_LR;
+	self->conf.format = SFX_PCM_FORMAT_S16_NATIVE;
+	pcmout_scummvm_framesize = SFX_PCM_FRAME_SIZE(self->conf);
+
+	pcmout_scummvm_audiostream = Audio::makeAppendableAudioStream(self->conf.rate, pcmout_scummvm_audiostream_flags);
+	::g_engine->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &pcmout_scummvm_sound_handle, pcmout_scummvm_audiostream);
+
+	return SFX_OK;
+}
+
+static void pcmout_scummvm_exit(sfx_pcm_device_t *self) {
+}
+
+static int pcmout_scummvm_output(sfx_pcm_device_t *self, byte *buf, int count,
+                                 sfx_timestamp_t *timestamp) {
+
+	byte *__buf = new byte[count * pcmout_scummvm_framesize];
+
+	memcpy(__buf, buf, count * pcmout_scummvm_framesize);
+
+	pcmout_scummvm_audiostream->queueBuffer(__buf, count * pcmout_scummvm_framesize);
+
+	return SFX_OK;
+}
+
+
+sfx_pcm_device_t sfx_pcm_driver_scummvm = {
+	"ScummVM",
+	"0.1",
+	&pcmout_scummvm_init,
+	&pcmout_scummvm_exit,
+	NULL,
+	&pcmout_scummvm_output,
+	NULL,
+	{0, 0, 0},
+	0,
+	NULL,
+	NULL
+};


Property changes on: scummvm/trunk/engines/sci/sfx/pcm_device.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:mergeinfo
   + 
Added: svn:eol-style
   + native

Copied: scummvm/trunk/engines/sci/sfx/timer.cpp (from rev 38371, scummvm/trunk/engines/sci/sfx/timer/timer_scummvm.cpp)
===================================================================
--- scummvm/trunk/engines/sci/sfx/timer.cpp	                        (rev 0)
+++ scummvm/trunk/engines/sci/sfx/timer.cpp	2009-02-16 16:23:48 UTC (rev 38373)
@@ -0,0 +1,54 @@
+#include "common/timer.h"
+#include "engines/engine.h"
+#include "sci/include/sfx_timer.h"
+
+
+#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() {
+	scummvm_timer_callback = NULL;
+	return SFX_OK;
+}
+
+
+sfx_timer_t sfx_timer_scummvm = {
+	"ScummVM",
+	"0.1",
+	DELAY / 1000, 0,
+	NULL,
+	&scummvm_timer_start,
+	&scummvm_timer_stop,
+	0,
+	0
+};


Property changes on: scummvm/trunk/engines/sci/sfx/timer.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:mergeinfo
   + 
Added: svn:eol-style
   + native


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