]> code.delx.au - pulseaudio/blobdiff - src/utils/pactl.c
bump API and protocol version. Return PA_ERR_NOTSUPPORTED if pa_context_move_sink_inp...
[pulseaudio] / src / utils / pactl.c
index 6e40f3fec5ff6df0362a368adf9c17ab9a9626ef..0fde33eb5f67c1257087ee5f35314647bccdd6a0 100644 (file)
@@ -37,8 +37,8 @@
 
 #include <pulse/pulseaudio.h>
 
-#if PA_API_VERSION != 9
-#error Invalid Polypaudio API version
+#if PA_API_VERSION < 10
+#error Invalid PulseAudio API version
 #endif
 
 #define BUFSIZE 1024
@@ -46,7 +46,8 @@
 static pa_context *context = NULL;
 static pa_mainloop_api *mainloop_api = NULL;
 
-static char *device = NULL, *sample_name = NULL;
+static char *device = NULL, *sample_name = NULL, *sink_name = NULL;
+static uint32_t sink_input_idx = PA_INVALID_INDEX;
 
 static SNDFILE *sndfile = NULL;
 static pa_stream *sample_stream = NULL;
@@ -64,7 +65,8 @@ static enum {
     UPLOAD_SAMPLE,
     PLAY_SAMPLE,
     REMOVE_SAMPLE,
-    LIST
+    LIST,
+    MOVE_SINK_INPUT
 } action = NONE;
 
 static void quit(int ret) {
@@ -174,7 +176,7 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_
            "Volume: %s\n"
            "Monitor Source: %u\n"
            "Latency: %0.0f usec\n"
-           "Flags: %s%s\n",
+           "Flags: %s%s%s\n",
            i->index,
            i->name,
            i->driver,
@@ -186,7 +188,8 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_
            i->monitor_source,
            (double) i->latency,
            i->flags & PA_SINK_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
-           i->flags & PA_SINK_LATENCY ? "LATENCY" : "");
+           i->flags & PA_SINK_LATENCY ? "LATENCY " : "",
+           i->flags & PA_SINK_HARDWARE ? "HARDWARE" : "");
 
 }
 
@@ -222,7 +225,7 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int
            "Volume: %s\n"
            "Monitor of Sink: %s\n"
            "Latency: %0.0f usec\n"
-           "Flags: %s%s\n",
+           "Flags: %s%s%s\n",
            i->index,
            i->driver,
            i->name,
@@ -234,7 +237,8 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int
            i->monitor_of_sink != PA_INVALID_INDEX ? t : "no",
            (double) i->latency,
            i->flags & PA_SOURCE_HW_VOLUME_CTRL ? "HW_VOLUME_CTRL " : "",
-           i->flags & PA_SOURCE_LATENCY ? "LATENCY" : "");
+           i->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
+           i->flags & PA_SOURCE_HARDWARE ? "HARDWARE" : "");
 
 }
 
@@ -579,6 +583,10 @@ static void context_state_callback(pa_context *c, void *userdata) {
                     pa_operation_unref(pa_context_get_autoload_info_list(c, get_autoload_info_callback, NULL));
                     break;
 
+                case MOVE_SINK_INPUT:
+                    pa_operation_unref(pa_context_move_sink_input_by_name(c, sink_input_idx, sink_name, simple_callback, NULL));
+                    break;
+
                 default:
                     assert(0);
             }
@@ -607,12 +615,13 @@ static void help(const char *argv0) {
            "%s [options] exit\n"
            "%s [options] upload-sample FILENAME [NAME]\n"
            "%s [options] play-sample NAME [SINK]\n"
+           "%s [options] move-sink-input NAME [SINK]\n"
            "%s [options] remove-sample NAME\n\n"
            "  -h, --help                            Show this help\n"
            "      --version                         Show version\n\n"
            "  -s, --server=SERVER                   The name of the server to connect to\n"
            "  -n, --client-name=NAME                How to call this client on the server\n",
-           argv0, argv0, argv0, argv0, argv0, argv0);
+           argv0, argv0, argv0, argv0, argv0, argv0, argv0);
 }
 
 enum { ARG_VERSION = 256 };
@@ -729,6 +738,15 @@ int main(int argc, char *argv[]) {
             }
 
             sample_name = pa_xstrdup(argv[optind+1]);
+        } else if (!strcmp(argv[optind], "move-sink-input")) {
+            action = MOVE_SINK_INPUT;
+            if (optind+2 >= argc) {
+                fprintf(stderr, "You have to specify a sink input index and a sink\n");
+                goto quit;
+            }
+
+            sink_input_idx = atoi(argv[optind+1]);
+            sink_name = pa_xstrdup(argv[optind+2]);
         }
     }
 
@@ -782,6 +800,7 @@ quit:
     pa_xfree(server);
     pa_xfree(device);
     pa_xfree(sample_name);
+    pa_xfree(sink_name);
 
     return ret;
 }