From 4d874753f5ba838b015c69f281e991c7a42381eb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 4 Jun 2009 23:19:48 +0200 Subject: utils: use pa_path_get_filename() where applicable --- src/utils/pactl.c | 14 ++------------ src/utils/pasuspender.c | 5 +---- 2 files changed, 3 insertions(+), 16 deletions(-) (limited to 'src/utils') diff --git a/src/utils/pactl.c b/src/utils/pactl.c index 53c67666..6608c01e 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -802,7 +802,6 @@ enum { int main(int argc, char *argv[]) { pa_mainloop* m = NULL; - char tmp[PATH_MAX]; int ret = 1, c; char *server = NULL, *bn; @@ -882,17 +881,8 @@ int main(int argc, char *argv[]) { if (optind+2 < argc) sample_name = pa_xstrdup(argv[optind+2]); else { - char *f = strrchr(argv[optind+1], '/'); - size_t n; - if (f) - f++; - else - f = argv[optind]; - - n = strcspn(f, "."); - strncpy(tmp, f, n); - tmp[n] = 0; - sample_name = pa_xstrdup(tmp); + char *f = pa_path_get_filename(argv[optind+1]); + sample_name = pa_xstrndup(f, strcspn(f, ".")); } pa_zero(sfi); diff --git a/src/utils/pasuspender.c b/src/utils/pasuspender.c index b4bccd56..c327ee41 100644 --- a/src/utils/pasuspender.c +++ b/src/utils/pasuspender.c @@ -235,10 +235,7 @@ int main(int argc, char *argv[]) { setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR); - if (!(bn = strrchr(argv[0], '/'))) - bn = argv[0]; - else - bn++; + bn = pa_path_get_filename(argv[0]); while ((c = getopt_long(argc, argv, "s:h", long_options, NULL)) != -1) { switch (c) { -- cgit From 6b2ca094ae18110271ef6facd963e5cf11ff1715 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 Jun 2009 04:54:39 +0200 Subject: pactl: implement pactl set-{sink|source}-port --- src/utils/pactl.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 5 deletions(-) (limited to 'src/utils') diff --git a/src/utils/pactl.c b/src/utils/pactl.c index 6608c01e..1ae15c75 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -49,8 +49,21 @@ static pa_context *context = NULL; static pa_mainloop_api *mainloop_api = NULL; -static char *device = NULL, *sample_name = NULL, *sink_name = NULL, *source_name = NULL, *module_name = NULL, *module_args = NULL, *card_name = NULL, *profile_name = NULL; -static uint32_t sink_input_idx = PA_INVALID_INDEX, source_output_idx = PA_INVALID_INDEX; +static char + *device = NULL, + *sample_name = NULL, + *sink_name = NULL, + *source_name = NULL, + *module_name = NULL, + *module_args = NULL, + *card_name = NULL, + *profile_name = NULL, + *port_name = NULL; + +static uint32_t + sink_input_idx = PA_INVALID_INDEX, + source_output_idx = PA_INVALID_INDEX; + static uint32_t module_index; static pa_bool_t suspend; @@ -80,7 +93,9 @@ static enum { UNLOAD_MODULE, SUSPEND_SINK, SUSPEND_SOURCE, - SET_CARD_PROFILE + SET_CARD_PROFILE, + SET_SINK_PORT, + SET_SOURCE_PORT } action = NONE; static void quit(int ret) { @@ -753,6 +768,14 @@ static void context_state_callback(pa_context *c, void *userdata) { pa_operation_unref(pa_context_set_card_profile_by_name(c, card_name, profile_name, simple_callback, NULL)); break; + case SET_SINK_PORT: + pa_operation_unref(pa_context_set_sink_port_by_name(c, sink_name, port_name, simple_callback, NULL)); + break; + + case SET_SOURCE_PORT: + pa_operation_unref(pa_context_set_source_port_by_name(c, source_name, port_name, simple_callback, NULL)); + break; + default: pa_assert_not_reached(); } @@ -788,12 +811,14 @@ static void help(const char *argv0) { "%s [options] unload-module ID\n" "%s [options] suspend-sink [SINK] 1|0\n" "%s [options] suspend-source [SOURCE] 1|0\n" - "%s [options] set-card-profile [CARD] [PROFILE] \n\n" + "%s [options] set-card-profile [CARD] [PROFILE] \n" + "%s [options] set-sink-port [SINK] [PORT] \n" + "%s [options] set-source-port [SOURCE] [PORT] \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); + argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0); } enum { @@ -1017,6 +1042,28 @@ int main(int argc, char *argv[]) { card_name = pa_xstrdup(argv[optind+1]); profile_name = pa_xstrdup(argv[optind+2]); + } else if (pa_streq(argv[optind], "set-sink-port")) { + action = SET_SINK_PORT; + + if (argc != optind+3) { + pa_log(_("You have to specify a sink name/index and a port name\n")); + goto quit; + } + + sink_name = pa_xstrdup(argv[optind+1]); + port_name = pa_xstrdup(argv[optind+2]); + + } else if (pa_streq(argv[optind], "set-source-port")) { + action = SET_SOURCE_PORT; + + if (argc != optind+3) { + pa_log(_("You have to specify a source name/index and a port name\n")); + goto quit; + } + + source_name = pa_xstrdup(argv[optind+1]); + port_name = pa_xstrdup(argv[optind+2]); + } else if (pa_streq(argv[optind], "help")) { help(bn); ret = 0; -- cgit From 75256fb671b6ae8d784e0d6415d292fdbc6482c2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 Jun 2009 23:40:46 +0200 Subject: pactl: show list of supported ports --- src/utils/pactl.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/utils') diff --git a/src/utils/pactl.c b/src/utils/pactl.c index 1ae15c75..c8c3a437 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -254,6 +254,18 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_ pl = pa_proplist_to_string_sep(i->proplist, "\n\t\t")); pa_xfree(pl); + + if (i->ports) { + pa_sink_port_info **p; + + printf(_("\tPorts:\n")); + for (p = i->ports; *p; p++) + printf("\t\t%s: %s (priority. %u)\n", (*p)->name, (*p)->description, (*p)->priority); + } + + if (i->active_port) + printf(_("\tActive Port: %s\n"), + i->active_port->name); } static void get_source_info_callback(pa_context *c, const pa_source_info *i, int is_last, void *userdata) { @@ -334,6 +346,18 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int pl = pa_proplist_to_string_sep(i->proplist, "\n\t\t")); pa_xfree(pl); + + if (i->ports) { + pa_source_port_info **p; + + printf(_("\tPorts:\n")); + for (p = i->ports; *p; p++) + printf("\t\t%s: %s (priority. %u)\n", (*p)->name, (*p)->description, (*p)->priority); + } + + if (i->active_port) + printf(_("\tActive Port: %s\n"), + i->active_port->name); } static void get_module_info_callback(pa_context *c, const pa_module_info *i, int is_last, void *userdata) { -- cgit From 0955e3d45b6e992308e2d51fcbf28a9f9376f788 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Sun, 5 Apr 2009 02:13:43 +0300 Subject: Base mainloop on pa_rtclock_now() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the mainloop to monotonic based time events. Introduces 4 helper functions: pa_{context,core}_rttime_{new,restart}(), that fill correctly a timeval with the rtclock flag set if the mainloop supports it. Both mainloop-test and mainloop-test-glib works with rt and timeval based time events. PulseAudio and clients should be fully functional. This patch has received several iterations, and this one as been largely untested. Signed-off-by: Marc-André Lureau --- src/utils/pabrowse.c | 3 ++- src/utils/pacat.c | 19 +++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) (limited to 'src/utils') diff --git a/src/utils/pabrowse.c b/src/utils/pabrowse.c index a6487b88..a349e414 100644 --- a/src/utils/pabrowse.c +++ b/src/utils/pabrowse.c @@ -27,8 +27,9 @@ #include #include -#include #include +#include +#include #include diff --git a/src/utils/pacat.c b/src/utils/pacat.c index 0b6df3d8..f00a32eb 100644 --- a/src/utils/pacat.c +++ b/src/utils/pacat.c @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -583,9 +584,7 @@ static void sigusr1_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int s pa_operation_unref(pa_stream_update_timing_info(stream, stream_update_timing_callback, NULL)); } -static void time_event_callback(pa_mainloop_api*m, pa_time_event *e, const struct timeval *tv, void *userdata) { - struct timeval next; - +static void time_event_callback(pa_mainloop_api *m, pa_time_event *e, const struct timeval *t, void *userdata) { if (stream && pa_stream_get_state(stream) == PA_STREAM_READY) { pa_operation *o; if (!(o = pa_stream_update_timing_info(stream, stream_update_timing_callback, NULL))) @@ -594,10 +593,7 @@ static void time_event_callback(pa_mainloop_api*m, pa_time_event *e, const struc pa_operation_unref(o); } - pa_gettimeofday(&next); - pa_timeval_add(&next, TIME_EVENT_USEC); - - m->time_restart(e, &next); + pa_context_rttime_restart(context, e, pa_rtclock_now() + TIME_EVENT_USEC); } static void help(const char *argv0) { @@ -1068,13 +1064,8 @@ int main(int argc, char *argv[]) { } if (verbose) { - struct timeval tv; - - pa_gettimeofday(&tv); - pa_timeval_add(&tv, TIME_EVENT_USEC); - - if (!(time_event = mainloop_api->time_new(mainloop_api, &tv, time_event_callback, NULL))) { - pa_log(_("time_new() failed.\n")); + if (!(time_event = pa_context_rttime_new(context, pa_rtclock_now() + TIME_EVENT_USEC, time_event_callback, NULL))) { + pa_log(_("pa_context_rttime_new() failed.\n")); goto quit; } } -- cgit