[alsa-devel] ASoC: TLV320AIC3x how to reduce alsa playback/capture latency?

Timur Karaldin karaldin at mcsplus.ru
Thu Mar 24 12:12:15 CET 2016


Hello,
I have an issue to reduce playback/capture audio latency for AIC3106.
Now I'm using following strategy for initial of alsa backend driver in 
user level application:

snd_pcm_hw_params_set_period_size(...,frame_size,...);
snd_pcm_hw_params_set_periods_min(...,&periodsp,...);
if(periodsp< user_nperiods)
	periodsp = user_nperiods
snd_pcm_hw_params_set_periods_near(....,&periodsp,...);
snd_pcm_hw_set_buffer_size(...,frame_size*periodsp,....);
[...]
snd_pcm_sw_params_set_start_threshold(..., 0U);
snd_pcm_sw_params_set_stop_threshold(..., frame_size*periodsp);
if(playback)
{
	availmin=frame_size*(periodsp-user_nperiods+1);

}else
{
	availmin=frame_size;
}
snd_pcm_sw_params_set_avail_min(...,availmin)
[...]

On far end I hear an echo with delay about 1 second, I definitely know 
that it is a playback/capture (acoustic echo), and delay is too much for 
any AEC because of (as I think) low latency in alsa driver or 
misunderstanding how it should be initialized. I already exclude other 
delays (jitter delay, network delay)

My initial parameters: frame_size = 640, rate = 16000, user_nperiods = 
2, but after calling snd_pcm_hw_params_set_periods_min I got minimum 
periodsp = 16.
For these parameter buffer (16 buffers 40ms each) total length of buffer 
is 0.64 sec.

My question is how could I reduce this latency? May be some improvements 
which allow me to set up less then 16 buffers, or I did wrong 
initialization or is there any another internal buffer which make such 
long delay for echo?

Cheers,
Tim Karaldin


More information about the Alsa-devel mailing list