On Sat, Mar 28, 2020 at 04:34:01PM -0500, Pierre-Louis Bossart wrote:
Using MONOTONIC_RAW is very nice on paper, until you realize you can't program a timer using the information. You can only read the timestamp and not really do much if you want to sleep/wait.
In practice, if you really really need super-precise information you'll get use rdtsc(), and apply you own formulas. And otherwise stick with MONOTONIC, it's rather unlikely you will ever notice the NTP changes. PulseAudio, CRAS and a number of Android HALs use MONOTONIC and nobody ever complained.
The pb is not about using monotonic_raw, the thing is: it is documented valid to use it which I did as expected from a naive reading of the api documentation and found those issues. I can reasonably believe it will be the case for any new alsa programmer.
For my code, in the end, I think I'll use the best "audio timestamp" I can get from the status ioctl for linear interpolation with ffmpeg timestamps.
But this is off topic here.
The topic is discussing how to fix this bug, since I had to dig a bit in alsa. It appears to me the recursive fix might be a good way, since it is done for other api functions, but I am not Jaroslav Kysela neither Takashi Iwai then far from grasping all the details of alsa.