OK, now I understand your concern. Yes it's another missing piece, snd_pcm_ioplug_hw_ptr_update() needs to check the current state, and it drops to SETUP state instead of XRUN when it was DRAINING. Then application can simply do poll() and status update until it goes out of DRAINING state.
Okay. Therefore the pulse plugin has to call pa_stream_drain() from its IO plug pointer callback in case of state DRAINING, right?
But still it's outside the plugin, drain callback isn't called there.
I think this is not the best design decision because there is an IO plug callback for each state transitions. Only for transitions to draining in nonblocking mode there will be no IO plug callback. I think this could be confusing for some IO plugin developers. What do you think?
Timo