<font size="2"><br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;"></font><div style="font-family: arial,helvetica,sans-serif;" class="gmail_quote"><font size="2">2010/11/18 Sebastian Dröge <span dir="ltr">&lt;<a href="mailto:sebastian.droege@collabora.co.uk">sebastian.droege@collabora.co.uk</a>&gt;</span><br>
</font><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div class="h5"><font size="2">On Thu, 2010-11-18 at 11:51 -0200, Tiago Katcipis wrote:<br>

&gt;<br>
&gt;<br>
&gt; 2010/11/18 Sebastian Dröge &lt;<a href="mailto:sebastian.droege@collabora.co.uk">sebastian.droege@collabora.co.uk</a>&gt;<br>
&gt;         On Thu, 2010-11-18 at 10:07 -0200, Tiago Katcipis wrote:<br>
&gt;         &gt;<br>
&gt;         &gt;<br>
&gt;         &gt; On Tue, Nov 16, 2010 at 6:28 PM, David Schleef<br>
&gt;         &lt;<a href="mailto:ds@entropywave.com">ds@entropywave.com</a>&gt;<br>
&gt;         &gt; wrote:<br>
&gt;         &gt;         On Tue, Nov 16, 2010 at 10:28:23AM -0200, Tiago<br>
&gt;         Katcipis<br>
&gt;         &gt;         wrote:<br>
&gt;         &gt;         &gt; but to make use of the async API it is needed a<br>
&gt;         GMainLoop,<br>
&gt;         &gt;         and there is the<br>
&gt;         &gt;         &gt; problem :-), gst plugins are not aware if there is<br>
&gt;         a main<br>
&gt;         &gt;         loop running, it<br>
&gt;         &gt;         &gt; is not mandatory.<br>
&gt;         &gt;<br>
&gt;         &gt;         Elements that require a GMainLoop create a thread<br>
&gt;         and run a<br>
&gt;         &gt;         GMainLoop<br>
&gt;         &gt;         there.  One example is souphttpsrc.<br>
&gt;         &gt;<br>
&gt;<br>
&gt;         &gt; That approach doesn&#39;t bring the same hazards of<br>
&gt;         gst_bus_poll ?<br>
&gt;<br>
&gt;         No, if you want to use a GMainLoop inside your element you<br>
&gt;         also have to<br>
&gt;         create a new GMainContext for it (which is then driven by your<br>
&gt;         private<br>
&gt;         main loop). There&#39;s no need to run a GLib main loop on the<br>
&gt;         default<br>
&gt;         context or any other ugly things.<br>
&gt;<br>
&gt; hmm, that&#39;s interesting, why gst_bus_poll use the default context<br>
&gt; them?<br><br></font>

</div></div><font size="2">Because it was meant to be used by application that have a main loop on<br>
the default context and that want to continue other things in that main<br>
loop while waiting for a message on the bus.<br></font></blockquote><div><br>hmm and in that case using a
<a href="http://library.gnome.org/devel/glib/unstable/glib-The-Main-Event-Loop.html#g-main-context-push-thread-default" class="link" title="g_main_context_push_thread_default ()"><code class="function">g_main_context_push_thread_default()</code></a> to run poll stuff on other context and them
<a href="http://library.gnome.org/devel/glib/unstable/glib-The-Main-Event-Loop.html#g-main-context-pop-thread-default" class="link" title="g_main_context_pop_thread_default ()"><code class="function">g_main_context_pop_thread_default()</code></a> to restore the main context would prevent other things from happening on the default context, right?<br>
 </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><font size="2"></font>
<div class="im"><font size="2"><br>
&gt; i never used GMainLoop with different contexts, not pretty sure of how<br>
&gt; it works. If the main loop on the default context is running (the<br>
&gt; application is using it), and i create my main loop with a different<br>
&gt; context inside the plugin, to which main loop will go the async result<br>
&gt; of the GIO call ? (I&#39;m going to read more about multiple main loops<br>
&gt; with different contexts)<br><br></font>

</div><font size="2">GIO uses the thread default main context of the thread that started the<br>
async operation (see the GMainContext docs) and signals are emitted to<br>
any main loop running on that main context.<br></font></blockquote><div><font size="2"><br>Thanks for the help Sebastian, i read</font><font size="2"> g_main_context_get_thread_default ()</font><font size="2"> and</font><font size="2"> g_main_context_push_thread_default ()</font><font size="2"> doc and helped a lot to understand better how could this work.<br>
 </font></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><font size="2"><br>
&gt; if GIO would work with this approach it seems to be an interesting<br>
&gt; solution to start using the GIO async API instead of the sync API, and<br>
&gt; it would be possible to mount the file for the user, making the use of<br>
&gt; giosrc/sink pretty easier.<br><br></font>

</div><font size="2">That&#39;s all possible but the problem with that is, that a) the state<br>
change from NULL-&gt;READY happens synchronous in GStreamer and that b)<br>
basesrc wants to know the file size in READY already, otherwise it will<br>
never activate random access mode.<br><br></font></blockquote><div><br>Well if it must be synchronous running the main loop on another Thread does not to seem to be an option. What is done on gst_bus_poll seems to fit here:<br>
<br>1 - the caller on the set_state will get blocked on the call<br>2 - inside the call we mount the file and do all the stuff async using the main_loop_run to block the caller<br>3 - after everything is done we get out of the run call and give to the basesrc the file size<br>
<br>this way we can use the async GIO API, mount the file for the user giving a &quot;sync&quot; operation to the set_state caller. But this approach is pretty simple, if you guys still not implemented it... it is because it has something pretty bad on it... it is because the same problem that can happen on gst_bus_poll?<br>
 </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><font size="2"><br>------------------------------
</font>
<font size="2">------------------------------</font><font size="2">------------------<br>
Beautiful is writing same markup. Internet Explorer 9 supports<br>
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 &amp; L3.<br>
Spend less time writing and  rewriting code and more time creating great<br>
experiences on the web. Be a part of the beta today<br><a href="http://p.sf.net/sfu/msIE9-sfdev2dev" target="_blank">http://p.sf.net/sfu/msIE9-sfdev2dev</a><br>______________________________</font>
<font size="2">_________________<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>
<br></font>


</blockquote></div><font size="2"><br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;" clear="all"><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">-- </span><br style="font-family: arial,helvetica,sans-serif;">
<span style="font-family: arial,helvetica,sans-serif;"><a href="http://www.getgnulinux.org/windows">http://www.getgnulinux.org/windows</a></span><br style="font-family: arial,helvetica,sans-serif;"></font>