bluez5: emit node volume and mute right after bluez5 node creating

bluez5 nodes will always be removed & created again during profile changing, hence
node volume & mute will always be reset. This is OK if profile did changed, because
session manager would carries volume & mute to bluez5 route param. But if profile
was not changed after setting profile (a2dp-sink-sbc -> a2dp-sink -> a2dp-sink-sbc),
session manager would think node volume & mute are not changed and no route
setting is performed, causing route volume out of sync with node volume.

To fix this, we emit node volume and mute right after bluez5 node is created.

Fixes #1254
This commit is contained in:
Huang-Huang Bao 2021-06-03 05:48:25 +08:00 committed by Wim Taymans
parent 27433c4000
commit f92a5b3bbd

View file

@ -238,7 +238,7 @@ static void transport_destroy(void *userdata)
node->transport = NULL;
}
static void emit_volume(struct impl *this, struct node *node)
static void emit_node_props(struct impl *this, struct node *node, bool full)
{
struct spa_event *event;
uint8_t buffer[4096];
@ -259,11 +259,23 @@ static void emit_volume(struct impl *this, struct node *node)
SPA_TYPE_Float, node->n_channels, node->soft_volumes),
SPA_PROP_channelMap, SPA_POD_Array(sizeof(uint32_t),
SPA_TYPE_Id, node->n_channels, node->channels));
if (full) {
spa_pod_builder_add(&b,
SPA_PROP_mute, SPA_POD_Bool(node->mute),
SPA_PROP_softMute, SPA_POD_Bool(node->mute),
SPA_PROP_latencyOffsetNsec, SPA_POD_Long(node->latency_offset),
0);
}
event = spa_pod_builder_pop(&b, &f[0]);
spa_device_emit_event(&this->hooks, event);
}
static void emit_volume(struct impl *this, struct node *node)
{
emit_node_props(this, node, false);
}
static void emit_info(struct impl *this, bool full);
static float node_get_hw_volume(struct node *node)
@ -379,6 +391,8 @@ static void emit_node(struct impl *this, struct spa_bt_transport *t,
spa_hook_remove(&this->nodes[id].transport_listener);
this->nodes[id].transport = t;
spa_bt_transport_add_listener(t, &this->nodes[id].transport_listener, &transport_events, &this->nodes[id]);
emit_node_props(this, &this->nodes[id], true);
}
}