From 392ecf3352b23bf82576026296798372ed2ec595 Mon Sep 17 00:00:00 2001 From: Aliaksandr Date: Mon, 23 Mar 2026 17:52:08 +0200 Subject: [PATCH] libldac-dec: fix decoder initialization failure `ldacBT_init_handle_decode` passes `hLdacBT->cci`, `hLdacBT->frmlen`, and `hLdacBT->frm_status` to `ldaclib_set_config_info()` before they are assigned, causing `LDACBT_ERR_FATAL` on every decode init. This breaks PipeWire 1.6+'s LDAC codec entirely, since the SPA plugin treats decoder init failure as fatal and refuses to initialize the encoder too. Move the struct member assignments before the function call that uses them. --- .../li/libldac-dec/fix-decode-init.patch | 24 +++++++++++++++++++ pkgs/by-name/li/libldac-dec/package.nix | 5 ++++ 2 files changed, 29 insertions(+) create mode 100644 pkgs/by-name/li/libldac-dec/fix-decode-init.patch diff --git a/pkgs/by-name/li/libldac-dec/fix-decode-init.patch b/pkgs/by-name/li/libldac-dec/fix-decode-init.patch new file mode 100644 index 000000000000..be1b8905e27c --- /dev/null +++ b/pkgs/by-name/li/libldac-dec/fix-decode-init.patch @@ -0,0 +1,24 @@ +--- a/src/ldacBT_api.o.c ++++ b/src/ldacBT_api.o.c +@@ -165,6 +165,10 @@ + // tbl_ldacbt_config[0].frmlen_1ch; + // frmlen = 165 * channel - LDACBT_FRMHDRBYTES; + frmlen = tbl_ldacbt_config[0].frmlen_1ch * channel - LDACBT_FRMHDRBYTES; ++ hLdacBT->frmlen = frmlen; ++ hLdacBT->cm = cm; ++ hLdacBT->cci = cci; ++ hLdacBT->frm_status = 0; + /* Set Configuration Information */ + result = ldaclib_set_config_info( + hLdacBT->hLDAC, hLdacBT->sfid, hLdacBT->cci, hLdacBT->frmlen, hLdacBT->frm_status); +@@ -174,10 +178,6 @@ + } else if (result != LDAC_S_OK) { + hLdacBT->error_code_api = LDACBT_GET_LDACLIB_ERROR_CODE; + } +- hLdacBT->frmlen = frmlen; +- hLdacBT->cm = cm; +- hLdacBT->cci = cci; +- hLdacBT->frm_status = 0; + hLdacBT->sfid = sfid; + result = ldaclib_init_decode(hLdacBT->hLDAC, nshift); + if (LDAC_FAILED(result)) { diff --git a/pkgs/by-name/li/libldac-dec/package.nix b/pkgs/by-name/li/libldac-dec/package.nix index 7a8eaf208718..5d292af9996f 100644 --- a/pkgs/by-name/li/libldac-dec/package.nix +++ b/pkgs/by-name/li/libldac-dec/package.nix @@ -17,6 +17,11 @@ stdenv.mkDerivation { hash = "sha256-pdeEtQXxL2pd9qTfLOEmPDn3POgo5qxRqbK807WN98s="; }; + patches = [ + # Fix uninitialized struct members passed to ldaclib_set_config_info in decode init + ./fix-decode-init.patch + ]; + nativeBuildInputs = [ cmake ]; # Upstream CMakeLists.txt doesn't have install rules