I noticed that the BusHandler function does get called a few times in the beginning, but the 'end of stream' event fails to trigger a callback, for some reason. If I replace g_main_context_new() by g_main_context_default(), I get callback during when end of stream occurs.<div>
<br></div><div>Does anyone have any idea what could be wrong with EOS alone?</div><div><br></div><div><br></div><div><br><div class="gmail_quote">On Thu, Nov 13, 2008 at 2:40 PM, Karthik V <span dir="ltr"><<a href="mailto:karthikveeramani@gmail.com">karthikveeramani@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Thanks Wim.<div><br></div><div>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:</div>
<div><br></div><div><div> <span style="white-space:pre">        </span>GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipe));</div>
<div><span style="white-space:pre">                </span>if ( ( source = gst_bus_create_watch(bus) ) == NULL )</div><div><span style="white-space:pre">                </span>{</div><div><span style="white-space:pre">                        </span>cout << "Unable to create sourced for bus watch";</div>
<div><span style="white-space:pre">                </span>}</div><div><span style="white-space:pre">                </span>cout << "Created source";</div><div><span style="white-space:pre">                </span></div>
<div><span style="white-space:pre">                </span>g_source_set_callback(source, (GSourceFunc) BusHandler, data, NULL);</div><div><span style="white-space:pre">                </span>cout << "Set callback";</div>
<div><span style="white-space:pre">                </span></div><div><span style="white-space:pre">                </span>busWatchId = g_source_attach(source, loopContext);</div><div><span style="white-space:pre">                </span>cout << "Attached source. Id = " << busWatchId;</div>
<div><span style="white-space:pre">        </span></div><div><span style="white-space:pre">                </span>g_source_unref(source);</div><div><span style="white-space:pre">                </span>gst_object_unref (bus);</div>
<div><br></div><div><br></div><div>The handler function (I retained what I had earlier when I used gst_bus_add_watch() ),</div><div>gboolean BusHandler(GstBus *bus, GstMessage *message, gpointer data)</div><div>{</div><div>
cout << "Handler called";</div><div>}</div><div><br></div><div><br></div><div>And elsewhere in the code,</div><div><br></div><div> <span style="white-space:pre">        </span>GMainContext *context = g_main_context_new();</div>
<div> <span style="white-space:pre">        </span>GMainLoop *loop = g_main_loop_new(context, false);</div><div> <span style="white-space:pre">        </span>g_main_loop_run(loop);</div>
<div><br></div></div><div><div></div><div class="Wj3C7c"><div><br></div><div><br><br><div class="gmail_quote">On Thu, Nov 13, 2008 at 10:33 AM, Wim Taymans <span dir="ltr"><<a href="mailto:wim.taymans@gmail.com" target="_blank">wim.taymans@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>On Thu, 2008-11-13 at 10:16 -0800, Karthik V wrote:<br>
> Hello All,<br>
><br>
><br>
> I would like to run my g_main_loop in a separate context, so did<br>
> something like this<br>
><br>
><br>
> GMainContext *c = g_main_context_new();<br>
> GMainLoop *l = g_main_loop_new(c, false);<br>
> g_main_loop_run(l);<br>
><br>
><br>
> My bus watch code goes like this:<br>
> GstBus *bus = gst_pipeline_get_bus(pipe);<br>
> gst_bus_add_watch(bus, BusHandler, NULL);<br>
><br>
><br>
> If I run my main loop in the default context (by passing NULL), I<br>
> receive call backs when there is an event on the bus. But after I<br>
> moved it to a new context, I don't get the events anymore. Looking<br>
> into the documentation, it looks like gst_bus_add_watch() adds watch<br>
> only to the default context.<br>
><br>
><br>
> Could someone tell me how to add watch to my own context, please?<br>
<br>
</div></div>You want something like this:<br>
<br>
GSource *source;<br>
<br>
source = gst_bus_create_watch (bus);<br>
<br>
g_source_set_callback (source, (GSourceFunc) func, user_data, notify);<br>
<br>
/* now attach to the custom context c */<br>
id = g_source_attach (source, c);<br>
g_source_unref (source);<br>
...<br>
<br>
Wim<br>
<br>
<br>
<br>
<br>
><br>
><br>
> Thanks<br>
> Karthik<br>
><br>
><br>
> -------------------------------------------------------------------------<br>
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge<br>
> Build the coolest Linux based applications with Moblin SDK & win great prizes<br>
> Grand prize is a trip for two to an Open Source event anywhere in the world<br>
> <a href="http://moblin-contest.org/redirect.php?banner_id=100&url=/" target="_blank">http://moblin-contest.org/redirect.php?banner_id=100&url=/</a><br>
> _______________________________________________ gstreamer-devel mailing list <a href="mailto:gstreamer-devel@lists.sourceforge.net" target="_blank">gstreamer-devel@lists.sourceforge.net</a> <a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
<br>
<br>
-------------------------------------------------------------------------<br>
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge<br>
Build the coolest Linux based applications with Moblin SDK & win great prizes<br>
Grand prize is a trip for two to an Open Source event anywhere in the world<br>
<a href="http://moblin-contest.org/redirect.php?banner_id=100&url=/" target="_blank">http://moblin-contest.org/redirect.php?banner_id=100&url=/</a><br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.sourceforge.net" target="_blank">gstreamer-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>