arkq / bluez-alsa

Bluetooth Audio ALSA Backend
MIT License
864 stars 189 forks source link

Improve PCM plugin drain #667

Closed borine closed 1 year ago

borine commented 1 year ago

Implement support for applications that use snd_pcm_abort() or snd_pcm_nonblock(pcm, 2) to request that blocking calls are aborted by a signal. Also apply a timeout to the local drain so that an application can not be blocked indefinitely should the bluealsa server stop reading from the PCM FIFO.

This PR is an attempt to address the plugin issues revealed indirectly by #666

codecov[bot] commented 1 year ago

Codecov Report

Attention: 20 lines in your changes are missing coverage. Please review.

Files Coverage Δ
src/asound/bluealsa-pcm.c 76.33% <56.52%> (-0.71%) :arrow_down:

... and 2 files with indirect coverage changes

:loudspeaker: Thoughts on this report? Let us know!.

borine commented 1 year ago

Hmm - the test for io->state == SND_PCM_STATE_SUSPENDED in that last commit was silly; there is no way the system can have set that state. Do you know if there is any way to test if the system has been suspended during a call to poll()? If not then perhaps we should just drop the stream and report -EIO for any timeout error.

arkq commented 1 year ago

Do you know if there is any way to test if the system has been suspended during a call to poll()

I have no idea how to do it properly... the only thing that comes to my mind is some heuristic based on wall clock time vs monotonic time check. But I guess that simple EIO will suffice here.