From 8f075619b294d671a25fa8aec49fdcfed8630f97 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Mon, 15 Mar 2021 23:07:46 +0200 Subject: [PATCH] bluez5: set volume for both channels when switching HFP -> A2DP Retain mono volume level set with HFP, for A2DP, in case session manager fails to restore it. --- spa/plugins/bluez5/bluez5-device.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spa/plugins/bluez5/bluez5-device.c b/spa/plugins/bluez5/bluez5-device.c index 63045868a..a3beaa862 100644 --- a/spa/plugins/bluez5/bluez5-device.c +++ b/spa/plugins/bluez5/bluez5-device.c @@ -156,6 +156,17 @@ static void emit_node(struct impl *this, struct spa_bt_transport *t, spa_device_emit_object_info(&this->hooks, id, &info); + if (this->nodes[id].n_channels > 0) { + size_t i; + + /* + * Spread mono volume to all channels, if we had switched HFP -> A2DP. + * XXX: we should also use different route for hfp and a2dp + */ + for (i = this->nodes[id].n_channels; i < t->n_channels; ++i) + this->nodes[id].volumes[i] = this->nodes[id].volumes[i % this->nodes[id].n_channels]; + } + this->nodes[id].active = true; this->nodes[id].n_channels = t->n_channels; memcpy(this->nodes[id].channels, t->channels,