aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSangchul Lee <sangchul1011@gmail.com>2019-03-18 14:46:13 +0900
committerGeorg Chini <georg@chini.tk>2019-03-26 14:54:15 +0000
commit65cc86f609525a89b740de6b366e35277763e32c (patch)
tree85d912f185c340e76ca031cd52799a7b64b48fda
parent5540f728e52e9c369079e3ac83b8bc55e3519079 (diff)
downloadpulseaudio-65cc86f609525a89b740de6b366e35277763e32c.tar.gz
role-ducking, role-cork: Add use_source_trigger argument
This is added to keep backward compatibility. The default value of this new argument is false. Therefore, triggering by source-output will be activated only if it is set to true explicitly. Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
-rw-r--r--src/modules/module-role-cork.c5
-rw-r--r--src/modules/module-role-ducking.c2
-rw-r--r--src/modules/stream-interaction.c31
3 files changed, 30 insertions, 8 deletions
diff --git a/src/modules/module-role-cork.c b/src/modules/module-role-cork.c
index a13457ef..3d3f5db7 100644
--- a/src/modules/module-role-cork.c
+++ b/src/modules/module-role-cork.c
@@ -32,12 +32,15 @@ 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?>");
+ "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>"
+ );
static const char* const valid_modargs[] = {
"trigger_roles",
"cork_roles",
"global",
+ "use_source_trigger",
NULL
};
diff --git a/src/modules/module-role-ducking.c b/src/modules/module-role-ducking.c
index 1b2ecd73..f494942b 100644
--- a/src/modules/module-role-ducking.c
+++ b/src/modules/module-role-ducking.c
@@ -34,6 +34,7 @@ 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[] = {
@@ -41,6 +42,7 @@ static const char* const valid_modargs[] = {
"ducking_roles",
"global",
"volume",
+ "use_source_trigger",
NULL
};
diff --git a/src/modules/stream-interaction.c b/src/modules/stream-interaction.c
index 96c0ac77..a69b1228 100644
--- a/src/modules/stream-interaction.c
+++ b/src/modules/stream-interaction.c
@@ -48,6 +48,7 @@ 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,
@@ -114,9 +115,14 @@ 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) ? !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;
+ 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;
}
}
@@ -136,7 +142,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 (trigger_role)
+ if (!u->source_trigger || trigger_role)
return trigger_role;
PA_IDXSET_FOREACH(source, u->core->sources, idx)
@@ -274,9 +280,13 @@ 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 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;
+ 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;
+ }
for (j = 0; j < u->n_groups; j++) {
if (u->global) {
@@ -412,6 +422,7 @@ 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);
@@ -580,6 +591,12 @@ 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);