[pulseaudio-commits] r1659 - /branches/lennart/src/utils/pactl.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Mon Aug 13 16:34:47 PDT 2007
Author: lennart
Date: Tue Aug 14 01:34:46 2007
New Revision: 1659
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1659&root=3Dpulseaudio&vi=
ew=3Drev
Log:
add load-module and unload-module commands to pactl
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=3D1659&root=3Dpulseaudio&r1=3D1658&r2=3D1659&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 Tue Aug 14 01:34:46 2007
@@ -48,8 +48,9 @@
static pa_context *context =3D NULL;
static pa_mainloop_api *mainloop_api =3D NULL;
=
-static char *device =3D NULL, *sample_name =3D NULL, *sink_name =3D NULL, =
*source_name =3D NULL;
+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 SNDFILE *sndfile =3D NULL;
static pa_stream *sample_stream =3D NULL;
@@ -69,7 +70,9 @@
REMOVE_SAMPLE,
LIST,
MOVE_SINK_INPUT,
- MOVE_SOURCE_OUTPUT
+ MOVE_SOURCE_OUTPUT,
+ LOAD_MODULE,
+ UNLOAD_MODULE,
} action =3D NONE;
=
static void quit(int ret) {
@@ -492,6 +495,18 @@
complete_action();
}
=
+static void index_callback(pa_context *c, uint32_t idx, void *userdata) {
+ if (idx =3D=3D PA_INVALID_INDEX) {
+ fprintf(stderr, "Failure: %s\n", pa_strerror(pa_context_errno(c)));
+ quit(1);
+ return;
+ }
+
+ printf("%u\n", idx);
+ =
+ complete_action();
+}
+
static void stream_state_callback(pa_stream *s, void *userdata) {
assert(s);
=
@@ -594,6 +609,14 @@
pa_operation_unref(pa_context_move_source_output_by_na=
me(c, source_output_idx, source_name, simple_callback, NULL));
break;
=
+ case LOAD_MODULE:
+ pa_operation_unref(pa_context_load_module(c, module_na=
me, module_args, index_callback, NULL));
+ break;
+
+ case UNLOAD_MODULE:
+ pa_operation_unref(pa_context_unload_module(c, module_=
index, simple_callback, NULL));
+ break;
+ =
default:
assert(0);
}
@@ -624,12 +647,14 @@
"%s [options] play-sample NAME [SINK]\n"
"%s [options] move-sink-input ID SINK\n"
"%s [options] move-source-output ID SOURCE\n"
- "%s [options] remove-sample NAME\n\n"
+ "%s [options] remove-sample NAME\n"
+ "%s [options] load-module NAME [ARGS ...]\n"
+ "%s [options] unload-module ID\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);
}
=
enum { ARG_VERSION =3D 256 };
@@ -728,7 +753,7 @@
sample_length =3D sfinfo.frames*pa_frame_size(&sample_spec);
} else if (!strcmp(argv[optind], "play-sample")) {
action =3D PLAY_SAMPLE;
- if (optind+1 >=3D argc) {
+ if (argc !=3D optind+2 && argc !=3D optind+3) {
fprintf(stderr, "You have to specify a sample name to play=
\n");
goto quit;
}
@@ -740,7 +765,7 @@
=
} else if (!strcmp(argv[optind], "remove-sample")) {
action =3D REMOVE_SAMPLE;
- if (optind+1 >=3D argc) {
+ if (argc !=3D optind+2) {
fprintf(stderr, "You have to specify a sample name to remo=
ve\n");
goto quit;
}
@@ -748,7 +773,7 @@
sample_name =3D pa_xstrdup(argv[optind+1]);
} else if (!strcmp(argv[optind], "move-sink-input")) {
action =3D MOVE_SINK_INPUT;
- if (optind+2 >=3D argc) {
+ if (argc !=3D optind+3) {
fprintf(stderr, "You have to specify a sink input index an=
d a sink\n");
goto quit;
}
@@ -757,14 +782,48 @@
sink_name =3D pa_xstrdup(argv[optind+2]);
} else if (!strcmp(argv[optind], "move-source-output")) {
action =3D MOVE_SOURCE_OUTPUT;
- if (optind+2 >=3D argc) {
+ if (argc !=3D optind+3) {
fprintf(stderr, "You have to specify a source output index=
and a source\n");
goto quit;
}
=
source_output_idx =3D atoi(argv[optind+1]);
source_name =3D pa_xstrdup(argv[optind+2]);
+ } else if (!strcmp(argv[optind], "load-module")) {
+ int i;
+ size_t n =3D 0;
+ char *p;
+
+ action =3D LOAD_MODULE;
+ =
+ if (argc <=3D optind+1) {
+ fprintf(stderr, "You have to specify a module name and arg=
uments.\n");
+ goto quit;
+ }
+
+ module_name =3D argv[optind+1];
+ =
+ for (i =3D optind+2; i < argc; i++)
+ n +=3D strlen(argv[i])+1;
+
+ if (n > 0) {
+ p =3D module_args =3D pa_xnew0(char, n);
+ =
+ for (i =3D optind+2; i < argc; i++)
+ p +=3D sprintf(p, "%s%s", p =3D=3D module_args ? "" : =
" ", argv[i]);
+ }
+
+ } else if (!strcmp(argv[optind], "unload-module")) {
+ action =3D UNLOAD_MODULE;
+ =
+ if (argc !=3D optind+2) {
+ fprintf(stderr, "You have to specify a source output index=
and a source\n");
+ goto quit;
+ }
+
+ module_index =3D atoi(argv[optind+1]);
}
+ =
}
=
if (action =3D=3D NONE) {
@@ -819,6 +878,7 @@
pa_xfree(sample_name);
pa_xfree(sink_name);
pa_xfree(source_name);
+ pa_xfree(module_args);
=
return ret;
}
More information about the pulseaudio-commits
mailing list