From 67b4732c2601c97afad51524b125cbcdd919aeb4 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 14 Feb 2026 09:59:38 +0200 Subject: [PATCH] bluez5: aac: for multiple bits in aot, normalize to mandatory Non-spec compliant devices may set multiple bits in AAC AOT, which is invalid. In this case, we should normalize to MPEG-2 AAC LC which is the mandatory value in spec, not to MPEG-4 AAC LC. In select_config() we also prefer MPEG-2 over MPEG-4. --- spa/plugins/bluez5/a2dp-codec-aac.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spa/plugins/bluez5/a2dp-codec-aac.c b/spa/plugins/bluez5/a2dp-codec-aac.c index a19cdb093..a82efe983 100644 --- a/spa/plugins/bluez5/a2dp-codec-aac.c +++ b/spa/plugins/bluez5/a2dp-codec-aac.c @@ -331,14 +331,14 @@ static void *codec_init(const struct media_codec *codec, uint32_t flags, goto error; /* If object type has multiple bits set (invalid per spec, see above), - * assume the device usually means AAC-LC. + * assume the device usually means MPEG2 AAC LC which is mandatory. */ - if (conf->object_type & AAC_OBJECT_TYPE_MPEG4_AAC_LC) { - res = aacEncoder_SetParam(this->aacenc, AACENC_AOT, AOT_AAC_LC); + if (conf->object_type & AAC_OBJECT_TYPE_MPEG2_AAC_LC) { + res = aacEncoder_SetParam(this->aacenc, AACENC_AOT, AOT_MP2_AAC_LC); if (res != AACENC_OK) goto error; - } else if (conf->object_type & AAC_OBJECT_TYPE_MPEG2_AAC_LC) { - res = aacEncoder_SetParam(this->aacenc, AACENC_AOT, AOT_MP2_AAC_LC); + } else if (conf->object_type & AAC_OBJECT_TYPE_MPEG4_AAC_LC) { + res = aacEncoder_SetParam(this->aacenc, AACENC_AOT, AOT_AAC_LC); if (res != AACENC_OK) goto error; } else if (conf->object_type & AAC_OBJECT_TYPE_MPEG4_AAC_ELD) {