On Mon, 2016-11-28 at 19:23 +0200, Ahmed S. Darwish wrote: > On Mon, Nov 28, 2016 at 09:04:01AM +0100, David Henningsson wrote: > > Wouldn't it be better if we had something like: > > By better, you mean simpler? > > > 1) Call pa_stream_begin_write to get a buffer. > > 2) If we have half a frame from previous iteration at 4), put that half > > frame first in the buffer. > > 3) Call read / pa_read to read data from a file into the rest of the > > buffer. > > 4) If the last frame read is not complete, store that half frame in a local > > variable. > > 5) Call pa_stream_write with the number of complete frames. > > 6) Repeat from 1). > > Hmm, didn't know about pa_stream_begin_write() before; it seems > to offer zero-copy benefits, especially in the SHM case, too. > > The above implies that "stream_write_callback()" will not do any > actual writes though. That's because nothing will be buffered by > that point (no actual buffers), and we cannot do any read() or > we will risk blocking, thus possible underruns. Correct? > > IMHO the logic complexity seems equivalent to the ringbuffer, > especially that steps "2)" and "4)" are implicitly done by the > ring anyway. I'll give it a try though; maybe it'll grow on me > afterwards :D What's the status? Did you give the alternative fix a try? Or should we go with the ringbuffer-based fix? -- Tanu https://www.patreon.com/tanuk