From e7f2f450ff0ddf46d6a218f92d688cdbdbf6fb83 Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Mon, 29 Mar 2021 19:30:36 +0300 Subject: [PATCH] bluez5: add parameter to use A2DP source as input --- spa/plugins/bluez5/a2dp-source.c | 13 ++++++++++++- src/daemon/media-session.d/bluez-monitor.conf | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/spa/plugins/bluez5/a2dp-source.c b/spa/plugins/bluez5/a2dp-source.c index e9f553f3a..f57d3f376 100644 --- a/spa/plugins/bluez5/a2dp-source.c +++ b/spa/plugins/bluez5/a2dp-source.c @@ -129,6 +129,8 @@ struct impl { struct timespec now; uint64_t sample_count; uint64_t skip_count; + + bool is_input; }; #define NAME "a2dp-source" @@ -746,12 +748,14 @@ static int impl_node_send_command(void *object, const struct spa_command *comman static void emit_node_info(struct impl *this, bool full) { char latency[64] = SPA_STRINGIFY(MIN_LATENCY)"/48000"; + struct spa_dict_item node_info_items[] = { { SPA_KEY_DEVICE_API, "bluez5" }, - { SPA_KEY_MEDIA_CLASS, "Stream/Output/Audio" }, + { SPA_KEY_MEDIA_CLASS, this->is_input ? "Audio/Source" : "Stream/Output/Audio" }, { SPA_KEY_NODE_LATENCY, latency }, { "media.name", ((this->transport && this->transport->device->name) ? this->transport->device->name : "A2DP") }, + { SPA_KEY_NODE_DRIVER, this->is_input ? "true" : "false" }, }; if (full) @@ -1321,6 +1325,13 @@ impl_init(const struct spa_handle_factory *factory, this->codec_props = this->codec->init_props(this->codec, this->transport->device->settings); + + const char *a2dp_source_role = spa_dict_lookup(info, "bluez5.a2dp-source-role"); + if (a2dp_source_role != NULL && !strcmp("input", a2dp_source_role)) + this->is_input = true; + else + this->is_input = false; + return 0; } diff --git a/src/daemon/media-session.d/bluez-monitor.conf b/src/daemon/media-session.d/bluez-monitor.conf index c4a41445c..94e099a99 100644 --- a/src/daemon/media-session.d/bluez-monitor.conf +++ b/src/daemon/media-session.d/bluez-monitor.conf @@ -84,6 +84,11 @@ rules = [ #channelmix.normalize = false #channelmix.mix-lfe = false #session.suspend-timeout-seconds = 5 # 0 disables suspend + + # A2DP source role, "input" or "playback" + # Defaults to "playback", playing stream to speakers + # Set to "input" to use as an input for apps + #bluez5.a2dp-source-role = input } } }