From f593a4406935377c39b8983ec98396b3ec2a3eb3 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sun, 22 May 2022 19:08:56 +0300 Subject: [PATCH] bluez5: a2dp-sink: support duplex codec Allow running a2dp-sink using the duplex codec, when the local endpoint is the A2DP sink. --- spa/plugins/bluez5/a2dp-sink.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c index 8a284aa8f..d0d78d8a7 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/a2dp-sink.c @@ -137,6 +137,8 @@ struct impl { unsigned int started:1; unsigned int following:1; + unsigned int is_duplex:1; + struct spa_source source; int timerfd; struct spa_source flush_source; @@ -1697,6 +1699,9 @@ impl_init(const struct spa_handle_factory *factory, spa_list_init(&port->ready); + if (info && (str = spa_dict_lookup(info, "api.bluez5.a2dp-duplex")) != NULL) + this->is_duplex = spa_atob(str); + if (info && (str = spa_dict_lookup(info, SPA_KEY_API_BLUEZ5_TRANSPORT))) sscanf(str, "pointer:%p", &this->transport); @@ -1708,7 +1713,17 @@ impl_init(const struct spa_handle_factory *factory, spa_log_error(this->log, "a transport codec is needed"); return -EINVAL; } + this->codec = this->transport->a2dp_codec; + + if (this->is_duplex) { + if (!this->codec->duplex_codec) { + spa_log_error(this->log, "transport codec doesn't support duplex"); + return -EINVAL; + } + this->codec = this->codec->duplex_codec; + } + if (this->codec->init_props != NULL) this->codec_props = this->codec->init_props(this->codec, this->transport->device->settings);