简体   繁体   English

对于 Alsa pcm 设备,period_size 设置为 128,但有时轮询会延迟

[英]For Alsa pcm device, period_size is set to 128, yet sometimes the poll happens late

I am facing an issue where the period size has been set to 128, still sometimes the polling starts late.我面临的问题是周期大小已设置为 128,但有时轮询开始的时间仍然很晚。
For this configuration, where the period size is set to 128 and rate is 16 Khz, therefore polling should occur after each 128/16 = 8 ms, but in some cases the polling occurs a bit late which causes certain issues in the application.对于此配置,周期大小设置为 128,速率为 16 Khz,因此轮询应在每 128/16 = 8 毫秒后发生,但在某些情况下,轮询发生得有点晚,这会导致应用程序出现某些问题。
Since, polling is triggered internally by Alsa system modules which is dependent on the configuration, kindly suggest if we are going wrong somewhere with the configuration or any similar issue anyone might have experienced.由于轮询是由依赖于配置的 Alsa 系统模块在内部触发的,如果我们在配置的某个地方出错或任何人可能遇到的任何类似问题,请提出建议。 Pasting the PCM dump of my Setup below:-在下面粘贴我的设置的 PCM 转储:-

APCM_DUMP_DEVICE_DETALS :-
Hardware PCM card 0 'mt2712-d1v1' device 5 subdevice 0
Its setup is:
stream       : CAPTURE
access       : RW_INTERLEAVED
format       : S16_LE
subformat    : STD
channels     : 1
rate         : 16000
exact rate   : 16000 (16000/1)
msbits       : 16
buffer_size  : 512
period_size  : 128
period_time  : 8000
tstamp_mode  : NONE
tstamp_type  : MONOTONIC
period_step  : 1
avail_min    : 128
period_event : 0
start_threshold  : 128
stop_threshold   : 512
silence_threshold: 0
silence_size : 0
boundary     : 4611686018427387904
appl_ptr     : 0
hw_ptr       : 0

APCM_DUMP_DEVICE_DETALS :-
Hardware PCM card 0 'mt2712-d1v1' device 1 subdevice 0
Its setup is:
stream       : PLAYBACK
access       : RW_INTERLEAVED
format       : S16_LE
subformat    : STD
channels     : 1
rate         : 16000
exact rate   : 16000 (16000/1)
msbits       : 16
buffer_size  : 512
period_size  : 128
period_time  : 8000
tstamp_mode  : NONE
tstamp_type  : MONOTONIC
period_step  : 1
avail_min    : 128
period_event : 0
start_threshold  : 128
stop_threshold   : 512
silence_threshold: 0
silence_size : 0
boundary     : 4611686018427387904
appl_ptr     : 0
hw_ptr       : 0

APCM_DUMP_DEVICE_DETALS :-
Hardware PCM card 0 'mt2712-d1v1' device 12 subdevice 0
Its setup is:
stream       : CAPTURE
access       : RW_INTERLEAVED
format       : S16_LE
subformat    : STD
channels     : 1
rate         : 16000
exact rate   : 16000 (16000/1)
msbits       : 16
buffer_size  : 512
period_size  : 128
period_time  : 8000
tstamp_mode  : NONE
tstamp_type  : MONOTONIC
period_step  : 1
avail_min    : 128
period_event : 0
start_threshold  : 128
stop_threshold   : 512
silence_threshold: 0
silence_size : 0
boundary     : 4611686018427387904
appl_ptr     : 0
hw_ptr       : 0

APCM_DUMP_DEVICE_DETALS :-
Hardware PCM card 0 'mt2712-d1v1' device 11 subdevice 0
Its setup is:
stream       : PLAYBACK
access       : RW_INTERLEAVED
format       : S16_LE
subformat    : STD
channels     : 1
rate         : 16000
exact rate   : 16000 (16000/1)
msbits       : 16
buffer_size  : 512
period_size  : 128
period_time  : 8000
tstamp_mode  : NONE
tstamp_type  : MONOTONIC
period_step  : 1
avail_min    : 128
period_event : 0
start_threshold  : 128
stop_threshold   : 512
silence_threshold: 0
silence_size : 0
boundary     : 4611686018427387904
appl_ptr     : 0
hw_ptr       : 0

For the issue, we tried to analyze the kernel traces, after going through the kernel traces, we found out that we were reading the entire available data (snd_pcm_avail_update) for the capture device(rather than the period_size), due to which a flag in kernel was set to 0 since it had 0 bytes available due to which it was missing the interrupt to wake up the read thread(application) in time.对于这个问题,我们尝试分析 kernel 跟踪,在遍历 kernel 跟踪后,我们发现我们正在读取捕获设备(而不是 period_size)的全部可用数据(snd_pcm_avail_update),因此在kernel 被设置为 0,因为它有 0 个字节可用,因此它缺少及时唤醒读取线程(应用程序)的中断。 Once we set the pcm_read to read only the required data, the behaviour was rectified一旦我们将 pcm_read 设置为只读取所需的数据,该行为就得到了纠正

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM