Hi,
On 2018/11/01 13:44, Stefano Antonelli wrote:
Does anyone know why plughw might be acting the way it is and how I can get it to deliver 10ms periods? Â Equally appreciated would be any tips on how to debug this problem.
The 'plughw' PCM node of alsa-lib configuration space is assigned to 'plug' PCM plugin[1]. This PCM plugin can aggregate several PCM plugins to perform resampling. For example, in a below case, two PCM plugins (rate/route conversion PCM plugins) are aggregated by 'plug' PCM plugin in front of 'hw' PCM plugin which direct accesses to ALSA PCM chracter device.
$ LC_ALL=C arecord -v -Dplughw:1,0 /dev/null -fS16_LE Recording WAVE '/dev/null' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono Plug PCM: Rate conversion PCM (48000, sformat=S16_LE) Converter: libspeex (external) Protocol version: 10002 Its setup is: stream : CAPTURE access : RW_INTERLEAVED format : S16_LE ... Slave: Route conversion PCM (sformat=S16_LE) Transformation table: 0 <- 0*0.5 + 1*0.5 Its setup is: stream : CAPTURE access : MMAP_INTERLEAVED format : S16_LE ... Slave: Hardware PCM card 1 'HDA Intel PCH' device 0 subdevice 0 Its setup is: stream : CAPTURE access : MMAP_INTERLEAVED format : S16_LE ...
Well, for capture direction, the most of PCM plugins in alsa-lib/alsa-utils are programmed to do resampling in .avail_update() callback of plugin framework in alsa-lib. The number of available PCM frames is calculated in this timing. On the other hand, poll(2) system call is executed against ALSA PCM character device. Even if poll(2) returns to notify available PCM frames in the device, actual number of available frames is a summary of resampling done by the aggregated PCM plugins. As a result, you can see the behaviour because plugins possibly have buffers for count gap between in/out frames.
[1] http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/conf/alsa.conf;h=bb...
Regards
Takashi Sakamoto