On Fri, 23 Mar 2018 08:23:56 +0100, Wischer, Timo (ADITG/ESB) wrote:
The application needs to sync manually via poll() instead.
You mean the user application which opens the ALSA virtual device (aka IO plugin), right?
No, no matter which device is used.
It's also the behavior of the kernel driver, which ioplug follows.
I know that your suggested solution is the behavior of the kernel. But in kernel space we have the DMA interrupt which checks the state for draining.
To use the same mechanism in the IO plug each IO plug needs to have its own thread which checks state for draining. In case of pulse without this additional thread I have no idea how pulseaudio can be informed that draining starts because in nonblocking mode there is no function in the pulse IO plugin which is called to inform about the state change to draining.
In non-blocking mode, drain is never called.
The only solution which I have in my mind is this additional thread state_check_thread() { while (true) { if (state == DRAINING) pa_stream_drain() ... } }
Therefore with your proposed solution there is additional effort in each new IO plug required to support draining in nonblocking mode. (With my solution exactly the same mechanism (drain callback and poll) is used in blocking and nonblocking mode. Therefore new IO plugins will support both modes without additional efforts in the IO plugin implementation)
No, again, in non-blocking mode, the drain callback will get never called. It's the responsibility of application to sync with poll() instead.
Takashi