From 6a8dd07ec94d8f98245d81b91ff7a59cd5cbfd22 Mon Sep 17 00:00:00 2001 From: ZZyVSmOzMz OZaAEBlUIZ <1080187-ZZyVSmOzMz@users.noreply.gitlab.freedesktop.org> Date: Sun, 22 Jun 2025 11:22:26 +0000 Subject: [PATCH 1/6] bluez5: use ldacBT for both decode and encode fixup check version --- spa/meson.build | 14 +++++++++----- spa/plugins/bluez5/a2dp-codec-ldac.c | 6 +++++- spa/plugins/bluez5/meson.build | 1 - 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/spa/meson.build b/spa/meson.build index f8acaec6a..c17deaab9 100644 --- a/spa/meson.build +++ b/spa/meson.build @@ -78,19 +78,23 @@ if get_option('spa-plugins').allowed() ldac_abr_dep = dependency('ldacBT-abr', required : get_option('bluez5-codec-ldac')) summary({'LDAC ABR': ldac_abr_dep.found()}, bool_yn: true, section: 'Bluetooth audio codecs') + ldac_dec_dep = dependency('', required: false) if get_option('bluez5-codec-ldac-dec').allowed() - ldac_dec_dep = dependency('ldacBT-dec', required : false) - if not ldac_dec_dep.found() - dep = cc.find_library('ldacBT_dec', required : false) + dep = dependency('ldacBT', required : false) + if dep.found() and cc.has_function('ldacBT_decode', dependencies : dep) + ldac_dec_dep = dep + else + dep = cc.find_library('ldacBT', required : false) if dep.found() and cc.has_function('ldacBT_decode', dependencies : dep) ldac_dec_dep = dep endif endif + if ldac_dec_dep.found() + ldac_dep = ldac_dec_dep # use ldacBT for both decode and encode + endif if not ldac_dec_dep.found() and get_option('bluez5-codec-ldac-dec').enabled() error('LDAC decoder library not found') endif - else - ldac_dec_dep = dependency('', required: false) endif summary({'LDAC DEC': ldac_dec_dep.found()}, bool_yn: true, section: 'Bluetooth audio codecs') diff --git a/spa/plugins/bluez5/a2dp-codec-ldac.c b/spa/plugins/bluez5/a2dp-codec-ldac.c index c80733220..ceda1621c 100644 --- a/spa/plugins/bluez5/a2dp-codec-ldac.c +++ b/spa/plugins/bluez5/a2dp-codec-ldac.c @@ -471,7 +471,11 @@ static void *codec_init(const struct media_codec *codec, uint32_t flags, #endif #ifdef ENABLE_LDAC_ABR - this->ldac_abr = ldac_ABR_get_handle(); +#ifdef ENABLE_LDAC_DEC + this->ldac_abr = ldac_ABR_get_handle(NULL); +#else + this->ldac_abr = ldac_ABR_get_handle(); +#endif if (this->ldac_abr == NULL) goto error_errno; #endif diff --git a/spa/plugins/bluez5/meson.build b/spa/plugins/bluez5/meson.build index 01c5f3ac1..e39afd030 100644 --- a/spa/plugins/bluez5/meson.build +++ b/spa/plugins/bluez5/meson.build @@ -141,7 +141,6 @@ if ldac_dep.found() endif if get_option('bluez5-codec-ldac-dec').allowed() and ldac_dec_dep.found() ldac_args += [ '-DENABLE_LDAC_DEC' ] - ldac_dep = [ldac_dep, ldac_dec_dep] endif bluez_codec_ldac = shared_library('spa-codec-bluez5-ldac', [ 'a2dp-codec-ldac.c', 'media-codecs.c' ], From 1719d14fb36a9ec4f4488c58b97bb12a63a77c8e Mon Sep 17 00:00:00 2001 From: Elias Souza Date: Sun, 7 Jun 2026 16:21:52 -0300 Subject: [PATCH 2/6] spa: meson: Bring back ldacBT-dec --- spa/meson.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spa/meson.build b/spa/meson.build index c17deaab9..7d7eeaafa 100644 --- a/spa/meson.build +++ b/spa/meson.build @@ -80,7 +80,9 @@ if get_option('spa-plugins').allowed() ldac_dec_dep = dependency('', required: false) if get_option('bluez5-codec-ldac-dec').allowed() - dep = dependency('ldacBT', required : false) + ldac_dec_dep = dependency('ldacBT-dec', required : false) + if not ldac_dec_dep.found() + dep = cc.find_library('ldacBT-dec', required : false) if dep.found() and cc.has_function('ldacBT_decode', dependencies : dep) ldac_dec_dep = dep else @@ -96,6 +98,7 @@ if get_option('spa-plugins').allowed() error('LDAC decoder library not found') endif endif + endif summary({'LDAC DEC': ldac_dec_dep.found()}, bool_yn: true, section: 'Bluetooth audio codecs') aptx_dep = dependency('libfreeaptx', required : get_option('bluez5-codec-aptx')) From be4bc96ee4e8b8e6c8f9eb635799dd8643da082c Mon Sep 17 00:00:00 2001 From: Elias Souza Date: Sun, 7 Jun 2026 16:24:26 -0300 Subject: [PATCH 3/6] spa: meson: Remove ldacBT only as ldac_dep --- spa/meson.build | 3 --- 1 file changed, 3 deletions(-) diff --git a/spa/meson.build b/spa/meson.build index 7d7eeaafa..f8fdaa6ee 100644 --- a/spa/meson.build +++ b/spa/meson.build @@ -91,9 +91,6 @@ if get_option('spa-plugins').allowed() ldac_dec_dep = dep endif endif - if ldac_dec_dep.found() - ldac_dep = ldac_dec_dep # use ldacBT for both decode and encode - endif if not ldac_dec_dep.found() and get_option('bluez5-codec-ldac-dec').enabled() error('LDAC decoder library not found') endif From 8c7784d037df9560cae171f555ef673e9f8725e7 Mon Sep 17 00:00:00 2001 From: Elias Souza Date: Sun, 7 Jun 2026 16:27:48 -0300 Subject: [PATCH 4/6] fix: spa: meson: Bring back ldacBT-dec --- spa/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spa/meson.build b/spa/meson.build index f8fdaa6ee..b73de72c4 100644 --- a/spa/meson.build +++ b/spa/meson.build @@ -82,7 +82,7 @@ if get_option('spa-plugins').allowed() if get_option('bluez5-codec-ldac-dec').allowed() ldac_dec_dep = dependency('ldacBT-dec', required : false) if not ldac_dec_dep.found() - dep = cc.find_library('ldacBT-dec', required : false) + dep = cc.find_library('ldacBT_dec', required : false) if dep.found() and cc.has_function('ldacBT_decode', dependencies : dep) ldac_dec_dep = dep else From b844678a1da4c237b98b97a8a73c6e22cbb87fa0 Mon Sep 17 00:00:00 2001 From: Elias Souza Date: Sun, 7 Jun 2026 16:30:04 -0300 Subject: [PATCH 5/6] spa: meson: Support use ldacBT as encoder library --- spa/meson.build | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spa/meson.build b/spa/meson.build index b73de72c4..1cbcfed30 100644 --- a/spa/meson.build +++ b/spa/meson.build @@ -73,6 +73,23 @@ if get_option('spa-plugins').allowed() endforeach summary({'Bluetooth audio': bluez_deps_found}, bool_yn: true, section: 'Backend') if bluez_deps_found + ldac_enc_dep = dependency('', required: false) + if get_option('bluez5-codec-ldac').allowed() + ldac_enc_dep = dependency('ldacBT-enc', required : false) + if not ldac_enc_dep.found() + dep = cc.find_library('ldacBT', required : false) + dep = dependency('ldacBT', required : false) + if dep.found() and cc.has_function('ldacBT_encode', dependencies : dep) + ldac_enc_dep = dep + dep = cc.find_library('ldacBT', required : false) + else + dep = cc.find_library('ldacBT', required : false) + if not ldac_enc_dep.found() and get_option('bluez5-codec-ldac').enabled() + error('LDAC encoder library not found') + endif + endif + endif + endif ldac_dep = dependency('ldacBT-enc', required : get_option('bluez5-codec-ldac')) summary({'LDAC': ldac_dep.found()}, bool_yn: true, section: 'Bluetooth audio codecs') ldac_abr_dep = dependency('ldacBT-abr', required : get_option('bluez5-codec-ldac')) From fdbc846120ef336085f650a1c81898aa271d862d Mon Sep 17 00:00:00 2001 From: Elias Souza Date: Sun, 7 Jun 2026 16:45:29 -0300 Subject: [PATCH 6/6] bluez5: Use LDAC_ABR_HANDLE_NULL on ldacBT >= 2.1.0.0 --- spa/plugins/bluez5/a2dp-codec-ldac.c | 6 +++--- spa/plugins/bluez5/meson.build | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/spa/plugins/bluez5/a2dp-codec-ldac.c b/spa/plugins/bluez5/a2dp-codec-ldac.c index ceda1621c..98898c5f1 100644 --- a/spa/plugins/bluez5/a2dp-codec-ldac.c +++ b/spa/plugins/bluez5/a2dp-codec-ldac.c @@ -471,11 +471,11 @@ static void *codec_init(const struct media_codec *codec, uint32_t flags, #endif #ifdef ENABLE_LDAC_ABR -#ifdef ENABLE_LDAC_DEC + #ifdef LDAC_ABR_HANDLE_NULL this->ldac_abr = ldac_ABR_get_handle(NULL); -#else + #else this->ldac_abr = ldac_ABR_get_handle(); -#endif + #endif if (this->ldac_abr == NULL) goto error_errno; #endif diff --git a/spa/plugins/bluez5/meson.build b/spa/plugins/bluez5/meson.build index e39afd030..2aeab5b9d 100644 --- a/spa/plugins/bluez5/meson.build +++ b/spa/plugins/bluez5/meson.build @@ -138,6 +138,9 @@ if ldac_dep.found() ldac_args = codec_args if ldac_abr_dep.found() ldac_args += [ '-DENABLE_LDAC_ABR' ] + if ldac_abr_dep.version().version_compare('>=2.1.0.0') + ldac_args += [ '-DLDAC_ABR_HANDLE_NULL' ] + endif endif if get_option('bluez5-codec-ldac-dec').allowed() and ldac_dec_dep.found() ldac_args += [ '-DENABLE_LDAC_DEC' ]