[alsa-devel] How to keep track of the amount of queued samples?
Hi,
I would like to understand the following quote which I copied from https://www.kernel.org/doc/Documentation/sound/alsa/timestamping.txt
"The ALSA API provides two basic pieces of information, avail and delay, which combined with the trigger and current system timestamps allow for applications to keep track of the 'fullness' of the ring buffer and the amount of queued samples."
Querying avail and delay is straight forward. But I have no idea how to use these values in combination with trigger_htstamp and the current system timestamp to calculate the fullness of the ring buffer.
Can someone provide some insight?
What exactly is meant by "current system timestamp"? Is it provied by ALSA (htstamp?) or should I use clock_gettime(CLOCK_MONOTONIC, &system_time); to get that timestamp?
Thanks, Jan
Jan Deinhard wrote:
I would like to understand the following quote which I copied from https://www.kernel.org/doc/Documentation/sound/alsa/timestamping.txt
"The ALSA API provides two basic pieces of information, avail and delay, which combined with the trigger and current system timestamps allow for applications to keep track of the 'fullness' of the ring buffer and the amount of queued samples."
The trigger/current timestamps are not related to the buffer/queue. They are useful only to relate the audio stream position to the system time.
What exactly is meant by "current system timestamp"? Is it provied by ALSA (htstamp?) or should I use clock_gettime(CLOCK_MONOTONIC, &system_time); to get that timestamp?
They are the same. ALSA returns it to prevent your process from being interrupted between measuring the two clocks.
Regards, Clemens
participants (2)
-
Clemens Ladisch
-
Jan Deinhard