<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
I see a *very* strange behavior of a function I've written.<br><br>I get data's for spectral analysis from either (1) a mic, or (2) a sound<br>file, or (3) from from jack input. Then the values of the spectrum are send<br>to a function that diplay it on a 3d graph (with openGL).<br><br>I have made possible to disable jack support : with a define, jack's code<br>is not included.<br><br>The very strange behavior is this : when jack is enabled, everything works<br>fine; when jack is disabled, displaying data from source is ok, BUT NOT FROM<br>AUDIO FILE, although these 2 path (input from audio file and input from<br>jack) are not related to each other...). When this happens, the audio file<br>is played; i can hear it, but it seems that no messages are passed to the<br>message handler that result in displaying the values of the sprectrum...<br><br>Everything is declared like this:<br> <br> AUDIOFREQ = 44100;<br> int interval = 100000000;<br> GstElement *src, *dec, *audioconvert, *conv, *spectrum, *sink;<br> GstBus *bus;<br> GstCaps *caps;<br> GstPad *audiopad;<br> GstStateChangeReturn ret;<br><br>// pipeline is initialized as a global variable since it is necessary in<br>many other functions<br><br>//Then here are the function to play the sound :<br><br> gst_init (NULL, NULL);<br> loop = g_main_loop_new(NULL, FALSE);<br> playing = 1;<br> <br> if (typeSource == 0) { // source == microphone <br> pipeline = gst_pipeline_new ("pipeline");<br> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<br> gst_bus_add_watch(bus, message_handler, NULL);<br> gst_object_unref(bus);<br> src = gst_element_factory_make ("alsasrc", "src");<br> audioconvert = gst_element_factory_make ("audioconvert", NULL);<br> g_assert (audioconvert);<br> spectrum = gst_element_factory_make ("spectrum", "spectrum");<br> g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80,<br>"interval", interval, NULL);<br> sink = gst_element_factory_make ("fakesink", "sink");<br> gst_bin_add_many (GST_BIN (pipeline), src, audioconvert, spectrum, sink,<br>NULL);<br> caps = gst_caps_new_simple ("audio/x-raw-int", "rate", G_TYPE_INT,<br>AUDIOFREQ, NULL);<br><br> if (!gst_element_link (src, audioconvert) ||<br> !gst_element_link_filtered (audioconvert, spectrum, caps) ||<br> !gst_element_link (spectrum, sink)) {<br> fprintf (stderr, "can't link elements\n");<br> exit (1);<br> }<br> gst_caps_unref (caps);<br> ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);<br> if (ret == GST_STATE_CHANGE_FAILURE) {<br> g_print ("Failed to start up pipeline!\n");<br> }<br> g_main_loop_run (loop);<br> gst_element_set_state (pipeline, GST_STATE_NULL);<br> gst_object_unref(pipeline);<br> }<br><br>else if (typeSource == 1) { // source == file read from disk<br> int positionTimeout = 0, seekTimeout = 0;<br> pipeline = gst_pipeline_new ("pipeline");<br> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<br> gst_bus_add_watch (bus, message_handler, NULL);<br> gst_object_unref (bus);<br><br> src = gst_element_factory_make ("filesrc", "source");<br> g_object_set (G_OBJECT (src), "location", sFile, NULL);<br> dec = gst_element_factory_make ("decodebin", "decoder");<br> g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad), NULL);<br> spectrum = gst_element_factory_make ("spectrum", "spectrum");<br> g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80,<br> "message", TRUE, "message-phase", TRUE, "interval", interval, NULL);<br> gst_bin_add_many (GST_BIN (pipeline), src, dec, NULL);<br> gst_element_link (src, dec);<br><br> audio = gst_bin_new ("audiobin");<br> conv = gst_element_factory_make ("audioconvert", "aconv");<br> audiopad = gst_element_get_static_pad (conv, "sink");<br> sink = gst_element_factory_make ("alsasink", "sink");<br> gst_bin_add_many (GST_BIN (audio), conv, spectrum, sink, NULL);<br> gst_element_link_many (conv, spectrum, sink, NULL);<br> gst_element_add_pad (audio,<br> gst_ghost_pad_new ("sink", audiopad));<br> gst_object_unref (audiopad);<br> gst_bin_add (GST_BIN (pipeline), audio);<br> <br> g_timeout_add (200, (GSourceFunc) cb_print_position, pipeline);<br> gst_element_set_state (pipeline, GST_STATE_PLAYING);<br> g_timeout_add (101, (GSourceFunc) seek_to_time, pipeline);<br><br> g_main_loop_run (loop);<br> gst_element_set_state (pipeline, GST_STATE_NULL);<br> gst_object_unref (GST_OBJECT (pipeline));<br> g_source_remove(positionTimeout);<br> g_source_remove(seekTimeout);<br> printf("stop playing\n");<br> filenames = filenames->next;<br> getFileName(); <br> }<br> else if (typeSource == 2) //source == JACK <br> {<br>#ifdef JACK // this include or not the code for jack's support<br> pipeline = gst_pipeline_new ("pipeline");<br> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<br> gst_bus_add_watch(bus, message_handler, NULL);<br> gst_object_unref(bus);<br> jack_client_t *src_client;<br> jack_status_t status;<br><br> src_client = jack_client_open ("src_client", JackNoStartServer, &status);<br>// create jack clients<br> if (src_client == NULL) {<br> if (status & JackServerFailed){<br> GtkWidget *pAbout;<br> //gchar *sSite = "";<br> pAbout = gtk_message_dialog_new (GTK_WINDOW(mainWindow),<br> GTK_DIALOG_MODAL,<br> GTK_MESSAGE_WARNING,<br> GTK_BUTTONS_OK,<br> "JACK server not running");<br> gtk_dialog_run(GTK_DIALOG(pAbout));<br> gtk_widget_destroy(pAbout);<br> SDL_Quit();<br> playing = 0;<br> }<br> else {<br> GtkWidget *pAbout;<br> gchar *sSite = "";<br> pAbout = gtk_message_dialog_new (GTK_WINDOW(mainWindow),<br> GTK_DIALOG_MODAL,<br> GTK_MESSAGE_WARNING,<br> GTK_BUTTONS_OK,<br> "jack_client_open() failed %s",<br> sSite);<br> gtk_dialog_run(GTK_DIALOG(pAbout));<br> gtk_widget_destroy(pAbout);<br> SDL_Quit();<br> exit(1);<br> } <br> }<br><br> src = gst_element_factory_make ("jackaudiosrc", NULL);<br> sink = gst_element_factory_make ("fakesink", NULL);<br> spectrum = gst_element_factory_make ("spectrum", "spectrum");<br> g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80,<br>"interval", interval, NULL);<br> gst_bin_add_many (GST_BIN (pipeline), src, spectrum, sink, NULL);<br><br> if (!gst_element_link (src, spectrum) ||<br> !gst_element_link (spectrum, sink)) {<br> fprintf (stderr, "can't link elements\n");<br> exit (1);<br> }<br> gst_element_set_state(pipeline, GST_STATE_PLAYING);<br> g_main_loop_run (loop);<br> gst_element_set_state (pipeline, GST_STATE_NULL);<br> gst_object_unref(pipeline);<br> #endif<br> }<br><br>Actually I have put a counter in the 'message handler' that is supposed to<br>be called; when I have problems, i can see that the counter stop after 48<br>calls.....<br><br>This is REALLY unbelivable, since the 3 parts of the functions (analyse from<br>mic or from file or from jack) have completely separate path........<br><br>Wold someone have a clue...?<br><br>Victor<br><br>--<br>View this message in context: <a href="http://gstreamer-devel.966125.n4.nabble.com/very-strange-behavior-related-to-jack-support-tp3469041p3469041.html" target="_blank">http://gstreamer-devel.966125.n4.nabble.com/very-strange-behavior-related-to-jack-support-tp3469041p3469041.html</a><br>Sent from the GStreamer-devel mailing list archive at Nabble.com.                                            </body>
</html>