Skip to content

Commit

Permalink
pending: module-role-ducking: Add argument duck_while_corked
Browse files Browse the repository at this point in the history
With this enabled when trigger stream is available but
in corked state trigger is already applied to interaction
streams. This is useful when trigger stream pauses for
a while before playing, so that the trigger happens
slightly earlier.

Signed-off-by: Juho Hämäläinen <juho.hamalainen@jolla.com>
  • Loading branch information
jusa committed Feb 24, 2021
1 parent bd6b687 commit 13c4f0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/modules/module-role-ducking.c
Expand Up @@ -34,13 +34,15 @@ PA_MODULE_USAGE(
"ducking_roles=<Comma(and slash) separated list of roles which will be ducked. Slash can divide the roles into groups>"
"global=<Should we operate globally or only inside the same device?>"
"volume=<Volume for the attenuated streams. Default: -20dB. If trigger_roles and ducking_roles are separated by slash, use slash for dividing volume group>"
"duck_while_corked=<Duck ducking_roles even if trigger_roles are corked. Default false>"
);

static const char* const valid_modargs[] = {
"trigger_roles",
"ducking_roles",
"global",
"volume",
"duck_while_corked",
NULL
};

Expand Down
16 changes: 10 additions & 6 deletions src/modules/stream-interaction.c
Expand Up @@ -56,8 +56,9 @@ struct group {
struct userdata {
pa_core *core;
PA_LLIST_HEAD(struct group, groups);
bool global:1;
bool duck:1;
bool global;
bool duck;
bool duck_while_corked;
};

static const char *sink_input_role(pa_sink_input *sink_input) {
Expand All @@ -84,7 +85,7 @@ static bool update_group_active(struct userdata *u, struct group *g) {
if (pa_hashmap_size(g->trigger_state) > 0) {
PA_HASHMAP_FOREACH_KV(sink_input, value, g->trigger_state, state) {
if (!sink_input->muted &&
sink_input->state != PA_SINK_INPUT_CORKED) {
(u->duck_while_corked || sink_input->state != PA_SINK_INPUT_CORKED)) {
new_active = true;
break;
}
Expand Down Expand Up @@ -463,7 +464,6 @@ static int count_groups(pa_modargs *ma, const char *module_argument) {
int pa_stream_interaction_init(pa_module *m, const char* const v_modargs[]) {
pa_modargs *ma = NULL;
struct userdata *u;
bool global = false;
uint32_t i = 0;
uint32_t group_count_tr = 0;
struct group *last = NULL;
Expand Down Expand Up @@ -539,11 +539,15 @@ int pa_stream_interaction_init(pa_module *m, const char* const v_modargs[]) {
if (!group_parse_roles(ma, "volume", group_value_add_volume, u->groups))
goto fail;

if (pa_modargs_get_value_boolean(ma, "global", &global) < 0) {
if (pa_modargs_get_value_boolean(ma, "global", &u->global) < 0) {
pa_log("Invalid boolean parameter: global");
goto fail;
}
u->global = global;

if (pa_modargs_get_value_boolean(ma, "duck_while_corked", &u->duck_while_corked) < 0) {
pa_log("Invalid boolean parameter: duck_while_corked");
goto fail;
}

pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_put_cb, u);
pa_module_hook_connect(m, &m->core->hooks[PA_CORE_HOOK_SINK_INPUT_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_unlink_cb, u);
Expand Down

0 comments on commit 13c4f0f

Please sign in to comment.