[pulseaudio-discuss] [PATCH] pactl: Add set-source-output-mute command

Maarten Bosmans mkbosmans at gmail.com
Mon Aug 15 13:05:41 PDT 2011


---
 man/pactl.1.xml.in |    5 +++++
 src/utils/pactl.c  |   28 +++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/man/pactl.1.xml.in b/man/pactl.1.xml.in
index f0060fb..688ac38 100644
--- a/man/pactl.1.xml.in
+++ b/man/pactl.1.xml.in
@@ -218,6 +218,11 @@ USA.
     </option>
 
     <option>
+      <p><opt>set-source-output-mute</opt> <arg>INPUT</arg> <arg>1|0</arg></p>
+      <optdesc><p>Set the mute status of the specified source output (identified by its numerical index).</p></optdesc>
+    </option>
+
+    <option>
       <p><opt>set-sink-formats</opt> <arg>SINK</arg> <arg>FORMATS</arg></p>
       <optdesc><p>Set the supported formats of the specified sink (identified by its numerical index) if supported by the sink.
       <arg>FORMATS</arg> is specified as a semi-colon (;) separated list of formats in the form
diff --git a/src/utils/pactl.c b/src/utils/pactl.c
index 947c6e9..7622fe4 100644
--- a/src/utils/pactl.c
+++ b/src/utils/pactl.c
@@ -114,6 +114,7 @@ static enum {
     SET_SINK_MUTE,
     SET_SOURCE_MUTE,
     SET_SINK_INPUT_MUTE,
+    SET_SOURCE_OUTPUT_MUTE,
     SET_SINK_FORMATS,
     SUBSCRIBE
 } action = NONE;
@@ -1159,6 +1160,10 @@ static void context_state_callback(pa_context *c, void *userdata) {
                     pa_operation_unref(pa_context_set_sink_input_mute(c, sink_input_idx, mute, simple_callback, NULL));
                     break;
 
+                case SET_SOURCE_OUTPUT_MUTE:
+                    pa_operation_unref(pa_context_set_source_output_mute(c, source_output_idx, mute, simple_callback, NULL));
+                    break;
+
                 case SET_SINK_VOLUME:
                     if ((volume_flags & VOL_RELATIVE) == VOL_RELATIVE) {
                         pa_operation_unref(pa_context_get_sink_info_by_name(c, sink_name, get_sink_volume_callback, NULL));
@@ -1315,7 +1320,7 @@ static void help(const char *argv0) {
     printf("%s %s %s %s\n", argv0, _("[options]"), "set-(sink|source)-volume", _("NAME|#N VOLUME"));
     printf("%s %s %s %s\n", argv0, _("[options]"), "set-(sink-input|source-output)-volume", _("#N VOLUME"));
     printf("%s %s %s %s\n", argv0, _("[options]"), "set-(sink|source)-mute", _("NAME|#N 1|0"));
-    printf("%s %s %s %s\n", argv0, _("[options]"), "set-sink-input-mute", _("#N 1|0"));
+    printf("%s %s %s %s\n", argv0, _("[options]"), "set-(sink-input|source-output)-mute", _("#N 1|0"));
     printf("%s %s %s %s\n", argv0, _("[options]"), "set-sink-formats", _("#N FORMATS"));
     printf("%s %s %s\n",    argv0, _("[options]"), "subscribe");
 
@@ -1705,6 +1710,27 @@ int main(int argc, char *argv[]) {
 
             mute = b;
 
+        } else if (pa_streq(argv[optind], "set-source-output-mute")) {
+            int b;
+            action = SET_SOURCE_OUTPUT_MUTE;
+
+            if (argc != optind+3) {
+                pa_log(_("You have to specify a source output index and a mute boolean"));
+                goto quit;
+            }
+
+            if (pa_atou(argv[optind+1], &source_output_idx) < 0) {
+                pa_log(_("Invalid source output index specification"));
+                goto quit;
+            }
+
+            if ((b = pa_parse_boolean(argv[optind+2])) < 0) {
+                pa_log(_("Invalid mute specification"));
+                goto quit;
+            }
+
+            mute = b;
+
         } else if (pa_streq(argv[optind], "subscribe"))
 
             action = SUBSCRIBE;
-- 
1.7.4.1



More information about the pulseaudio-discuss mailing list