[alsa-devel] Question about the buffer length in the transfer callback of the PCM External Plugin

Clemens Ladisch clemens at ladisch.de
Mon Oct 31 11:10:40 CET 2016


Bach, Andrea wrote:
> how can I change the size that is provided inside the „transfer“-
> callback of an external PCM plugin?

You cannot.

ALSA assumes that there is a ring buffer that has the configured buffer
size, and that when N frames are reported as available, any number of
frames between 1 and N can be read/written.

> I need to write a filter plugin and I have to use for processing
> a chunk size of power of two (32, 64, or 128 bytes … that’s because of
> the use of FFT). But I get inside the transfer callback a buffer of
> length 1000. That would be ok if I could just return let's say
> 960 bytes

Handling less bytes than requested would imply that an error occured.

You could add your own buffer to keep any remaining frames of the
128-frame chunk until the next transfer call.


Regards,
Clemens


More information about the Alsa-devel mailing list