[pulseaudio-discuss] [PATCH 3/3] module-role-ducking: Add argument duck_while_corked
Juho Hämäläinen
jusa at hilvi.org
Fri Jul 13 08:21:05 UTC 2018
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 <jusa at hilvi.org>
---
src/modules/module-role-ducking.c | 2 ++
src/modules/stream-interaction.c | 16 ++++++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/modules/module-role-ducking.c b/src/modules/module-role-ducking.c
index 1b2ecd7..50c23b7 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>"
+ "duck_while_corked=<Duck ducking_roles even if trigger_roles are corked. Default false>"
);
static const char* const valid_modargs[] = {
@@ -41,6 +42,7 @@ static const char* const valid_modargs[] = {
"ducking_roles",
"global",
"volume",
+ "duck_while_corked",
NULL
};
diff --git a/src/modules/stream-interaction.c b/src/modules/stream-interaction.c
index c30a8c0..dc727dc 100644
--- a/src/modules/stream-interaction.c
+++ b/src/modules/stream-interaction.c
@@ -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) {
@@ -85,7 +86,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;
}
@@ -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;
@@ -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);
--
2.7.4
More information about the pulseaudio-discuss
mailing list