[pulseaudio-discuss] [PATCH 1/2] loopback: Add hooks to track port latency offsets

Tanu Kaskinen tanuk at iki.fi
Fri Apr 7 12:55:18 UTC 2017


On Fri, 2017-04-07 at 09:37 +0200, Georg Chini wrote:
> The previous patch assumed constant port latency offsets. The offsets can
> however be changed by the user, therefore these changes need to be tracked
> as well. This patch adds the necessary hooks.
> ---
>  src/modules/module-loopback.c | 38 ++++++++++++++++++++++++++++++++++++--
>  src/pulsecore/core.h          |  2 ++
>  src/pulsecore/sink.c          |  2 ++
>  src/pulsecore/source.c        |  2 ++
>  4 files changed, 42 insertions(+), 2 deletions(-)
> 
> diff --git a/src/modules/module-loopback.c b/src/modules/module-loopback.c
> index 442bc8a9..e21a3b3b 100644
> --- a/src/modules/module-loopback.c
> +++ b/src/modules/module-loopback.c
> @@ -1087,7 +1087,7 @@ static int loopback_process_msg_cb(pa_msgobject *o, int code, void *userdata, in
>                   * source implementations. */
>                  pa_log_warn("Source minimum latency increased to %0.2f ms", (double)current_latency / PA_USEC_PER_MSEC);
>                  u->configured_source_latency = current_latency;
> -                update_latency_boundaries(u, u->source_output->source, u->sink_input->sink, false);
> +                update_latency_boundaries(u, u->source_output->source, u->sink_input->sink, true);

Now the print_msg parameter is always true. Can it be removed?

>              }
>  
>              return 0;
> @@ -1102,7 +1102,7 @@ static int loopback_process_msg_cb(pa_msgobject *o, int code, void *userdata, in
>                   * implementations. */
>                  pa_log_warn("Sink minimum latency increased to %0.2f ms", (double)current_latency / PA_USEC_PER_MSEC);
>                  u->configured_sink_latency = current_latency;
> -                update_latency_boundaries(u, u->source_output->source, u->sink_input->sink, false);
> +                update_latency_boundaries(u, u->source_output->source, u->sink_input->sink, true);
>              }
>  
>              return 0;
> @@ -1111,6 +1111,34 @@ static int loopback_process_msg_cb(pa_msgobject *o, int code, void *userdata, in
>      return 0;
>  }
>  
> +static pa_hook_result_t sink_port_latency_offset_changed_cb(pa_core *core, pa_sink *sink, struct userdata *u) {
> +
> +    if (!u->sink_input->sink)
> +        return PA_HOOK_OK;

This looks unnecessary to me. If u->sink_input->sink is NULL, the next
check will anyway return PA_HOOK_OK.

> +
> +    if (sink != u->sink_input->sink)
> +        return PA_HOOK_OK;
> +
> +    u->sink_latency_offset = sink->port_latency_offset;
> +    update_minimum_latency(u, sink, true);
> +
> +    return PA_HOOK_OK;
> +}
> +
> +static pa_hook_result_t source_port_latency_offset_changed_cb(pa_core *core, pa_source *source, struct userdata *u) {
> +
> +    if (!u->source_output->source)
> +        return PA_HOOK_OK;

Same as above.

-- 
Tanu

https://www.patreon.com/tanuk


More information about the pulseaudio-discuss mailing list