This patch fixes the draining behavior of ioplug in the following
ways:
- When no draining ioplug callback is defined, implement the draining
loop using snd_pcm_wait*() and sync with the drain finishes.
This is equivalent with the implementation in the kernel write().
Similarly as in kernel code, for non-blocking mode, it returns
immediately after setting DRAINING state.
- The hw_ptr update function checks the PCM state and stops the stream
if the draining finishes.
- When draining ioplug callback is defined, leave the whole draining
operation to it. The callback is supposed to return -EAGAIN for
non-blocking case, too.
- When an error happens during draining, it drops the stream, for a
safety reason.