
On 9/17/13 3:07 PM, Brandon Yates wrote:
I have an application using the ALSA API that writes to playback device and simultaneously reads from capture device. My processing loop is :
1)Read from microphone (blocking) 2)Process Data 3)Write to speaker
I am measuring the delay from the time I play a series of frames to the speaker until I detect the echo of this coming back in through the microphone. This delay seems to be changing every time I initialize the devices with ALSA. I have measured in the range of 60-160ms delay. I know things like period size effect delay, but using the exact same software and hardware configuration I would expect this to be constant across runs. What are some parameters that can help me make the delay deterministic?
snd_pcm_link can help make sure your playback and capture devices start at the same time, if supported in hardware (HDAudio works well). Otherwise you need a cross-correlation to find out the delay and compensate for it in software. -Pierre