[alsa-devel] [PATCH - JACK plugin 4/4] jack: Support snd_pcm_drain()
Wischer, Timo (ADITG/ESB)
twischer at de.adit-jv.com
Fri Mar 16 16:52:31 CET 2018
Hi Jaroslav,
> But it changes the PCM API behaviour, so some apps might have trouble
> with it, because it might cause the unexpected task blocking. The
> correct behaviour is return with -EAGAIN
I have checked all IO plugins (pulse, oss, a52, jack) only a52 could return -EAGAIN.
oss and pulse do always block and it seems that they are not updating the file descriptor in case of draining.
Therefore snd_pcm_wait() would block infinitely.
I think an application developer would not expect that he has to call snd_pcm_drop() after snd_pcm_drain().
Therefore snd_pcm_drop has to be called internally.
(On a real hardware it will be handled in the kernel)
Therefore I think snd_pcm_drop() has to be called from snd_pcm_wait() before returning.
But snd_pcm_wait callback is not available in the IO plug API.
Therefore I think we have to call snd_pcm_drop() from snd_pcm_ioplug_poll_revents().
But this looks a little bit ugly for me.
Do you have another idea?
One approach could be the following
snd_pcm_ioplug_poll_revents()
{
...
if (draining)
snd_pcm_drop()
}
snd_pcm_ioplug_drain()
{
int err = 0
if (io->data->callback->drain)
err = io->data->callback->drain(io->data);
if (err != -EAGAIN) {
snd_pcm_lock(pcm);
err = snd_pcm_ioplug_drop(pcm);
snd_pcm_unlock(pcm);
}
return err;
}
But I am not aware of if this would brake any of the existing IO plugins.
I would prefer to avoid these changes.
Best regards
Timo Wischer
Advanced Driver Information Technology GmbH
Engineering Software Base (ADITG/ESB)
Robert-Bosch-Str. 200
31139 Hildesheim
Germany
Tel. +49 5121 49 6938
Fax +49 5121 49 6999
twischer at de.adit-jv.com
ADIT is a joint venture company of Robert Bosch GmbH/Robert Bosch Car Multimedia GmbH and DENSO Corporation
Sitz: Hildesheim, Registergericht: Amtsgericht Hildesheim HRB 3438
Geschäftsführung: Wilhelm Grabow, Ken Yaguchi
More information about the Alsa-devel
mailing list