<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr">All,</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr"><br></div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr">I'm working on a basic asynchronous read/write program to understand the API before applying it to another piece of software.  On a read callback I create (or add to) a buffer, and then on write callback I write back as much of it as allowed. The code follows pacat.c and several examples I've found on Jan Newmarch's site. The main difference, is rather than checking for writable size and writing immediately following a read, piling it onto the buffer and waiting for write callback seems to reduce CPU load on the remote hardware (raspberry pi) by 50% or more.</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr"><br></div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr">Here is the erratic behavior...</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr">1)I don't get any write callbacks (after the initial one) with the prebuf attribute = -1. The sample buffer size continues to increment with nowhere to go. This is probably related to the next two issues.</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr">2)If I comment out the prebuf and tlength attribute it works... kind-of.  I sometimes don't get sound on one computer even though the data on the screen indicates the program is running normally. If there is no sound, I can immediately ctl-c and restart and then I get sound.</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr">3)On a slower computer, I get a segfault and gdb gives the following. I sometimes get a message about memcpy and unaligned memory.</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr"><br></div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr" class="" style="">Program received signal SIGSEGV, Segmentation fault.</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr" class="" style="">__memcpy_ssse3 () at ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S:2000</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr" class="" style="">2000<span class="" style="white-space:pre">    </span>../sysdeps/i386/i686/multiarch/memcpy-ssse3.S: No such file or directory.</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr" class="" style="">(gdb) backtrace</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr" class="" style="">#0  __memcpy_ssse3 () at ../sysdeps/i386/i686/multiarch/memcpy-ssse3.S:2000</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr" class="" style="">#1  0xb7fbf000 in ?? () from /usr/lib/i386-linux-gnu/libpulse.so.0</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr" class="" style="">Backtrace stopped: previous frame inner to this frame (corrupt stack?)</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr" class="" style="">(gdb) </div><div class="" style="" id="yui_3_16_0_1_1424656479344_2894"><br class="" style=""></div><div class="" style="" id="yui_3_16_0_1_1424656479344_2894" dir="ltr">I plan on using a fixed size ring buffer in the final implementation, but for the life of me cannot figure out why this program won't run using dynamic allocation.  Granted, I am not a very proficient programmer but it appears I'm missing some key concept resulting in the above issues.  I've attached the c code file.  If you have a minute to take a look and tell me what I'm missing I would really appreciate it. </div><div class="" style="" id="yui_3_16_0_1_1424656479344_2894" dir="ltr"><br></div><div class="" style="" id="yui_3_16_0_1_1424656479344_2894" dir="ltr">Thanks,</div><div class="" style="" id="yui_3_16_0_1_1424656479344_2894" dir="ltr"><br></div><div class="" style="" id="yui_3_16_0_1_1424656479344_2894" dir="ltr">Eric</div><div id="yui_3_16_0_1_1424656479344_2510" dir="ltr" class="" style=""><br class="" style=""></div></div></body></html>