From: "poljar (Damir Jelic)" <poljarinho@xxxxxxxxx> This introduces a new command to allow setting the latency offset. Also the list commands now show the latency offset on the ports. --- man/pactl.1.xml.in | 6 ++++++ src/utils/pactl.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/man/pactl.1.xml.in b/man/pactl.1.xml.in index 5670f43..6664dd2 100644 --- a/man/pactl.1.xml.in +++ b/man/pactl.1.xml.in @@ -168,6 +168,12 @@ USA. </option> <option> + <p><opt>set-port-latency-offset</opt> <arg>CARD</arg> <arg>PORT</arg> <arg>OFFSET</arg></p> + <optdesc><p>Set a latency offset to a specified port (identified by its symbolic name) that belongs to a card (identified by its symbolic name or numerical index). + <arg>OFFSET</arg> is a number which represents the latency offset in microseconds</p></optdesc> + </option> + + <option> <p><opt>set-source-port</opt> <arg>SOURCE</arg> <arg>PORT</arg></p> <optdesc><p>Set the specified source (identified by its symbolic name or numerical index) to the specified port (identified by its symbolic name).</p></optdesc> </option> diff --git a/src/utils/pactl.c b/src/utils/pactl.c index 5346b94..89fe603 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -67,6 +67,7 @@ static uint32_t static pa_bool_t short_list_format = FALSE; static uint32_t module_index; +static double latency_offset; static pa_bool_t suspend; static pa_bool_t mute; static pa_volume_t volume; @@ -117,6 +118,7 @@ static enum { SET_SINK_INPUT_MUTE, SET_SOURCE_OUTPUT_MUTE, SET_SINK_FORMATS, + SET_PORT_LATENCY_OFFSET, SUBSCRIBE } action = NONE; @@ -318,7 +320,8 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_ printf(_("\tPorts:\n")); for (p = i->ports; *p; p++) - printf("\t\t%s: %s (priority: %u%s)\n", (*p)->name, (*p)->description, (*p)->priority, + printf("\t\t%s: %s (priority: %u, offset: %.2f usec%s)\n", (*p)->name, + (*p)->description, (*p)->priority, (double) (*p)->latency_offset, get_available_str_ynonly((*p)->available)); } @@ -430,7 +433,8 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int printf(_("\tPorts:\n")); for (p = i->ports; *p; p++) - printf("\t\t%s: %s (priority: %u%s)\n", (*p)->name, (*p)->description, (*p)->priority, + printf("\t\t%s: %s (priority: %u, offset: %.2f usec%s)\n", (*p)->name, + (*p)->description, (*p)->priority, (double) (*p)->latency_offset, get_available_str_ynonly((*p)->available)); } @@ -589,7 +593,8 @@ static void get_card_info_callback(pa_context *c, const pa_card_info *i, int is_ printf(_("\tPorts:\n")); for (p = i->ports; *p; p++) { pa_card_profile_info **pr = (*p)->profiles; - printf(_("\t\t%s: %s (priority: %u%s)\n"), (*p)->name, (*p)->description, (*p)->priority, + printf("\t\t%s: %s (priority: %u, offset: %.2f usec%s)\n", (*p)->name, + (*p)->description, (*p)->priority, (double) (*p)->latency_offset, get_available_str_ynonly((*p)->available)); if (pr) { @@ -1270,6 +1275,10 @@ static void context_state_callback(pa_context *c, void *userdata) { set_sink_formats(c, sink_idx, formats); break; + case SET_PORT_LATENCY_OFFSET: + pa_operation_unref(pa_context_set_port_latency_offset(c, card_name, port_name, (pa_usec_t) latency_offset, simple_callback, NULL)); + break; + case SUBSCRIBE: pa_context_set_subscribe_callback(c, context_subscribe_callback, NULL); @@ -1384,6 +1393,7 @@ static void help(const char *argv0) { 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|source-output)-mute", _("#N 1|0")); printf("%s %s %s %s\n", argv0, _("[options]"), "set-sink-formats", _("#N FORMATS")); + printf("%s %s %s %s\n", argv0, _("[options]"), "set-port-latency-offset", _("CARD-NAME|CARD-#N PORT OFFSET")); printf("%s %s %s\n", argv0, _("[options]"), "subscribe"); printf(_("\n" @@ -1812,6 +1822,19 @@ int main(int argc, char *argv[]) { action = SET_SINK_FORMATS; formats = pa_xstrdup(argv[optind+2]); + } else if (pa_streq(argv[optind], "set-port-latency-offset")) { + action = SET_PORT_LATENCY_OFFSET; + + if (argc != optind+4) { + pa_log(_("You have to specify a card name/index, a port name and a latency offset")); + goto quit; + } + + card_name = pa_xstrdup(argv[optind+1]); + port_name = pa_xstrdup(argv[optind+2]); + if (pa_atod(argv[optind + 3], &latency_offset) < 0) + latency_offset = 0; + } else if (pa_streq(argv[optind], "help")) { help(bn); ret = 0; -- 1.7.11