On 02/20/2018 04:18 PM, Georg Chini wrote: > On 20.02.2018 13:50, Raman Shishniou wrote: >> On 02/20/2018 03:16 PM, Georg Chini wrote: >>> On 20.02.2018 13:11, Georg Chini wrote: >>>> On 19.02.2018 16:01, Raman Shyshniou wrote: >>>>> Currently the pipe-source will remain running even if no >>>>> writer is connected and therefore no data is produced. >>>>> This patch adds the autosuspend=<bool> option to prevent this. >>>>> Source will stay suspended if no writer is connected. >>>>> This option is enabled by default. >>>>> --- >>>>> + >>>>> + pa_memchunk_reset(&chunk); >>>>> + chunk.memblock = pa_memblock_new(u->core->mempool, u->pipe_size); >>>> Further down, you might put some data in the memchunk before the >>>> read if the previous data was not frame aligned, therefore the memblock >>>> size must be u->pipe_size + fs. >>> Looking twice, I see you subtract the index from the read size. Nevertheless I >>> guess it would be simpler to increase the memblock size by one frame. >> I prefer to keep buffer sizes to be power of 2. >> Currently pipe_size is 4096 (as determined by pulseaudio, actually 64k, >> I'll check later why). Adding one frame to the size of buffer makes it >> a little more than 4096 but much less then 8192> What is the advantage of keeping the buffer size a power of 2? > What if you have for example a channel count that is not a power > of 2? Would it not make more sense to keep the buffers frame > aligned? Anyway, I don't mind if you want to keep it your way. Usually memory is provided by pages, which is 4096 for x86/x86_64. Pipe size in linux is one page or 16 pages by default: http://man7.org/linux/man-pages/man7/pipe.7.html So the whole page will be used to store one extra frame which is 128 bytes (PA_CHANNELS_MAX * 4 bytes) maximum. I didn't read pa_memblock_new() code and may be it does not return page aligned memory. But I believe this is a good practice to keep page boundaries if possible. If you look again, the memblock always is frame aligned too. -- Raman