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

noman pouigt variksla at gmail.com
Thu May 3 22:17:08 CEST 2018


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,
 };


More information about the Alsa-devel mailing list