From 2581a1e4f5a936d8af68c187a8d10c8706c235b3 Mon Sep 17 00:00:00 2001 From: Keunyoung Date: Thu, 10 May 2012 10:50:00 -0700 Subject: add error check for pcm_start - Otherwise, read will be tried even after pcm_start is failed. This leads into blocking inside the read ioctl forever. pcm_start can fail, for example in full-speed USB audio device, in some H/W, due to the lack of bandwidth in USB bus, --- pcm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pcm.c') diff --git a/pcm.c b/pcm.c index 2dca157..af175f2 100644 --- a/pcm.c +++ b/pcm.c @@ -405,7 +405,10 @@ int pcm_read(struct pcm *pcm, void *data, unsigned int count) for (;;) { if (!pcm->running) { - pcm_start(pcm); + if (pcm_start(pcm) < 0) { + fprintf(stderr, "start error"); + return -errno; + } } if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_READI_FRAMES, &x)) { pcm->running = 0; -- cgit v1.2.3