[polypaudio-commits] r809 - /trunk/src/utils/paplay.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Wed Apr 26 09:28:30 PDT 2006


Author: lennart
Date: Wed Apr 26 18:28:29 2006
New Revision: 809

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=809&root=polypaudio&view=rev
Log:
allow the user to specify an alternative channel map in paplay too

Modified:
    trunk/src/utils/paplay.c

Modified: trunk/src/utils/paplay.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/utils/paplay.c?rev=809&root=polypaudio&r1=808&r2=809&view=diff
==============================================================================
--- trunk/src/utils/paplay.c (original)
+++ trunk/src/utils/paplay.c Wed Apr 26 18:28:29 2006
@@ -53,7 +53,9 @@
 
 static SNDFILE* sndfile = NULL;
 
-static pa_sample_spec sample_spec = { 0, 0, 0 }; 
+static pa_sample_spec sample_spec = { 0, 0, 0 };
+static pa_channel_map channel_map;
+static int channel_map_set = 0;
 
 static sf_count_t (*readf_function)(SNDFILE *_sndfile, void *ptr, sf_count_t frames);
 
@@ -161,7 +163,7 @@
             if (verbose)
                 fprintf(stderr, "Connection established.\n");
 
-            stream = pa_stream_new(c, stream_name, &sample_spec, NULL);
+            stream = pa_stream_new(c, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL);
             assert(stream);
 
             pa_stream_set_state_callback(stream, stream_state_callback, NULL);
@@ -200,14 +202,16 @@
            "  -d, --device=DEVICE                   The name of the sink/source to connect to\n"
            "  -n, --client-name=NAME                How to call this client on the server\n"
            "      --stream-name=NAME                How to call this stream on the server\n"
-           "      --volume=VOLUME                   Specify the initial (linear) volume in range 0...256\n",
+           "      --volume=VOLUME                   Specify the initial (linear) volume in range 0...65536\n"
+           "      --channel-map=CHANNELMAP          Set the channel map to the use\n",
            argv0);
 }
 
 enum {
     ARG_VERSION = 256,
     ARG_STREAM_NAME,
-    ARG_VOLUME
+    ARG_VOLUME,
+    ARG_CHANNELMAP
 };
 
 int main(int argc, char *argv[]) {
@@ -226,6 +230,7 @@
         {"help",        0, NULL, 'h'},
         {"verbose",     0, NULL, 'v'},
         {"volume",      1, NULL, ARG_VOLUME},
+        {"channel-map", 1, NULL, ARG_CHANNELMAP},
         {NULL,          0, NULL, 0}
     };
 
@@ -277,6 +282,15 @@
                 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;
         }
@@ -322,6 +336,13 @@
             break;
     }
 
+    assert(pa_sample_spec_valid(&sample_spec));
+
+    if (channel_map_set && channel_map.channels != sample_spec.channels) {
+        fprintf(stderr, "Channel map doesn't match file.\n");
+        goto quit;
+    }
+
     if (verbose) {
         char t[PA_SAMPLE_SPEC_SNPRINT_MAX];
         pa_sample_spec_snprint(t, sizeof(t), &sample_spec);




More information about the pulseaudio-commits mailing list