[alsa-devel] Buffer size calculation based on period size
I am at my wits end trying to figure out how period_size is being calculated in pcm_native layer based on period_size and period_count being set by the userspace.
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?
cat sub0/hw_params
access: RW_INTERLEAVED format: S16_LE subformat: STD channels: 1 rate: 16000 (16000/1) period_size: 2042 buffer_size: 4084
And this is my settings in pcm_hardware structure: static struct snd_pcm_hardware s1000_pcm_hw = { .buffer_bytes_max = 1024*1024, .period_bytes_min = 4084, .period_bytes_max = (1024*1024)/2, .periods_min = 2, .periods_max = 32, };
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(¶ms, 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
participants (2)
-
Clemens Ladisch
-
noman pouigt