[pulseaudio-commits] r1667 - /branches/lennart/src/utils/pactl.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Wed Aug 15 12:57:13 PDT 2007


Author: lennart
Date: Wed Aug 15 21:57:12 2007
New Revision: 1667

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1667&root=3Dpulseaudio&vi=
ew=3Drev
Log:
add new commands suspend-source, suspend-sink

Modified:
    branches/lennart/src/utils/pactl.c

Modified: branches/lennart/src/utils/pactl.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/utils/pact=
l.c?rev=3D1667&root=3Dpulseaudio&r1=3D1666&r2=3D1667&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/utils/pactl.c (original)
+++ branches/lennart/src/utils/pactl.c Wed Aug 15 21:57:12 2007
@@ -51,6 +51,7 @@
 static char *device =3D NULL, *sample_name =3D NULL, *sink_name =3D NULL, =
*source_name =3D NULL, *module_name =3D NULL, *module_args =3D NULL;
 static uint32_t sink_input_idx =3D PA_INVALID_INDEX, source_output_idx =3D=
 PA_INVALID_INDEX;
 static uint32_t module_index;
+static int suspend;
 =

 static SNDFILE *sndfile =3D NULL;
 static pa_stream *sample_stream =3D NULL;
@@ -73,6 +74,8 @@
     MOVE_SOURCE_OUTPUT,
     LOAD_MODULE,
     UNLOAD_MODULE,
+    SUSPEND_SINK,
+    SUSPEND_SOURCE,
 } action =3D NONE;
 =

 static void quit(int ret) {
@@ -357,7 +360,7 @@
            i->sink,
            pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec),
            pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map),
-           pa_cvolume_snprint(cv, sizeof(cv), &i->volume),
+           i->mute ? "muted" : pa_cvolume_snprint(cv, sizeof(cv), &i->volu=
me),
            (double) i->buffer_usec,
            (double) i->sink_usec,
            i->resample_method ? i->resample_method : "n/a");
@@ -616,6 +619,20 @@
                 case UNLOAD_MODULE:
                     pa_operation_unref(pa_context_unload_module(c, module_=
index, simple_callback, NULL));
                     break;
+
+                case SUSPEND_SINK:
+                    if (sink_name)
+                        pa_operation_unref(pa_context_suspend_sink_by_name=
(c, sink_name, suspend, simple_callback, NULL));
+                    else
+                        pa_operation_unref(pa_context_suspend_sink_by_inde=
x(c, PA_INVALID_INDEX, suspend, simple_callback, NULL));
+                    break;
+
+                case SUSPEND_SOURCE:
+                    if (source_name)
+                        pa_operation_unref(pa_context_suspend_source_by_na=
me(c, source_name, suspend, simple_callback, NULL));
+                    else
+                        pa_operation_unref(pa_context_suspend_source_by_in=
dex(c, PA_INVALID_INDEX, suspend, simple_callback, NULL));
+                    break;
                     =

                 default:
                     assert(0);
@@ -649,12 +666,14 @@
            "%s [options] move-source-output ID SOURCE\n"
            "%s [options] remove-sample NAME\n"
            "%s [options] load-module NAME [ARGS ...]\n"
-           "%s [options] unload-module ID\n\n"
+           "%s [options] unload-module ID\n"
+           "%s [options] suspend-sink [SINK] 1|0\n"
+           "%s [options] suspend-source [SOURCE] 1|0\n\n"
            "  -h, --help                            Show this help\n"
            "      --version                         Show version\n\n"
            "  -s, --server=3DSERVER                   The name of the serv=
er to connect to\n"
            "  -n, --client-name=3DNAME                How to call this cli=
ent on the server\n",
-           argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, =
argv0);
+           argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, =
argv0, argv0, argv0);
 }
 =

 enum { ARG_VERSION =3D 256 };
@@ -817,13 +836,38 @@
             action =3D UNLOAD_MODULE;
             =

             if (argc !=3D optind+2) {
-                fprintf(stderr, "You have to specify a source output index=
 and a source\n");
+                fprintf(stderr, "You have to specify a module index\n");
                 goto quit;
             }
 =

             module_index =3D atoi(argv[optind+1]);
+            =

+        } else if (!strcmp(argv[optind], "suspend-sink")) {
+            action =3D SUSPEND_SINK;
+
+            if (argc > optind+3 || optind+1 >=3D argc) {
+                fprintf(stderr, "You may not specify more than one sink. Y=
ou have to specify at least one boolean value.\n");
+                goto quit;
+            }
+            =

+            suspend =3D !!atoi(argv[argc-1]);
+            =

+            if (argc > optind+2)
+                sink_name =3D pa_xstrdup(argv[optind+1]);
+                =

+        } else if (!strcmp(argv[optind], "suspend-source")) {
+            action =3D SUSPEND_SOURCE;
+
+            if (argc > optind+3 || optind+1 >=3D argc) {
+                fprintf(stderr, "You may not specify more than one source.=
 You have to specify at least one boolean value.\n");
+                goto quit;
+            }
+
+            suspend =3D !!atoi(argv[argc-1]);
+
+            if (argc > optind+2)
+                source_name =3D pa_xstrdup(argv[optind+1]);
         }
-            =

     }
 =

     if (action =3D=3D NONE) {
@@ -879,6 +923,7 @@
     pa_xfree(sink_name);
     pa_xfree(source_name);
     pa_xfree(module_args);
+    pa_xfree(client_name);
 =

     return ret;
 }




More information about the pulseaudio-commits mailing list