[polypaudio-commits] r830 - /trunk/src/tests/pacat-simple.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sat May 6 13:56:43 PDT 2006
Author: lennart
Date: Sat May 6 22:56:43 2006
New Revision: 830
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=830&root=polypaudio&view=rev
Log:
add support for reading audio data from a file instead of plain STDIN in pacat-simple.c
Modified:
trunk/src/tests/pacat-simple.c
Modified: trunk/src/tests/pacat-simple.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/tests/pacat-simple.c?rev=830&root=polypaudio&r1=829&r2=830&view=diff
==============================================================================
--- trunk/src/tests/pacat-simple.c (original)
+++ trunk/src/tests/pacat-simple.c Sat May 6 22:56:43 2006
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
+#include <fcntl.h>
#include <polyp/simple.h>
#include <polyp/error.h>
@@ -47,6 +48,23 @@
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));
More information about the pulseaudio-commits
mailing list