summaryrefslogtreecommitdiffstats
path: root/src/utils/pacat.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-04-10 19:42:14 +0000
committerLennart Poettering <lennart@poettering.net>2006-04-10 19:42:14 +0000
commit93327083d9273bcf2d6ce94b61449c181dcf6fa2 (patch)
tree1e1abf9514d26ae3fb9eb1ee059d1f0f27c1de95 /src/utils/pacat.c
parent6a3b8aeb3fa43c69ca7ad1b89e35040fb5834751 (diff)
when using record mode, allow file to save data to to be passed on the command line
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@675 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/utils/pacat.c')
-rw-r--r--src/utils/pacat.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/utils/pacat.c b/src/utils/pacat.c
index 441e2607..e721befa 100644
--- a/src/utils/pacat.c
+++ b/src/utils/pacat.c
@@ -517,25 +517,25 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "Opening a %s stream with sample specification '%s'.\n", mode == RECORD ? "recording" : "playback", t);
}
- if (optind+1 < argc) {
- fprintf(stderr, "Too many arguments.\n");
- goto quit;
- }
-
- if (optind+1 == argc) {
- int fd;
-
- if ((fd = open(argv[optind], O_RDONLY)) < 0) {
- fprintf(stderr, "open(): %s\n", strerror(errno));
- goto quit;
- }
-
- if (dup2(fd, 0) < 0) {
- fprintf(stderr, "dup2(): %s\n", strerror(errno));
+ if (!(optind >= argc)) {
+ if (optind+1 == argc) {
+ int fd;
+
+ if ((fd = open(argv[optind], mode == PLAYBACK ? O_RDONLY : O_WRONLY|O_TRUNC|O_CREAT)) < 0) {
+ fprintf(stderr, "open(): %s\n", strerror(errno));
+ goto quit;
+ }
+
+ if (dup2(fd, mode == PLAYBACK ? 0 : 1) < 0) {
+ fprintf(stderr, "dup2(): %s\n", strerror(errno));
+ goto quit;
+ }
+
+ close(fd);
+ } else {
+ fprintf(stderr, "Too many arguments.\n");
goto quit;
}
-
- close(fd);
}
/* Set up a new main loop */