<div dir="ltr">Hi Peter,<div style>at least on iOS, the whole thing boils down to the patch below.</div><div style>I added two initialization functions to libpd_init, the first sys_findprogdir for finding the pd binary directory (actually to initialize the symbol sys_libdir which can also be done manually), and second sys_startgui to initialize the data structures for networking. That this fundamental functionality is mangled with GUI-related code is not pretty and should certainly be refactored (in Pd proper).</div>
<div style>The polling happens in the PROCESS macro, after audio has been processed. I think using a sleep time of 0 it should be non-blocking, but it would definitely be better (in sys_domicrosleep) to avoid calling the system function Sleep (only matters for WIN32) for timeouts of 0. Maybe Miller should review that.</div>
<div style>I am not sure whether using memory management functions in an audio callback is a problem - it shouldn&#39;t, as Miller certainly had a look at that. This happens because the incoming networking data is stored in dynamically allocated binbuf structures.</div>
<div style>That&#39;s my report - it works for me now.</div><div style>all the best,</div><div style>gr~~~</div>































<div style><br></div><div style>----------</div><div style><br></div><div style><div>--- a/libpd_wrapper/z_libpd.c</div><div>+++ b/libpd_wrapper/z_libpd.c</div><div>@@ -20,6 +20,8 @@</div><div> #include &quot;g_all_guis.h&quot;</div>
<div> </div><div> void pd_init(void);</div><div>+void sys_findprogdir(char *progname);</div><div>+int sys_startgui(const char *guipath);</div><div> </div><div> t_libpd_printhook libpd_printhook = NULL;</div><div> t_libpd_banghook libpd_banghook = NULL;</div>
<div>@@ -65,7 +67,9 @@ void libpd_init(void) {</div><div>   sys_nmidiout = 0;</div><div>   sys_time = 0;</div><div>   pd_init();</div><div>+  sys_findprogdir(&quot;&quot;);                   /* set sys_progname, guipath */</div>
<div>   libpdreceive_setup();</div><div>+  sys_startgui(sys_libdir-&gt;s_name);   /* start the gui */</div><div>   sys_set_audio_api(API_DUMMY);</div><div>   sys_searchpath = NULL;</div><div> }</div><div>@@ -128,6 +132,7 @@ static const t_sample sample_to_short = SHRT_MAX,</div>
<div>       } \</div><div>     } \</div><div>   } \</div><div>+  sys_microsleep(0); \</div><div>   return 0;</div><div> </div><div> int libpd_process_short(int ticks, short *inBuffer, short *outBuffer) {</div><div><br></div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/1/21 Peter Brinkmann <span dir="ltr">&lt;<a href="mailto:peter.brinkmann@googlemail.com" target="_blank">peter.brinkmann@googlemail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><br></div>Hi Thomas,<br></div>There&#39;s no mailing list for libpd, but there is a forum: <a href="http://createdigitalnoise.com/categories/pd-everywhere" target="_blank">http://createdigitalnoise.com/categories/pd-everywhere</a> In any case, this does seem like a question for pd-dev, so we&#39;re in the right place :)<br>

<br></div>About sys_microsleep, there are two potential problems that I&#39;m concerned about about: The first is that it might block, but that doesn&#39;t seem to be the case since it&#39;s being called in the audio callback. The second concern is that I&#39;m not sure how this low-level access to network sockets might behave on Android (which requires special permissions for internet access). I&#39;m expecting that it&#39;ll be okay, but we need to make sure. Please let me know how it goes!<br>

</div>Best,<br></div>     Peter<br><br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 21, 2013 at 6:43 AM, Thomas Grill <span dir="ltr">&lt;<a href="mailto:gr@grrrr.org" target="_blank">gr@grrrr.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Ok Peter, let&#39;s move this over to pd-dev. There is no specific libpd list, is it?<div><br></div><div>

I have now quickly looked into what the context of the socket polling is like in Pd.</div>
<div>It is even done in the audio callback (via sys_pollgui) if this is enabled, so it can&#39;t really have serious side effects. As far as i have seen libpd also uses a callback based approach for audio, at least for iOS. Maybe introducing a sys_microsleep(0,1) in the audio callback does the trick? I will test that now.</div>


<div>That said, i&#39;m totally unaware of the details of other implementations.</div><div><br></div><div>all the best,</div><div>gr~~~~</div><div> </div></div><div><div><div class="gmail_extra">
<br><br>
<div class="gmail_quote">2013/1/21 Peter Brinkmann <span dir="ltr">&lt;<a href="mailto:peter.brinkmann@googlemail.com" target="_blank">peter.brinkmann@googlemail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div dir="ltr"><div><div><br></div>Hi Thomas,<br>I have to admit that I didn&#39;t realize that netreceive requires an extra polling step. So, I&#39;m afraid that netreceive is currently broken.<br><br>The question is what to do about this. I took a quick look at sys_domicrosleep and didn&#39;t immediately see how it works. I wouldn&#39;t mind integrating it into libpd somehow, but I want to be sure that there won&#39;t be any weird side effects. This seems slightly off-topic for pd-list. Shall we talk about this on pd-dev?<br>



Cheers,<br></div>     Peter<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Sun, Jan 20, 2013 at 6:42 PM, Thomas Grill <span dir="ltr">&lt;<a href="mailto:gr@grrrr.org" target="_blank">gr@grrrr.org</a>&gt;</span> wrote:<br>



</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hi all,<div>i am new to libpd and i have run into problems using netreceive on ios 5.1.</div>


<div>While netsend works perfectly, netreceive doesn&#39;t work at all. Senders can connect to the receiving socket, but netreceive wouldn&#39;t spit out any data.</div>

<div>Looking at the code, it seems to me that the polling of the net sockets (done in plain Pure Data in s_inter.c / sys_domicrosleep) is not called in libpd at all. I also couldn&#39;t find a different place where this is done.</div>




<div>Does that mean that libpd doesn&#39;t currently service incoming socket data?</div><div><br></div><div><br></div><div>Thanks for clarification, all the best,</div><div>gr~~~</div><span><font color="#888888"><div>
<div>
<br></div>-- <br>Thomas Grill<br><a href="http://grrrr.org" target="_blank">http://grrrr.org</a>
</div></font></span></div>
<br></div></div>_______________________________________________<br>
<a href="mailto:Pd-list@iem.at" target="_blank">Pd-list@iem.at</a> mailing list<br>
UNSUBSCRIBE and account-management -&gt; <a href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Thomas Grill<br><a href="http://grrrr.org" target="_blank">http://grrrr.org</a>
</div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Thomas Grill<br><a href="http://grrrr.org">http://grrrr.org</a>
</div>