]> git.alsa-project.org Git - alsa-lib.git/commit
pcm: ioplug: Implement proper drain behavior
authorTakashi Iwai <tiwai@suse.de>
Thu, 29 Mar 2018 07:51:46 +0000 (09:51 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 29 Mar 2018 07:51:46 +0000 (09:51 +0200)
commitce2095c41f2891c51f5dbd28e0317200314c5a75
tree05340cdb4b5482b1c507a1e701216369a2e2b051
parentd3d42f60a6ba9e2684fe82ee311ef41e58e15921
pcm: ioplug: Implement proper drain behavior

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.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm_ioplug.c