>The delay value is calculated from getting the amount of samples still in
>the sound buffer.
>See the "ao_alsa_delay" function is
>"xine-lib/src/audio_out/audio_alsa_out.c"
>
>So if the delay is 100 ms.
>You have to place samples in the audio buffer 100ms before you wish to hear
>them.

Not quite right.

You have to put the samples in the buffer when its time to put them
there. The audio interface will tell you when its time to do that by
sending you an interrupt, which in POSIX terms means your app will
wake up from poll(2) if it was waiting on the relevant file
descriptor(s). You can then deliver the data.

Typically (assuming you used sane parameters to configure the device
driver), this will be about 100ms ahead of the samples being
heard. But there is no need to try to do any other scheduling - just
give the audio interface the data when it tells you it needs it.

However, thats still not quite right either, at least not all the
time. If you have a digital audio interface that has further
downstream latency before the signal becomes an analog one, you have
to adjust for that as well. The audio interface and the driver can't
know about this delay, so your app has to take care of it.

How many more demonstrations of the importance of being driven by the
audio interface interrupt do we need? :)

--p

_______________________________________________
Alsa-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

Reply via email to