[g-a-devel]gnopernicus patch ...
- From: Michael Meeks <michael ximian com>
- To: Draghi Puterity <mp baum de>
- Cc: accessibility mailing list <gnome-accessibility-devel gnome org>
- Subject: [g-a-devel]gnopernicus patch ...
- Date: 12 Dec 2002 09:58:52 +0000
Hi Draghi,
Here's the patch I committed - I also fixed the Gnome 2.2 build, and
removed the project global 'i' variable, so a few more cleans.
HTH,
Michael.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnopernicus/ChangeLog,v
retrieving revision 1.97
diff -u -p -u -r1.97 ChangeLog
--- ChangeLog 11 Dec 2002 09:00:49 -0000 1.97
+++ ChangeLog 12 Dec 2002 09:59:10 -0000
@@ -1,3 +1,13 @@
+2002-12-12 Michael Meeks <michael ximian com>
+
+ * speech/test/Makefile.am (INCLUDES): add
+ $(LIBSRS_*) to get -pthread in Gnome 2.2
+
+2002-12-09 Michael Meeks <michael ximian com>
+
+ * speech/libsrs/spgs.c: substantially re-write
+ lots of changes, killed daft globals etc.
+
2002-12-11 Remus Draica <rd baum ro>
* srcore/srpres.c:
Index: speech/libsrs/spgs.c
===================================================================
RCS file: /cvs/gnome/gnopernicus/speech/libsrs/spgs.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 spgs.c
--- speech/libsrs/spgs.c 11 Nov 2002 19:15:59 -0000 1.12
+++ speech/libsrs/spgs.c 12 Dec 2002 09:59:10 -0000
@@ -30,210 +30,162 @@
/* __ GLOBALS ___ */
-CORBA_Environment env;
-Bonobo_ServerInfoList *servers;
-int last_driver = 0;
-gint choice = 0;
-CORBA_string driver_name, driver_version;
-CORBA_string synth_name, synth_version;
-GNOME_Speech_Speaker speaker;
-GNOME_Speech_VoiceInfoList *voices;
-GNOME_Speech_SynthesisDriver curr_driver;
-GNOME_Speech_SynthesisDriver *drivers;
-gint i;
+static GNOME_Speech_Speaker speaker;
+static GNOME_Speech_SynthesisDriver *drivers;
/* __ API ___ */
-void gs_say (SRS_VOICE *voice, const char *text)
+void
+gs_say (SRS_VOICE *voice, const char *text)
{
+ CORBA_Environment ev;
+ CORBA_exception_init (&ev);
+
+ /* FIXME: unutterably broken design */
if (speaker)
- {
- GNOME_Speech_Speaker_say (speaker,
- text,
- &env);
- }
+ GNOME_Speech_Speaker_say (speaker, text, &ev);
else
- {
fprintf (stderr, "Can't say, no speaker available.\n");
- }
+
+ CORBA_exception_free (&ev);
}
-void gs_speak (SRS_VOICE *voice, SRS_TEXT *text )
+void
+gs_speak (SRS_VOICE *voice, SRS_TEXT *text )
{
- if (last_driver)
- {
- /* !!! TBI !!! find the driver coresponding to this voice */
- curr_driver = drivers[last_driver - 1]; /* THE PROBLEM IT WAS 0 */
-
- /* !!! TBI !!! map all voice parameter to the acutal voice here */
-
- if (text)
- {
- if (voice)
- {
- gs_say (voice, text->Text); /* !!! TEMP ONLY, need something better
!!! */
- }
- else
- {
- gs_say (voice, text->Text); /* !!! some default voice */
- }
- /* NOTE: yes, I know that both branches of the if ar the same. It's
only temporary. */
- }
- }
+ /* FIXME: unutterably broken design */
+ if (speaker && text)
+ gs_say (voice, text->Text);
}
-void gs_shut_up()
+void
+gs_shut_up (void)
{
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ /* FIXME: unutterably broken design */
if (speaker)
- {
- GNOME_Speech_Speaker_stop (speaker,
- &env);
- }
-}
+ GNOME_Speech_Speaker_stop (speaker, &ev);
+ CORBA_exception_free (&ev);
+}
-int gs_init (TTS_ENGINE *engine)
+int
+gs_init (TTS_ENGINE *engine)
{
- int i;
+ int i;
+ int last_driver = 0;
+ CORBA_Environment ev;
+ Bonobo_ServerInfoList *servers;
+ CORBA_string synth_name, synth_version;
+ CORBA_string driver_name, driver_version;
+
+ CORBA_exception_init (&ev);
- CORBA_exception_init (&env);
if (!bonobo_init (NULL, NULL) )
- {
- fprintf (stderr, "Can't initialize Bonobo.\n");
- }
+ fprintf (stderr, "Can't initialize Bonobo.\n");
- servers = bonobo_activation_query ("repo_ids.has
('IDL:GNOME/Speech/SynthesisDriver:0.2')",
- NULL,
- &env);
- if (env._major != CORBA_NO_EXCEPTION)
- {
- fprintf (stderr, "Couldn't activate GNOME-SPEECH server.\n");
- }
+ servers = bonobo_activation_query (
+ "repo_ids.has ('IDL:GNOME/Speech/SynthesisDriver:0.2')",
+ NULL, &ev);
+
+ if (BONOBO_EX (&ev))
+ fprintf (stderr, "Couldn't activate GNOME-SPEECH server.\n");
if (!servers)
- {
- fprintf (stderr, "No GNOME-SPEECH drivers found.\n");
- }
+ fprintf (stderr, "No GNOME-SPEECH drivers found.\n");
- drivers = (GNOME_Speech_SynthesisDriver*) g_malloc0(servers->_length *
sizeof(GNOME_Speech_SynthesisDriver));
+ drivers = g_new0 (GNOME_Speech_SynthesisDriver, servers->_length);
- for (i = 0; i < servers->_length; i++)
- {
- CORBA_Object obj;
- GNOME_Speech_SynthesisDriver driver;
- Bonobo_ServerInfo *info;
-
- info = &servers->_buffer[i];
-
- printf ("Atempting to activate %s.\n", info->iid);
-
- obj = bonobo_activation_activate_from_id ((const
Bonobo_ActivationID)info->iid,
- 0,
- NULL,
- &env);
- if (CORBA_Object_is_nil (obj, &env) )
- {
- fprintf (stderr, "Activation of server %s failed.\n", info->iid);
- }
- else
- {
+ for (i = 0; i < servers->_length; i++) {
+ int voice_idx;
+ CORBA_Object obj;
+ Bonobo_ServerInfo *info;
+ GNOME_Speech_VoiceInfoList *voices;
+ GNOME_Speech_SynthesisDriver driver;
- fprintf (stderr, "Activation of server %s succeeded.\n", info->iid);
+ info = &servers->_buffer[i];
- driver = (GNOME_Speech_SynthesisDriver) obj;
+ printf ("Atempting to activate %s.\n", info->iid);
- /*if (GNOME_Speech_SynthesisDriver_driverInit (driver, &env))*/
- if (driver)/*an information to verify if the driver init was ok*/
- {
- drivers[last_driver++] = driver;
-
- driver_name = GNOME_Speech_SynthesisDriver__get_driverName (driver,
&env);
- if (!BONOBO_EX (&env))
- {
- printf ("Driver name: %s\n", driver_name);
- CORBA_free (driver_name);
- }
-/*This is not so important and it's time consuming I think*/
-/*
- driver_version = GNOME_Speech_SynthesisDriver__get_driverVersion
(driver, &env);
- if (!BONOBO_EX (&env))
- {
- printf ("Driver version: %s\n", driver_version);
- CORBA_free (driver_version);
- }
- synth_name = GNOME_Speech_SynthesisDriver__get_synthesizerName
(driver, &env);
- if (!BONOBO_EX (&env))
- {
- printf ("Synthesizer name: %s\n", synth_name);
- CORBA_free (synth_name);
- }
- synth_version = GNOME_Speech_SynthesisDriver__get_synthesizerVersion
(driver, &env);
- if (!BONOBO_EX (&env))
- {
- printf ("Synthesizer Version: %s\n", synth_version);
- CORBA_free (synth_version);
+ CORBA_exception_init (&ev);
+
+ obj = bonobo_activation_activate_from_id (
+ info->iid, 0, NULL, &ev);
+
+ if (BONOBO_EX (&ev) || obj == CORBA_OBJECT_NIL) {
+ fprintf (stderr, "Activation of server %s failed.\n", info->iid);
+ continue;
}
-*/
- /* Display list of voices */
+ fprintf (stderr, "Activation of server %s succeeded.\n", info->iid);
+
+ driver = (GNOME_Speech_SynthesisDriver) obj;
- voices = GNOME_Speech_SynthesisDriver_getAllVoices (driver, &env);
+ drivers [last_driver++] = driver;
- if (!voices)
- {
- printf ("No voices!!!.\n");
- /************RETURN SMTH/EXIT***********/
- exit(0);
+ driver_name = GNOME_Speech_SynthesisDriver__get_driverName (driver,
&ev);
+ if (!BONOBO_EX (&ev)) {
+ printf ("Driver name: %s\n", driver_name);
+ CORBA_free (driver_name);
+ } else
+ CORBA_exception_free (&ev);
+
+ /* Display list of voices */
+ voices = GNOME_Speech_SynthesisDriver_getAllVoices (driver, &ev);
+ if (BONOBO_EX (&ev) || !voices || !voices->_length) {
+ printf ("No voices!!!.\n");
+ continue;
}
+
/*this information will be needed for the GUI to display it to user,
so the user can chose a peculiar voice. Maybe some gconf keys
created for
them ?!?*/
/* fprintf (stderr,"\n Name of the voices : \n");
- for (i = 0; i < voices->_length; i++)
- {
- GNOME_Speech_Speaker_setParameterValue (speaker,
- "voice",
- i+1,
- &env);
- fprintf (stderr, "%d. %s\n", i+1, voices->_buffer[i].name);
- }
+ for (i = 0; i < voices->_length; i++) {
+ GNOME_Speech_Speaker_setParameterValue (speaker,
+ "voice", i, &ev);
+ fprintf (stderr, "%d. %s\n", i+1, voices->_buffer[i].name);
+ }
*/
- /*select a voice, a default should be required here
- choice = 1 ;
- */
- /*to be sure that the chosen voice is approriate, verify*/
- if (choice < 1 || choice > voices->_length)
- choice = 1;
-
- speaker = GNOME_Speech_SynthesisDriver_createSpeaker (driver,
- &voices->_buffer[choice-1],
- &env);
- /* GNOME_Speech_Speaker_say (speaker, "Welcome", &env);*/
+ /* FIXME: select a voice, a default should be required here */
+ voice_idx = 0;
+ if (voice_idx < 0 || voice_idx >= voices->_length)
+ continue;
+
+ speaker = GNOME_Speech_SynthesisDriver_createSpeaker (
+ driver, &voices->_buffer[voice_idx], &ev);
+ /* GNOME_Speech_Speaker_say (speaker, "Welcome", &ev);*/
+
+ CORBA_free (voices);
+ voices = NULL;
+
+ if (BONOBO_EX (&ev) || !speaker)
+ printf ("Driver initialization failed :-(.\n");
+ }
+ CORBA_free (servers);
+ servers = NULL;
- }
- else
- printf ("Driver initialization failed :-(.\n");
-
- }
- }
- if (last_driver)
- {
- /* fill the engine structure with the actual functions */
+ if (last_driver) {
+ /* fill the engine structure with the actual functions */
engine->ShutUp = gs_shut_up;
engine->Speak = gs_speak;
engine->Terminate = gs_terminate;
}
+
return last_driver;
}
-void gs_terminate ()
+void
+gs_terminate (void)
{
- gs_shut_up();
-/* CORBA_free(voices); ????*/
-/* CORBA_free(drivers);*/
- CORBA_free(servers);
-
+ gs_shut_up ();
+
+ g_free (drivers);
+ drivers = NULL;
}
Index: speech/libsrs/spgs.h
===================================================================
RCS file: /cvs/gnome/gnopernicus/speech/libsrs/spgs.h,v
retrieving revision 1.4
diff -u -p -u -r1.4 spgs.h
--- speech/libsrs/spgs.h 11 Oct 2002 10:58:44 -0000 1.4
+++ speech/libsrs/spgs.h 12 Dec 2002 09:59:10 -0000
@@ -28,7 +28,7 @@
#include "srspeech.h"
int gs_init (TTS_ENGINE *engine);
-void gs_terminate ();
+void gs_terminate (void);
void gs_say (SRS_VOICE *voice, const char *string);
-void gs_shut_up ();
+void gs_shut_up (void);
#endif
Index: speech/test/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnopernicus/speech/test/Makefile.am,v
retrieving revision 1.3
diff -u -p -u -r1.3 Makefile.am
--- speech/test/Makefile.am 1 Nov 2002 14:32:57 -0000 1.3
+++ speech/test/Makefile.am 12 Dec 2002 09:59:10 -0000
@@ -2,9 +2,10 @@ NULL=
noinst_PROGRAMS = tester
-tester_SOURCES = tester.c
+tester_SOURCES = tester.c
+tester_LDFLAGS = $(LIBSRS_LIBS)
-INCLUDES = -I$(srcdir)/../libsrs
+INCLUDES = -I$(srcdir)/../libsrs $(LIBSRS_CFLAGS)
LDADD = ../libsrs/libsrs.la
--
mmeeks gnu org <><, Pseudo Engineer, itinerant idiot
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]