[alsa-devel] Buffer size calculation based on period size

Clemens Ladisch clemens at ladisch.de
Fri May 4 14:57:27 CEST 2018


noman pouigt wrote:
> I am using tinycap to capture the audio and
> setting below settings:
> bitwidth =  16
> rate =  16000
> channel =  1
> period_size =  320
> period_count = 2
>
> I am wondering how is below
> period_size and buffer_size calculated?
>
> Shouldn't period_size of 320 bytes and
> period_count of 2 fail?

>From the tinyalsa source code:

    param_set_min(&params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, config->period_size);

So it uses either the supplied value, or if that is too small, the
smallest allowed value.

> cat sub0/hw_params
>
> access: RW_INTERLEAVED
> format: S16_LE
> subformat: STD
> channels: 1
> rate: 16000 (16000/1)
> period_size: 2042
> buffer_size: 4084

The actual values of period_size and period_count are returned by
pcm_open().


Regards,
Clemens


More information about the Alsa-devel mailing list