[gst-devel] Problem after Jack use

victor delvauxbernard at yahoo.fr
Thu Nov 25 15:14:57 CET 2010


Hello to all

I've made a spectrum analyser, that can capture the sound from the mic and
display the spectrum on a SDL window. Source is  either form ALSA
("alsasrc") or JACK ("jackaudiosrc").

This works fine with ALSA, then with JACK also. But when i go back to ALSA,
i have interrupts and pause in the signal (the display of the spectrum)
displayed on the SDL window.

I post here the function calling Gstreamer, either with jack ("jack == 1")
or without jack. The only solution I have to have it work with ALSA afetr
JACK's use is to restart the application.....

Does anyone have a clue?

Thank you

Victor

void sdlWindow()
{
    AUDIOFREQ = 44100;
    interval = 15000000;
    reprendre = 1;
    GstElement *bin;
    GstElement *src, *dec, *audioconvert, *conv, *spectrum, *sink;
    GstBus *bus;
    GstCaps *caps;
    GstPad *audiopad;

    SDL_Init(SDL_INIT_VIDEO); // init SDL parameters
    ecran = SDL_SetVideoMode(LARGEUR_FENETRE+100, HAUTEUR_FENETRE, 32,
SDL_HWSURFACE | SDL_DOUBLEBUF);
    SDL_WM_SetCaption("Real-Time Spectral Analysis",NULL);
    imprimeLigne(); // some lines and scale for the SDL window
    imprimeEchelle();
    SDL_Flip(ecran);

    gst_init (NULL, NULL);
    loop = g_main_loop_new(NULL, FALSE);
    playing = 1;
            
    if (jack == 1) // if Jack is selected
	{
		bin = gst_pipeline_new ("bin");
   		bus = gst_element_get_bus (bin);
    		gst_bus_add_watch(bus, message_handler, NULL);
    		gst_object_unref(bus);
		jack_client_t *src_client;
		jack_status_t status;
		GstStateChangeReturn ret;

		  /* create jack clients */
		  src_client = jack_client_open ("src_client", JackNoStartServer,
&status);
		  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",
				sSite);
			gtk_dialog_run(GTK_DIALOG(pAbout));
		     	gtk_widget_destroy(pAbout);
			TTF_Quit();
			SDL_Quit();
			exit(1);
			}
		    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",
				sSite);
			gtk_dialog_run(GTK_DIALOG(pAbout));
		     	gtk_widget_destroy(pAbout);
			TTF_Quit();
			SDL_Quit();
			exit(1);
			}		      
		  }

		src = gst_element_factory_make ("jackaudiosrc", NULL);
	    	sink = gst_element_factory_make ("fakesink", NULL);
	    	g_object_set (src, "connect", src_client, 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 (bin), 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(bin, GST_STATE_PLAYING);
    		g_main_loop_run (loop);
		gst_element_set_state (bin, GST_STATE_NULL);
    		gst_object_unref(bin);
		}
}

-- 
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Problem-after-Jack-use-tp3059016p3059016.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.




More information about the gstreamer-devel mailing list