Thanks Wim.<div><br></div><div>I did the same but still didn&#39;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>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span>GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipe));</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>if ( ( source = gst_bus_create_watch(bus) ) == NULL )</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>cout &lt;&lt; &quot;Unable to create sourced for bus watch&quot;;</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>cout &lt;&lt; &quot;Created source&quot;;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>g_source_set_callback(source, (GSourceFunc) BusHandler, data, NULL);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>cout &lt;&lt; &quot;Set callback&quot;;</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>busWatchId = g_source_attach(source, loopContext);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>cout &lt;&lt; &quot;Attached source. Id = &quot; &lt;&lt; busWatchId;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>g_source_unref(source);</div><div><span class="Apple-tab-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>
&nbsp;cout &lt;&lt; &quot;Handler called&quot;;</div><div>}</div><div><br></div><div><br></div><div>And elsewhere in the code,</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span>GMainContext *context = g_main_context_new();</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span>GMainLoop *loop = g_main_loop_new(context, false);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span>g_main_loop_run(loop);</div>
<div><br></div></div><div><br></div><div><br><br><div class="gmail_quote">On Thu, Nov 13, 2008 at 10:33 AM, Wim Taymans <span dir="ltr">&lt;<a href="mailto:wim.taymans@gmail.com">wim.taymans@gmail.com</a>&gt;</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 class="Wj3C7c">On Thu, 2008-11-13 at 10:16 -0800, Karthik V wrote:<br>
&gt; Hello All,<br>
&gt;<br>
&gt;<br>
&gt; I would like to run my g_main_loop in a separate context, so did<br>
&gt; something like this<br>
&gt;<br>
&gt;<br>
&gt; GMainContext *c = g_main_context_new();<br>
&gt; GMainLoop *l = g_main_loop_new(c, false);<br>
&gt; g_main_loop_run(l);<br>
&gt;<br>
&gt;<br>
&gt; My bus watch code goes like this:<br>
&gt; GstBus *bus = gst_pipeline_get_bus(pipe);<br>
&gt; gst_bus_add_watch(bus, BusHandler, NULL);<br>
&gt;<br>
&gt;<br>
&gt; If I run my main loop in the default context (by passing NULL), I<br>
&gt; receive call backs when there is an event on the bus. But after I<br>
&gt; moved it to a new context, I don&#39;t get the events anymore. Looking<br>
&gt; into the documentation, it looks like gst_bus_add_watch() adds watch<br>
&gt; only to the default context.<br>
&gt;<br>
&gt;<br>
&gt; Could someone tell me how to add watch to my own context, please?<br>
<br>
</div></div>You want something like this:<br>
<br>
 &nbsp;GSource *source;<br>
<br>
 &nbsp;source = gst_bus_create_watch (bus);<br>
<br>
 &nbsp;g_source_set_callback (source, (GSourceFunc) func, user_data, notify);<br>
<br>
 &nbsp;/* now attach to the custom context c */<br>
 &nbsp;id = g_source_attach (source, c);<br>
 &nbsp;g_source_unref (source);<br>
 &nbsp;...<br>
<br>
Wim<br>
<br>
<br>
<br>
<br>
&gt;<br>
&gt;<br>
&gt; Thanks<br>
&gt; Karthik<br>
&gt;<br>
&gt;<br>
&gt; -------------------------------------------------------------------------<br>
&gt; This SF.Net email is sponsored by the Moblin Your Move Developer&#39;s challenge<br>
&gt; Build the coolest Linux based applications with Moblin SDK &amp; win great prizes<br>
&gt; Grand prize is a trip for two to an Open Source event anywhere in the world<br>
&gt; <a href="http://moblin-contest.org/redirect.php?banner_id=100&amp;url=/" target="_blank">http://moblin-contest.org/redirect.php?banner_id=100&amp;url=/</a><br>
&gt; _______________________________________________ gstreamer-devel mailing list <a href="mailto:gstreamer-devel@lists.sourceforge.net">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&#39;s challenge<br>
Build the coolest Linux based applications with Moblin SDK &amp; 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&amp;url=/" target="_blank">http://moblin-contest.org/redirect.php?banner_id=100&amp;url=/</a><br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.sourceforge.net">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>