Alsa library latency

Hi all,

I have been testing audio playback latency on the BB xmC using libasound (alsa library). I test it using a c application, toggling a GPIO pin and sending audio data to alsa library at startup. Using an oscilloscope to capture the time the GPIO pin was switched on, and the time audio was streamed out via the phono connector, I realize that there is a 20ms delay in the audio signal. Anymore optimization in the alsa library would cause a “buffer underrun error”, in other words, CPU is unable to send data to audio device in time. Even after changing the kernel scheduling policy to earliest deadline first, enabling preemption, running the user application in higher priority would still result in a 20ms delay in actual audio start time. Please share if you know of a way to minimize the actual start time. thanks,