[gst-devel] Specifying a different context for gst_bus_add_watch()

Karthik V karthikveeramani at gmail.com
Thu Nov 13 23:40:56 CET 2008


Thanks Wim.
I did the same but still didn't get the pipeline events. I confirmed that I
do get the events if I use the default context. My code now looks like this:

             GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipe));
if ( ( source = gst_bus_create_watch(bus) ) == NULL )
{
cout << "Unable to create sourced for bus watch";
}
cout << "Created source";
 g_source_set_callback(source, (GSourceFunc) BusHandler, data, NULL);
cout << "Set callback";
 busWatchId = g_source_attach(source, loopContext);
cout << "Attached source. Id = " << busWatchId;
 g_source_unref(source);
gst_object_unref (bus);


The handler function (I retained what I had earlier when I used
gst_bus_add_watch() ),
gboolean BusHandler(GstBus *bus, GstMessage *message, gpointer data)
{
 cout << "Handler called";
}


And elsewhere in the code,

             GMainContext *context = g_main_context_new();
             GMainLoop *loop = g_main_loop_new(context, false);
             g_main_loop_run(loop);




On Thu, Nov 13, 2008 at 10:33 AM, Wim Taymans <wim.taymans at gmail.com> wrote:

> On Thu, 2008-11-13 at 10:16 -0800, Karthik V wrote:
> > Hello All,
> >
> >
> > I would like to run my g_main_loop in a separate context, so did
> > something like this
> >
> >
> > GMainContext *c = g_main_context_new();
> > GMainLoop *l = g_main_loop_new(c, false);
> > g_main_loop_run(l);
> >
> >
> > My bus watch code goes like this:
> > GstBus *bus = gst_pipeline_get_bus(pipe);
> > gst_bus_add_watch(bus, BusHandler, NULL);
> >
> >
> > If I run my main loop in the default context (by passing NULL), I
> > receive call backs when there is an event on the bus. But after I
> > moved it to a new context, I don't get the events anymore. Looking
> > into the documentation, it looks like gst_bus_add_watch() adds watch
> > only to the default context.
> >
> >
> > Could someone tell me how to add watch to my own context, please?
>
> You want something like this:
>
>  GSource *source;
>
>  source = gst_bus_create_watch (bus);
>
>  g_source_set_callback (source, (GSourceFunc) func, user_data, notify);
>
>  /* now attach to the custom context c */
>  id = g_source_attach (source, c);
>  g_source_unref (source);
>  ...
>
> Wim
>
>
>
>
> >
> >
> > Thanks
> > Karthik
> >
> >
> > -------------------------------------------------------------------------
> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> > Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> > Grand prize is a trip for two to an Open Source event anywhere in the
> world
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > _______________________________________________ gstreamer-devel mailing
> list gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20081113/b50b3885/attachment.htm>


More information about the gstreamer-devel mailing list