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