From 3f8fb6e4dc9a272c0cdb7bcfa90730a85fd9a9d0 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Wed, 8 Sep 2021 18:15:23 +0300 Subject: [PATCH] media-session: don't bluez-autoswitch for suspended/idle/errored streams E.g. skypeforlinux makes its input streams idle but does not destroy them, when no call is active. --- src/examples/media-session/bluez-autoswitch.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/examples/media-session/bluez-autoswitch.c b/src/examples/media-session/bluez-autoswitch.c index d638824b4..7c0659f77 100644 --- a/src/examples/media-session/bluez-autoswitch.c +++ b/src/examples/media-session/bluez-autoswitch.c @@ -81,6 +81,7 @@ struct node { struct spa_hook listener; unsigned char active:1; unsigned char communication:1; + unsigned char was_active:1; }; struct find_data { @@ -473,6 +474,8 @@ static void change_node_state(struct node *node, bool active, bool communication bool need_switch = false; struct impl *impl = node->impl; + node->was_active = node->was_active || active; + if (node->active != active) { impl->record_count += active ? 1 : -1; node->active = active; @@ -508,6 +511,17 @@ static void check_node(struct node *node) spa_atob(str)) goto inactive; + /* + * XXX: This is not fully the right thing to do --- the node may be + * XXX: idle/suspended also because it's linked to a source that is not + * XXX: generating data. However, this seems the closest approximation + * XXX: to Pulse corked stream status. + */ + if (node->was_active && (node->obj->info->state == PW_NODE_STATE_SUSPENDED || + node->obj->info->state == PW_NODE_STATE_IDLE || + node->obj->info->state == PW_NODE_STATE_ERROR)) + goto inactive; + if (spa_streq(pw_properties_get(node->obj->obj.props, PW_KEY_MEDIA_ROLE), "Communication")) communication = true;