diff mbox

[1/2] pcm: break out of snd_pcm_write_areas() if write function returned 0

Message ID 1402642727.109608901@f39.i.mail.ru (mailing list archive)
State New, archived
Headers show

Commit Message

Sergey June 13, 2014, 6:58 a.m. UTC
When pcm is stuck and write func returns 0, snd_pcm_write_areas() loops
infinitely freezing the application and not allowing it to handle the case.
Can be reproduced with:
  # aplay -vvv /dev/zero
  pcm.!default {
    type plug
    slave.pcm { type null }
    slave.format S32_LE
  }
This patch fixes it by breaking the loop if func returns 0.
Note: pcm_null stuckness must be fixed on its own.
---
 src/pcm/pcm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 7e46014..5bb7582 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -6816,7 +6816,7 @@  snd_pcm_sframes_t snd_pcm_write_areas(snd_pcm_t *pcm, const snd_pcm_channel_area
 		if (! frames)
 			break;
 		err = func(pcm, areas, offset, frames);
-		if (err < 0)
+		if (err <= 0)
 			break;
 		frames = err;
 		if (state == SND_PCM_STATE_PREPARED) {