alsa: fix rate matching in the sequencer

The alsa sequencer rate matching was not actually working correctly.
It would compare the previous queue time with the current time and
compare that to the quantum. This would include uncorrected errors from
jitter and would result in the timeouts being scaled in the wrong
direction forever.

Instead, calculate an ideal queue time and compare our current queue
time against that. We then use the correction to scale the timeout or
the next queue time prediction.

Also use the predicted time as the base time for the event timestamps.
this results in less jitter.

Fixes #3657
This commit is contained in:
Wim Taymans 2023-12-05 15:12:27 +01:00
parent c153f39720
commit 758805d65d
2 changed files with 26 additions and 16 deletions

View file

@ -142,6 +142,8 @@ struct seq_state {
uint64_t next_time;
uint64_t base_time;
uint64_t queue_time;
uint64_t queue_next;
double queue_corr;
unsigned int opened:1;
unsigned int started:1;