]> err.no Git - mapper/commitdiff
Use g_debug instead of g_printf. Check elements directly after creating.
authorKaj-Michael Lang <milang@tal.org>
Fri, 29 Feb 2008 09:20:23 +0000 (11:20 +0200)
committerKaj-Michael Lang <milang@tal.org>
Fri, 29 Feb 2008 09:20:23 +0000 (11:20 +0200)
src/speak.c

index bd9a27ee076a04c0937be5bbbea37b9f77a669d6..190cd95d3a8b751d9f823aae92a4bada9685924f 100644 (file)
@@ -72,7 +72,7 @@ switch (GST_MESSAGE_TYPE (msg)) {
                gst_message_parse_error (msg, &err, &debug);
                g_free (debug);
 
-               g_printf ("Error: %s\n", err->message);
+               g_debug("Error: %s", err->message);
                g_error_free (err);
 
                speak_stop();
@@ -80,10 +80,10 @@ switch (GST_MESSAGE_TYPE (msg)) {
                speak_ok=FALSE;
        break;
        case GST_MESSAGE_STATE_CHANGED:
-       g_print ("GST: state changed\n");
+       g_debug("GST: state changed");
        break;
     default:
-               g_printf("GST: %s\n", gst_message_type_get_name(GST_MESSAGE_TYPE(msg)));
+               g_debug("GST: %s", gst_message_type_get_name(GST_MESSAGE_TYPE(msg)));
        break;
        }
 return TRUE;
@@ -93,8 +93,14 @@ static gboolean
 speak_create_pipeline(void)
 {
 ge.pipeline=gst_pipeline_new("pipeline");
+g_assert(ge.pipeline);
+
 ge.src=gst_element_factory_make("appsrc", "source");
+g_assert(ge.src);
+
 ge.caps=gst_element_factory_make("capsfilter", "caps");
+g_assert(ge.caps);
+
 ge.srccaps=gst_caps_new_simple ("audio/x-raw-int",
                        "depth", G_TYPE_INT, 16,
                        "signed", G_TYPE_BOOLEAN, TRUE, 
@@ -102,15 +108,12 @@ ge.srccaps=gst_caps_new_simple ("audio/x-raw-int",
                        "rate", G_TYPE_INT, erate,
                        "channels", G_TYPE_INT, 1,
                        NULL);
+g_assert(ge.srccaps);
 
 ge.queue=gst_element_factory_make("queue", "queue");
-ge.sink=gst_element_factory_make(AUDIO_SINK, "sink");
-
-g_assert(ge.pipeline);
-g_assert(ge.src);
-g_assert(ge.caps);
-g_assert(ge.srccaps);
 g_assert(ge.queue);
+
+ge.sink=gst_element_factory_make(AUDIO_SINK, "sink");
 g_assert(ge.sink);
 
 g_object_set(ge.caps, "caps", ge.srccaps, NULL);
@@ -145,12 +148,12 @@ gchar *data;
 g_print("Adding buffer %d\n", numsamples);
 
 if (wav==NULL) {
-       gst_app_src_end_of_stream (GST_APP_SRC (ge.src));
+       gst_app_src_end_of_stream(GST_APP_SRC (ge.src));
        return 0;
 } else if (numsamples>0) {
        numsamples=numsamples*2;
        data=g_memdup(wav, numsamples);
-       buf=gst_app_buffer_new (data, numsamples, espeak_buffer_free, data);
+       buf=gst_app_buffer_new(data, numsamples, espeak_buffer_free, data);
        gst_buffer_set_caps(buf, ge.srccaps);
        gst_app_src_push_buffer(GST_APP_SRC (ge.src), buf);
 }
@@ -183,6 +186,7 @@ if (speak_create_pipeline()==FALSE)
 bus=gst_pipeline_get_bus(GST_PIPELINE (ge.pipeline));
 g_assert(bus);
 gst_bus_add_watch(bus, bus_call, NULL);
+
 espeak_ok=TRUE;
 return TRUE;
 }
@@ -208,7 +212,7 @@ if (speaking==TRUE)
        return FALSE;
 #endif
 
-g_printf("Speaking: %s (%d)\n", text, strlen(text));
+g_debug("Speaking: %s (%d)\n", text, strlen(text));
 espeak_Synth(text, strlen(text)+1, 0, POS_CHARACTER, 0, espeakCHARS_UTF8, NULL, NULL);
 
 if (speaking!=TRUE) {
@@ -258,7 +262,7 @@ if (!fork()) {
        /* We are the fork child.  Synthesize the voice. */
        sound_noise();
        sleep(1);
-       printf("%s %s\n", _voice_synth_path, text);
+       g_debug("%s %s\n", _voice_synth_path, text);
 #ifdef WITH_ESPEAK
        execl(_voice_synth_path, _voice_synth_path, "-t", text, (char *)NULL);
 #else