diff options
author | Keunyoung <kyoung.park@gmail.com> | 2012-05-10 10:50:00 -0700 |
---|---|---|
committer | Keunyoung <kyoung.park@gmail.com> | 2012-05-10 10:50:00 -0700 |
commit | 2581a1e4f5a936d8af68c187a8d10c8706c235b3 (patch) | |
tree | 75fe9bdb9735d136a1a7b65a5da1b4f1efce3005 | |
parent | b6db70a16026bfc226a200a4382d04e2d15d84a1 (diff) |
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,
-rw-r--r-- | pcm.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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; |