From 93383edaeb6d762d6626308b358c76608560e88a Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Tue, 10 Mar 2009 21:18:54 +0100 Subject: [PATCH] Hack in the sox as a kind of audio router Signed-off-by: Alex Riesen --- src/videoinput.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/src/videoinput.c b/src/videoinput.c index 783bff8..6af42c0 100644 --- a/src/videoinput.c +++ b/src/videoinput.c @@ -232,6 +232,8 @@ struct videoinput_s /* V4L1 read-mode state. */ int grab_size; uint8_t *grab_data; + + pid_t audiorouter; }; const char *videoinput_get_audio_mode_name( videoinput_t *vidin, int mode ) @@ -478,6 +480,7 @@ videoinput_t *videoinput_new( const char *v4l_device, int capwidth, vidin->curinput = 0; vidin->have_mmap = 0; vidin->is_streaming = 0; + vidin->audiorouter = -1; memset( vidin->inputname, 0, sizeof( vidin->inputname ) ); memset( vidin->drivername, 0, sizeof( vidin->drivername ) ); @@ -930,6 +933,21 @@ videoinput_t *videoinput_new( const char *v4l_device, int capwidth, vidin->numframes = 2; } + vidin->audiorouter = fork(); + switch (vidin->audiorouter) + { + case 0: + execlp("sox", "sox", "-q", + "-t", "alsa", "hw:1", "-t", "alsa", "hw:0", + NULL); + exit(-1); + break; + case -1: + fprintf(stderr, "failed to fork for audiorouter %s\n", + strerror(errno)); + default: + break; + } return vidin; } @@ -956,6 +974,10 @@ void videoinput_delete( videoinput_t *vidin ) } } + if ( vidin->audiorouter > 0 ) { + kill(vidin->audiorouter, SIGTERM); + vidin->audiorouter = -1; + } close( vidin->grab_fd ); free( vidin ); } -- 1.6.2.133.g76830