[pulseaudio-discuss] [PATCH 8/9] role-cork: add ducking functionality to stream-interaction.c

Tanu Kaskinen tanuk at iki.fi
Thu Mar 17 12:21:47 UTC 2016


On Thu, 2015-03-26 at 21:54 +0100, Georg Chini wrote:
> ---
>  src/modules/stream-interaction.c | 54 +++++++++++++++++++++++++++++++---------
>  1 file changed, 42 insertions(+), 12 deletions(-)

module-role-ducking has one change that was added after you submitted
this patch:
https://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/?id=d049c2941e6aef5ff33bcd0b4adece12289302b7

If/when you resubmit this patch, please include that change. (I hope
you still are willing to work on this despite the unreasonable time
that it took for me to review this patch.)

All preceding patches have been applied, by the way.

> -static void cork_stream(struct userdata *u, pa_sink_input *i, const char *interaction_role, const char *trigger_role) {
> +static void cork_or_duck(struct userdata *u, pa_sink_input *i, const char *interaction_role,  const char *trigger_role, bool interaction_applied) {
>  
> -    pa_log_debug("Found a '%s' stream that corks/mutes a '%s' stream.", trigger_role, interaction_role);
> -    pa_sink_input_set_mute(i, true, false);
> -    pa_sink_input_send_event(i, PA_STREAM_EVENT_REQUEST_CORK, NULL);
> +    if (u->duck && !interaction_applied) {
> +        pa_cvolume vol;
> +        vol.channels = 1;
> +        vol.values[0] = u->volume;
> +
> +        pa_log_debug("Found a '%s' stream that ducks a '%s' stream.", trigger_role, interaction_role);
> +        pa_sink_input_add_volume_factor(i, u->name, &vol);
> +    }
> +
> +    else if (!u->duck) {

"else" should be on the same line as the closing bracket. If you want
to add an empty line, add it before the closing bracket.

> @@ -136,11 +155,11 @@ static inline void apply_interaction_to_sink(struct userdata *u, pa_sink *s, con
>              if (!interaction_applied)
>                  pa_hashmap_put(u->interaction_state, j, PA_INT_TO_PTR(1));
>  
> -            cork_stream(u, j, role, new_trigger);
> +            cork_or_duck(u, j, role, new_trigger, interaction_applied);

This code is preceded by this if condition:

        if (new_trigger && !corked && !j->muted) {

So if the stream is corked or muted, no ducking will happen. That
doesn't seem right.

-- 
Tanu


More information about the pulseaudio-discuss mailing list