Skip to content

Commit

Permalink
Revert "role-ducking, role-cork: Add use_source_trigger argument"
Browse files Browse the repository at this point in the history
This reverts commit 65cc86f.
  • Loading branch information
jusa committed Feb 24, 2021
1 parent f50e835 commit 4d6a114
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 30 deletions.
5 changes: 1 addition & 4 deletions src/modules/module-role-cork.c
Expand Up @@ -32,15 +32,12 @@ PA_MODULE_LOAD_ONCE(true);
PA_MODULE_USAGE(
"trigger_roles=<Comma separated list of roles which will trigger a cork> "
"cork_roles=<Comma separated list of roles which will be corked> "
"global=<Should we operate globally or only inside the same device?>"
"use_source_trigger=<Do we trigger a cork by a role of source-output as well as sink-input's? Default: false>"
);
"global=<Should we operate globally or only inside the same device?>");

static const char* const valid_modargs[] = {
"trigger_roles",
"cork_roles",
"global",
"use_source_trigger",
NULL
};

Expand Down
2 changes: 0 additions & 2 deletions src/modules/module-role-ducking.c
Expand Up @@ -34,15 +34,13 @@ 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>"
"use_source_trigger=<Do we trigger a ducking by a role of source-output as well as sink-input's? Default: false>"
);

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

Expand Down
31 changes: 7 additions & 24 deletions src/modules/stream-interaction.c
Expand Up @@ -48,7 +48,6 @@ struct userdata {
struct group **groups;
bool global:1;
bool duck:1;
bool source_trigger:1;
pa_hook_slot
*sink_input_put_slot,
*sink_input_unlink_slot,
Expand Down Expand Up @@ -115,14 +114,9 @@ static const char *find_trigger_stream(struct userdata *u, pa_object *device, pa
if (!(trigger_role = get_trigger_role(u, PA_OBJECT(j), g)))
continue;

if (pa_sink_isinstance(device)) {
if (!PA_SINK_INPUT(j)->muted &&
PA_SINK_INPUT(j)->state != PA_SINK_INPUT_CORKED)
return trigger_role;
} else {
if (!PA_SOURCE_OUTPUT(j)->muted &&
PA_SOURCE_OUTPUT(j)->state != PA_SOURCE_OUTPUT_CORKED)
return trigger_role;
if (pa_sink_isinstance(device) ? !PA_SINK_INPUT(j)->muted && PA_SINK_INPUT(j)->state != PA_SINK_INPUT_CORKED :
!PA_SOURCE_OUTPUT(j)->muted && PA_SOURCE_OUTPUT(j)->state != PA_SOURCE_OUTPUT_CORKED) {
return trigger_role;
}
}

Expand All @@ -142,7 +136,7 @@ static const char *find_global_trigger_stream(struct userdata *u, pa_object *ign
if ((trigger_role = find_trigger_stream(u, PA_OBJECT(sink), ignore_stream, g)))
break;

if (!u->source_trigger || trigger_role)
if (trigger_role)
return trigger_role;

PA_IDXSET_FOREACH(source, u->core->sources, idx)
Expand Down Expand Up @@ -280,13 +274,9 @@ static pa_hook_result_t process(struct userdata *u, pa_object *stream, bool crea
(pa_source_output_isinstance(stream) && !PA_SOURCE_OUTPUT(stream)->source))
return PA_HOOK_OK;

if (pa_source_output_isinstance(stream)) {
if (!u->source_trigger)
return PA_HOOK_OK;
/* If it is triggered from source-output with false of global option, no need to apply interaction. */
if (!u->global)
return PA_HOOK_OK;
}
/* If it is triggered from source-output with false of global option, no need to apply interaction. */
if (!u->global && pa_source_output_isinstance(stream))
return PA_HOOK_OK;

for (j = 0; j < u->n_groups; j++) {
if (u->global) {
Expand Down Expand Up @@ -422,7 +412,6 @@ int pa_stream_interaction_init(pa_module *m, const char* const v_modargs[]) {
const char *roles;
char *roles_in_group = NULL;
bool global = false;
bool source_trigger = false;
uint32_t i = 0;

pa_assert(m);
Expand Down Expand Up @@ -591,12 +580,6 @@ int pa_stream_interaction_init(pa_module *m, const char* const v_modargs[]) {
}
u->global = global;

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

u->sink_input_put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_put_cb, u);
u->sink_input_unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_UNLINK], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_unlink_cb, u);
u->sink_input_move_start_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_START], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_move_start_cb, u);
Expand Down

0 comments on commit 4d6a114

Please sign in to comment.