From 1641d9908b2d0b7bebabef9733b6e0fb4d83034a Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Wed, 26 Mar 2014 18:39:58 +0100 Subject: 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. --- sys/src/cmd/audio/oggdec/oggdec.c | 20 +++++++++++++++----- 1 file 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 #include #include +#include + +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); } -- cgit v1.2.3