summaryrefslogtreecommitdiff
path: root/sys/src/cmd/audio
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-03-26 18:39:58 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2014-03-26 18:39:58 +0100
commit1641d9908b2d0b7bebabef9733b6e0fb4d83034a (patch)
tree5b57892d5e64adcf693cd6b229d22715dfae9518 /sys/src/cmd/audio
parentb964e60a49ef7037b9360785de6e7d91c5f918c3 (diff)
audio/oggdec: wait for pcmconv child process to exit
we have to wait for the pcmconv process to exit before exiting yourselfs because otherwise pcmconv could keep /dev/audio open and prevent further reopens for a short period of time.
Diffstat (limited to 'sys/src/cmd/audio')
-rw-r--r--sys/src/cmd/audio/oggdec/oggdec.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/src/cmd/audio/oggdec/oggdec.c b/sys/src/cmd/audio/oggdec/oggdec.c
index 5a530e2c2..0df9b15f3 100644
--- a/sys/src/cmd/audio/oggdec/oggdec.c
+++ b/sys/src/cmd/audio/oggdec/oggdec.c
@@ -26,15 +26,18 @@
#include <stdlib.h>
#include <math.h>
#include <vorbis/codec.h>
+#include <sys/wait.h>
+
+static int ifd = -1;
static void
output(float **pcm, int samples, vorbis_info *vi)
{
static int rate, chans;
static unsigned char *buf;
- static int nbuf, ifd = -1;
+ static int nbuf;
unsigned char *p;
- int i, j, n, v;
+ int i, j, n, v, status;
float *s;
/* start converter if format changed */
@@ -46,8 +49,10 @@ output(float **pcm, int samples, vorbis_info *vi)
chans = vi->channels;
sprintf(fmt, "f%dr%dc%d", sizeof(float)*8, rate, chans);
- if(ifd >= 0)
+ if(ifd >= 0){
close(ifd);
+ wait(&status);
+ }
if(pipe(pfd) < 0){
fprintf(stderr, "Error creating pipe\n");
exit(1);
@@ -105,7 +110,7 @@ int main(){
char *buffer;
int bytes;
-
+ int status;
/********** Decode setup ************/
@@ -291,7 +296,12 @@ int main(){
/* OK, clean up the framer */
ogg_sync_clear(&oy);
-
+
+ if(ifd >= 0){
+ close(ifd);
+ wait(&status);
+ }
+
fprintf(stderr,"Done.\n");
return(0);
}