2009/8/13 Kai Vehmanen kvehmanen@eca.cx:
Hi,
Any update/ideas on this topic? Personally I think adding a new driver callback would make most sense, as that would allow to take full benefit from hardware that allows to query sample-accurate position of playout (i.e. not just support exposing a fixed latency). Of course that's potentially a big change. In alsa-lib, snd_pcm_hwsync() could call this driver callback, and a new variant of snd_pcm_delay() could present the information to the applications.
snd_pcm_delay() does not just support exposing a fixed latency. The value returned is dynamic.
In the current ALSA implementation, the value returns a real time count of how many samples are already in the hardware buffer. So, if one makes a call to snd_pcm_delay(), waits for a period of a few samples, the new value returned in snd_pcm_delay() is going to be different, but only for sound cards that support this level of accuracy.
So, I think the snd_pcm_delay() function is already doing what you want. It was me who originally requested the snd_pcm_delay() function to be introduced into the API, for the purposes of audio/video sync in the media player xine.
Kind Regards
James