Skip to content

alsa: improve audio output to multiple devices

Michael Olbrich requested to merge mol/pipewire:multi-alsa into master

There are currently several issues when multiple alsa devices are involved.

For alsa devices that are followers, all data is written via impl_node_process(). Currently spa_alsa_write() is only called if a new buffer was queued. It can happen that all buffers are in the ready list (queued by previous calls but not yet written because there was no free space in the kernel ring buffer). In this case writing stalls indefinitely. To fix this, also call spa_alsa_write() if no new buffer is queued but there are still buffers in the ready list.

If the ready list of the primary device is not empty then only this device is handled because spa_alsa_write() is called directly. The other devices make no progress during this interval. The clock drift calculation works by comparing the alsa delay with the expected delay since the last wakeup. This only work if the alsa ringbuffer was filled completly. If the ready list contains a partial buffer then the ringbuffer is not filled and the timing calculation during the next wakeup is incorrect.

To fix all this, remove the special case for the non-empty ready list and just call spa_node_call_ready() every time.

Merge request reports