[polypaudio-commits] r675 - /trunk/src/utils/pacat.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Mon Apr 10 12:42:15 PDT 2006


Author: lennart
Date: Mon Apr 10 21:42:14 2006
New Revision: 675

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=675&root=polypaudio&view=rev
Log:
when using record mode, allow file to save data to to be passed on the command line

Modified:
    trunk/src/utils/pacat.c

Modified: trunk/src/utils/pacat.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/utils/pacat.c?rev=675&root=polypaudio&r1=674&r2=675&view=diff
==============================================================================
--- trunk/src/utils/pacat.c (original)
+++ trunk/src/utils/pacat.c Mon Apr 10 21:42:14 2006
@@ -517,25 +517,25 @@
         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));
+    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;
         }
-
-        if (dup2(fd, 0) < 0) {
-            fprintf(stderr, "dup2(): %s\n", strerror(errno));
-            goto quit;
-        }
-
-        close(fd);
     }
     
     /* Set up a new main loop */




More information about the pulseaudio-commits mailing list