aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTaylor Holberton <taylorcholberton@gmail.com>2017-10-12 20:28:30 -0400
committerTaylor Holberton <taylorcholberton@gmail.com>2017-10-12 20:28:30 -0400
commit093b87878bb1fabb2077d412c46cfd9b15998f8d (patch)
tree01b27c4a0b203fce163a8e837ace7417c660ad5b /src
parent1770a22cf1c445331668deb45f0f5da80e143150 (diff)
added PCM_NONBLOCK macro
Diffstat (limited to 'src')
-rw-r--r--src/pcm.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/pcm.c b/src/pcm.c
index ef38c9c..7a67cfe 100644
--- a/src/pcm.c
+++ b/src/pcm.c
@@ -818,9 +818,13 @@ struct pcm_params *pcm_params_get(unsigned int card, unsigned int device,
snprintf(fn, sizeof(fn), "/dev/snd/pcmC%uD%u%c", card, device,
flags & PCM_IN ? 'c' : 'p');
- fd = open(fn, O_RDWR);
+ if (flags & PCM_NONBLOCK)
+ fd = open(fn, O_RDWR | O_NONBLOCK);
+ else
+ fd = open(fn, O_RDWR);
+
if (fd < 0) {
- fprintf(stderr, "cannot open device '%s'\n", fn);
+ fprintf(stderr, "cannot open device '%s': %s\n", fn, strerror(errno));
goto err_open;
}
@@ -1073,7 +1077,12 @@ struct pcm *pcm_open(unsigned int card, unsigned int device,
flags & PCM_IN ? 'c' : 'p');
pcm->flags = flags;
- pcm->fd = open(fn, O_RDWR);
+
+ if (flags & PCM_NONBLOCK)
+ pcm->fd = open(fn, O_RDWR | O_NONBLOCK);
+ else
+ pcm->fd = open(fn, O_RDWR);
+
if (pcm->fd < 0) {
oops(pcm, errno, "cannot open device '%s'", fn);
return pcm;