From 34a9b1dc1a4ac45cdd1f7cc7a02c94aa236fdcea Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 9 Dec 2020 18:08:24 +0100 Subject: [PATCH] a2dp: set channel map --- spa/plugins/bluez5/a2dp-codec-aptx.c | 8 ++++++++ spa/plugins/bluez5/a2dp-codec-sbc.c | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/spa/plugins/bluez5/a2dp-codec-aptx.c b/spa/plugins/bluez5/a2dp-codec-aptx.c index a96f27599..b151899fd 100644 --- a/spa/plugins/bluez5/a2dp-codec-aptx.c +++ b/spa/plugins/bluez5/a2dp-codec-aptx.c @@ -104,6 +104,7 @@ static int codec_enum_config(const struct a2dp_codec *codec, a2dp_aptx_t conf; struct spa_pod_frame f[2]; struct spa_pod_choice *choice; + uint32_t position[SPA_AUDIO_MAX_CHANNELS]; uint32_t i = 0; if (caps_size < sizeof(conf)) @@ -156,12 +157,19 @@ static int codec_enum_config(const struct a2dp_codec *codec, SPA_FORMAT_AUDIO_channels, SPA_POD_CHOICE_RANGE_Int(2, 1, 2), 0); } else if (conf.channel_mode & APTX_CHANNEL_MODE_MONO) { + position[0] = SPA_AUDIO_CHANNEL_MONO; spa_pod_builder_add(b, SPA_FORMAT_AUDIO_channels, SPA_POD_Int(1), + SPA_FORMAT_AUDIO_position, SPA_POD_Array(sizeof(uint32_t), + SPA_TYPE_Id, 1, position), 0); } else if (conf.channel_mode & APTX_CHANNEL_MODE_STEREO) { + position[0] = SPA_AUDIO_CHANNEL_FL; + position[1] = SPA_AUDIO_CHANNEL_FR; spa_pod_builder_add(b, SPA_FORMAT_AUDIO_channels, SPA_POD_Int(2), + SPA_FORMAT_AUDIO_position, SPA_POD_Array(sizeof(uint32_t), + SPA_TYPE_Id, 2, position), 0); } else return -EINVAL; diff --git a/spa/plugins/bluez5/a2dp-codec-sbc.c b/spa/plugins/bluez5/a2dp-codec-sbc.c index 7cf9852bb..4fd9768ff 100644 --- a/spa/plugins/bluez5/a2dp-codec-sbc.c +++ b/spa/plugins/bluez5/a2dp-codec-sbc.c @@ -201,6 +201,7 @@ static int codec_enum_config(const struct a2dp_codec *codec, struct spa_pod_frame f[2]; struct spa_pod_choice *choice; uint32_t i = 0; + uint32_t position[SPA_AUDIO_MAX_CHANNELS]; if (caps_size < sizeof(conf)) return -EINVAL; @@ -252,12 +253,20 @@ static int codec_enum_config(const struct a2dp_codec *codec, SPA_FORMAT_AUDIO_channels, SPA_POD_CHOICE_RANGE_Int(2, 1, 2), 0); } else if (conf.channel_mode & SBC_CHANNEL_MODE_MONO) { + position[0] = SPA_AUDIO_CHANNEL_MONO; spa_pod_builder_add(b, SPA_FORMAT_AUDIO_channels, SPA_POD_Int(1), + SPA_FORMAT_AUDIO_position, SPA_POD_Array(sizeof(uint32_t), + SPA_TYPE_Id, 1, position), 0); } else { + position[0] = SPA_AUDIO_CHANNEL_FL; + position[1] = SPA_AUDIO_CHANNEL_FR; spa_pod_builder_add(b, - SPA_FORMAT_AUDIO_channels, SPA_POD_Int(2), 0); + SPA_FORMAT_AUDIO_channels, SPA_POD_Int(2), + SPA_FORMAT_AUDIO_position, SPA_POD_Array(sizeof(uint32_t), + SPA_TYPE_Id, 2, position), + 0); } *param = spa_pod_builder_pop(b, &f[0]); return 1;