From: Lennart Poettering Date: Sat, 6 May 2006 20:56:43 +0000 (+0000) Subject: add support for reading audio data from a file instead of plain STDIN in pacat-simple.c X-Git-Tag: submit/2.0-panda/20130828.192557~3765 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f9bbf005a81a0f7d009e3fad3f6a4e8d4c5e6bb;p=profile%2Fivi%2Fpulseaudio-panda.git add support for reading audio data from a file instead of plain STDIN in pacat-simple.c git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@830 fefdeb5f-60dc-0310-8127-8f9354f1896f --- diff --git a/src/tests/pacat-simple.c b/src/tests/pacat-simple.c index 0382ec0..6a75c79 100644 --- a/src/tests/pacat-simple.c +++ b/src/tests/pacat-simple.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,23 @@ int main(PA_GCC_UNUSED int argc, char*argv[]) { int ret = 1; int error; + /* replace STDIN with the specified file if needed */ + if (argc > 1) { + int fd; + + if ((fd = open(argv[1], O_RDONLY)) < 0) { + fprintf(stderr, __FILE__": open() failed: %s\n", strerror(errno)); + goto finish; + } + + if (dup2(fd, STDIN_FILENO) < 0) { + fprintf(stderr, __FILE__": dup2() failed: %s\n", strerror(errno)); + goto finish; + } + + close(fd); + } + /* Create a new playback stream */ if (!(s = pa_simple_new(NULL, argv[0], PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, &error))) { fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", pa_strerror(error));