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

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Wed Apr 26 09:07:33 PDT 2006


Author: lennart
Date: Wed Apr 26 18:07:33 2006
New Revision: 805

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=805&root=polypaudio&view=rev
Log:
allow specifying the channel map to use 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=805&root=polypaudio&r1=804&r2=805&view=diff
==============================================================================
--- trunk/src/utils/pacat.c (original)
+++ trunk/src/utils/pacat.c Wed Apr 26 18:07:33 2006
@@ -66,6 +66,9 @@
     .channels = 2
 };
 
+static pa_channel_map channel_map;
+static int channel_map_set = 0;
+
 /* A shortcut for terminating the application */
 static void quit(int ret) {
     assert(mainloop_api);
@@ -184,7 +187,7 @@
             if (verbose)
                 fprintf(stderr, "Connection established.\n");
 
-            if (!(stream = pa_stream_new(c, stream_name, &sample_spec, NULL))) {
+            if (!(stream = pa_stream_new(c, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL))) {
                 fprintf(stderr, "pa_stream_new() failed: %s\n", pa_strerror(pa_context_errno(c)));
                 goto fail;
             }
@@ -405,7 +408,8 @@
            "      --format=SAMPLEFORMAT             The sample type, one of s16le, s16be, u8, float32le,\n"
            "                                        float32be, ulaw, alaw (defaults to s16ne)\n"
            "      --channels=CHANNELS               The number of channels, 1 for mono, 2 for stereo\n"
-           "                                        (defaults to 2)\n",
+           "                                        (defaults to 2)\n"
+           "      --channel-map=CHANNELMAP          Channel map to use instead of the default\n",
            argv0);
 }
 
@@ -415,7 +419,8 @@
     ARG_VOLUME,
     ARG_SAMPLERATE,
     ARG_SAMPLEFORMAT,
-    ARG_CHANNELS
+    ARG_CHANNELS,
+    ARG_CHANNELMAP,
 };
 
 int main(int argc, char *argv[]) {
@@ -438,6 +443,7 @@
         {"rate",        1, NULL, ARG_SAMPLERATE},
         {"format",      1, NULL, ARG_SAMPLEFORMAT},
         {"channels",    1, NULL, ARG_CHANNELS},
+        {"channel-map", 1, NULL, ARG_CHANNELMAP},
         {NULL,          0, NULL, 0}
     };
 
@@ -514,6 +520,16 @@
                 sample_spec.rate = atoi(optarg);
                 break;
 
+            case ARG_CHANNELMAP:
+                
+                if (!pa_channel_map_parse(&channel_map, optarg)) {
+                    fprintf(stderr, "Invalid channel map\n");
+                    goto quit;
+                }
+
+                channel_map_set = 1;
+                break;
+                
             default:
                 goto quit;
         }
@@ -527,6 +543,11 @@
 
     if (!pa_sample_spec_valid(&sample_spec)) {
         fprintf(stderr, "Invalid sample specification\n");
+        goto quit;
+    }
+
+    if (channel_map_set && channel_map.channels != sample_spec.channels) {
+        fprintf(stderr, "Channel map doesn't match sample specification\n");
         goto quit;
     }
     




More information about the pulseaudio-commits mailing list