How do I know when the GMainLoop has started running?

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

How do I know when the GMainLoop has started running?

tanmay.ambre
My GMainLoop starts and runs in a new thread.

GMainLoop* main_loop;

void start()
{
   main_loop= g_main_loop_new (NULL, FALSE);///Creating a main loop
/***
----
---Pipeline creation and initialization
****/
        bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline_sound_capture));
        gst_bus_add_watch(bus, *bus_call, main_loop);
        gst_object_unref (bus);

        g_main_loop_run (main_loop);///The main loop starts running
/////Unreffing the pipeline
/////

}


To stop my main loop I am using
g_main_loop_quit(m_loop)

My question is what signal I should intercept to know m main loop is running?
If i call g_main_loop_quit(m_loop)
before  g_main_loop_run (main_loop)
 the quit command never executes.

Any help ?

Tanmay Ambre


Reply | Threaded
Open this post in threaded view
|

Re: How do I know when the GMainLoop has started running?

Stefan Sauer
On 06/18/2012 01:21 PM, tanmay.ambre wrote:

> My GMainLoop starts and runs in a new thread.
>
> GMainLoop* main_loop;
>
> void start()
> {
>    main_loop= g_main_loop_new (NULL, FALSE);///Creating a main loop
> /***
> ----
> ---Pipeline creation and initialization
> ****/
> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline_sound_capture));
> gst_bus_add_watch(bus, *bus_call, main_loop);
> gst_object_unref (bus);
>
>         g_main_loop_run (main_loop);///The main loop starts running
> /////Unreffing the pipeline
> /////
>
> }
>
>
> To stop my main loop I am using
> g_main_loop_quit(m_loop)
>
> My question is what signal I should intercept to know m main loop is
> running?
> If i call g_main_loop_quit(m_loop)
> before  g_main_loop_run (main_loop)
>  the quit command never executes.
This is not gstreamer related. Anyway you can check using
g_main_loop_is_running().

Stefan

>
> Any help ?
>
> Tanmay Ambre
>
>
>
>
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-do-I-know-when-the-GMainLoop-has-started-running-tp4655313.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

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How do I know when the GMainLoop has started running?

tanmay.ambre
I did that used g_main_loop_isrunning to test

But that means I have to run it in a loop to keep check when it starts running.

I searched on forums for Glib forums and trying to find a better way of doing it.

Thanks
Tanmay


Reply | Threaded
Open this post in threaded view
|

Re: How do I know when the GMainLoop has started running?

Tim-Philipp Müller-2
On Tue, 2012-06-19 at 08:48 -0700, tanmay.ambre wrote:

> I did that used g_main_loop_isrunning to test
>
> But that means I have to run it in a loop to keep check when it starts
> running.
>
> I searched on forums for Glib forums and trying to find a better way of
> doing it.

You could attach an idle source (g_idle_source_new() for a custom main
context, g_idle_add() for the default glib main context). When your
callback gets called, the main loop has started running. Return FALSE
from the callback to be called only once (i.e. never again).

Cheers
 -Tim

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel