pipewire/spa/plugins/bluez5
George Kiagiadakis 4e46489964 bluez5: fix shared A2DP endpoint caps including disabled companion codecs
Codecs that share an A2DP endpoint (e.g. aac + aac_eld) previously used
an asymmetric pattern: one codec (the "owner") had fill_caps and quietly
advertised the union of all siblings' capability bits; companions had
fill_caps = NULL.

This caused a bug: when aac_eld is absent from bluez5.codecs, the "aac"
endpoint still advertised the ELD object-type bit because a2dp_codec_aac's
fill_caps emitted it unconditionally (gated only by eld_supported(), never
by enabled_codecs). A remote could then select ELD; SetConfiguration
resolved the transport to a2dp_codec_aac (the only fill_caps holder for "aac")

Refactor to a symmetric, composable model:

- Add bool endpoint_companion to struct media_codec (default false = owner).
  Companion codec objects set this flag instead of fill_caps = NULL.
- Add combine_caps() function to struct media_codec. Owners that share
  an endpoint implement this to union two capability blobs of the same
  codec_id.
- Each codec's fill_caps now describes only its own bits. AAC LC advertises
  only LC object types; AAC ELD advertises only the ELD type (or returns
  -ENOTSUP when FDK-AAC lacks ELD support).
- Bump SPA_VERSION_BLUEZ5_CODEC_MEDIA 16 -> 17.

On the monitor side (bluez5-dbus.c):
- New media_codec_fill_endpoint_caps() helper fills the owner's caps then
  walks enabled companions on the same endpoint and merges each via
  combine_caps. All five endpoint-registration fill_caps call sites are
  routed through this helper.
- endpoint_should_be_registered() gates on !endpoint_companion (not on
  fill_caps != NULL), so companions correctly skip endpoint registration.
- media_endpoint_to_codec() now filters by is_media_codec_enabled and
  prefers owners as a tiebreaker.
- New media_endpoint_to_codec_for_config() resolves SetConfiguration by
  calling each enabled candidate's validate_config against the negotiated
  config bytes. This ensures that an "aac" endpoint carrying ELD bytes is
  mapped to a2dp_codec_aac_eld (not a2dp_codec_aac).
- AAC validate_config and codec_init are id-gated so a stale ELD config
  can never be decoded by the LC codec object.

Assisted-by: Claude Opus 4.7
2026-06-30 21:21:24 +03:00
..
g722 bluez5: asha-codec-g722: Drop the dependency on FFmpeg 2025-02-13 19:55:18 +05:30
a2dp-codec-aac.c bluez5: fix shared A2DP endpoint caps including disabled companion codecs 2026-06-30 21:21:24 +03:00
a2dp-codec-aptx.c bluez5: add codec_data for codec-private configuration data 2025-11-21 08:33:14 +00:00
a2dp-codec-caps.h bluez5: aac: fix for A2DP v1.4 using rfa bits for more channels 2025-07-10 14:12:15 +00:00
a2dp-codec-faststream.c bluez5: add codec_data for codec-private configuration data 2025-11-21 08:33:14 +00:00
a2dp-codec-lc3plus.c bluez5: lc3plus: add missing #include 2026-05-05 16:20:34 +00:00
a2dp-codec-ldac.c bluez5: add codec_data for codec-private configuration data 2025-11-21 08:33:14 +00:00
a2dp-codec-opus-g.c security: fix integer overflow in Bluetooth codec codesize calculations 2026-04-24 15:55:35 +02:00
a2dp-codec-opus.c bluez5: fix shared A2DP endpoint caps including disabled companion codecs 2026-06-30 21:21:24 +03:00
a2dp-codec-sbc.c bluez5: fix shared A2DP endpoint caps including disabled companion codecs 2026-06-30 21:21:24 +03:00
asha-codec-g722.c bluez5: replace codec->bap/asha flags with codec->kind enum 2025-06-13 17:51:16 +00:00
backend-hsphfpd.c bluez5: fix wrong use of send_with_reply in HFP backends 2026-05-05 16:20:34 +00:00
backend-native.c bluez5: backend-native: fix multiple profile registration 2026-06-25 18:21:46 +03:00
backend-ofono.c bluez5: fix wrong use of send_with_reply in HFP backends 2026-05-05 16:20:34 +00:00
bap-codec-caps.h bluez5: bap: Advertise ASCS properties 2026-05-11 08:14:14 +00:00
bap-codec-lc3.c security: fix integer overflow in Bluetooth codec codesize calculations 2026-04-24 15:55:35 +02:00
bluez-hardware.conf bluez5: more MT7925 quirks 2026-04-19 16:02:56 +00:00
bluez5-dbus.c bluez5: fix shared A2DP endpoint caps including disabled companion codecs 2026-06-30 21:21:24 +03:00
bluez5-device.c fix some compilation problems 2026-05-11 11:59:54 +02:00
bt-latency.h bluez5: deal with missing TX timestamps 2026-01-11 17:55:26 +02:00
codec-loader.c bluez5: fix shared A2DP endpoint caps including disabled companion codecs 2026-06-30 21:21:24 +03:00
codec-loader.h treewide: use SPDX tags to specify copyright information 2023-02-16 10:54:48 +00:00
dbus-monitor.c bluez5: fix glib signal disconnect 2023-04-14 20:06:57 +03:00
dbus-monitor.h chore: fix warnings shown by Clang 16 2023-05-09 08:31:56 +00:00
decode-buffer.h bluez: introduce media.min-latency-ms for media source 2026-06-11 20:34:22 +02:00
defs.h bluez5: bap: Advertise ASCS properties 2026-05-11 08:14:14 +00:00
hci.c spa: bluez: use some more spa_auto* 2023-07-30 13:45:49 +02:00
hfp-codec-caps.h bluez5: remove HFP codec id from transports 2025-06-13 17:51:16 +00:00
hfp-codec-cvsd.c bluez5: fix wrong use of SPA_POD_CHOICE_ENUM_Int 2025-11-03 22:11:04 +00:00
hfp-codec-lc3-a127.c bluez5: fix wrong use of SPA_POD_CHOICE_ENUM_Int 2025-11-03 22:11:04 +00:00
hfp-codec-lc3-swb.c bluez5: fix wrong use of SPA_POD_CHOICE_ENUM_Int 2025-11-03 22:11:04 +00:00
hfp-codec-msbc.c bluez5: fix wrong use of SPA_POD_CHOICE_ENUM_Int 2025-11-03 22:11:04 +00:00
hfp-h2.h bluez5: add HFP codecs in the media codec API 2025-06-13 17:51:16 +00:00
iso-io.c bluez5: iso-io: don't use streams without tx_latency enabled for fill level calculation 2026-04-09 08:00:37 +00:00
iso-io.h bluez5: iso-io: add debug option for forcing same data in all streams 2026-01-11 17:55:26 +02:00
media-codecs.c bluez5: add codec_data for codec-private configuration data 2025-11-21 08:33:14 +00:00
media-codecs.h bluez5: fix shared A2DP endpoint caps including disabled companion codecs 2026-06-30 21:21:24 +03:00
media-sink.c fix some compilation problems 2026-05-11 11:59:54 +02:00
media-source.c bluez: introduce media.min-latency-ms for media source 2026-06-11 20:34:22 +02:00
meson.build bluez5: add PLC for MSBC using spandsp 2025-07-12 19:59:33 +00:00
midi-enum.c *: unify config.h handling 2025-05-30 10:24:13 +00:00
midi-node.c plugins: handle some fd allocation errors 2026-05-05 11:36:45 +02:00
midi-parser.c treewide: use SPDX tags to specify copyright information 2023-02-16 10:54:48 +00:00
midi-server.c security: add missing NULL check after strdup in MIDI server 2026-04-29 11:36:53 +02:00
midi.h spa: bluez: include gio/gunixfdlist.h 2023-02-16 20:55:55 +01:00
modemmanager.c security: add missing NULL checks after strdup in modemmanager 2026-04-29 11:34:37 +02:00
modemmanager.h spa: bluez: modemmanager: do not use old style declaration 2023-07-03 19:40:31 +02:00
org.bluez.xml bluez5: add GDBus-based object monitor framework 2023-01-24 08:27:56 +00:00
player.c spa: bluez: mark dbus vtables static 2025-11-07 12:28:16 +00:00
player.h treewide: use SPDX tags to specify copyright information 2023-02-16 10:54:48 +00:00
plc.h bluez5: add PLC for MSBC using spandsp 2025-07-12 19:59:33 +00:00
plugin.c spa: export log topic enumerations 2024-01-04 10:02:55 +00:00
quirks.c bluez5: add quirk for LC3-24kHz for HFP 2026-04-17 22:10:32 +00:00
rate-control.h Fix spelling errors in comments and log messages 2026-04-13 07:20:11 +00:00
README-MIDI.md bluez5: fixup BLE MIDI selinux README 2023-01-24 08:27:56 +00:00
README-OPUS-A2DP.md bluez5: clarify OPUS-A2DP spec 2022-09-03 19:08:27 +00:00
README-SBC-XQ.md bluez5: add SBC XQ readme 2021-01-07 09:54:16 +01:00
README-Telephony.md bluez5: telephony: implement asynchronous D-Bus calls 2025-08-01 15:39:06 +00:00
rtp.h
sco-io.c bluez5: sco-io: send keepalive TX data if sink is not feeding it 2025-09-29 14:15:46 +00:00
telephony.c spa: add and use spa_overflow macros 2026-04-24 15:55:35 +02:00
telephony.h bluez5: telephony: implement asynchronous D-Bus calls 2025-08-01 15:39:06 +00:00
test-midi.c bluez5: a few more -Werror=strict-prototypes fixes 2023-01-24 11:14:27 +02:00
upower.c spa: move dbus helpers out of bluez plugin 2024-02-05 13:03:20 +00:00
upower.h treewide: use SPDX tags to specify copyright information 2023-02-16 10:54:48 +00:00