aboutsummaryrefslogtreecommitdiff
path: root/pcm.c
diff options
context:
space:
mode:
authorKeunyoung <kyoung.park@gmail.com>2012-05-10 10:50:00 -0700
committerKeunyoung <kyoung.park@gmail.com>2012-05-10 10:50:00 -0700
commit2581a1e4f5a936d8af68c187a8d10c8706c235b3 (patch)
tree75fe9bdb9735d136a1a7b65a5da1b4f1efce3005 /pcm.c
parentb6db70a16026bfc226a200a4382d04e2d15d84a1 (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,
Diffstat (limited to 'pcm.c')
-rw-r--r--pcm.c5
1 files changed, 4 insertions, 1 deletions
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;