Problem after Jack use

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem after Jack use

victor
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);
                }
}
Reply | Threaded
Open this post in threaded view
|

Re: Problem after Jack use

Tristan Matthews-2
I haven't tried your code, but this part is problematic:

2010/11/25 victor <[hidden email]>
               g_object_set (src, "connect", src_client, NULL);
 
The value of the "connect" property should not be a pointer to a jack_client, but rather one of:
                           (0): none             - Don't automatically connect ports to physical ports
                           (1): auto             - Automatically connect ports to physical ports
                           (2): auto-forced      - Automatically connect ports to as many physical ports as possible

It just changes how your jack client's ports will be connected to physical ports. The jack plugins creates their own clients so you don't need to create your own.

--
Tristan Matthews
email: [hidden email]
web: http://tristanswork.blogspot.com

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem after Jack use

victor
Thank you for your reply

I've changed it indeed,back to

g_object_set (src, "client", src_client, NULL);

but no change with the problem.....

thanks for the reply

Vic
Reply | Threaded
Open this post in threaded view
|

Re: Problem after Jack use

Tristan Matthews-2
Could you provide a link to the source for the entire program?

-t

2010/11/25 victor <[hidden email]>

Thank you for your reply

I've changed it indeed,back to

g_object_set (src, "client", src_client, NULL);

but no change with the problem.....

thanks for the reply

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

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
Tristan Matthews
email: [hidden email]
web: http://tristanswork.blogspot.com

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel