From 83ee3021e9e234e4b463159a118ffec00cb1f5dc Mon Sep 17 00:00:00 2001 From: Carlos Rafael Giani Date: Thu, 2 Oct 2025 12:12:53 +0200 Subject: [PATCH] spa: Remove channel field from spa_audio_info_mpegh structure A fixed channel count makes no sense with an entity based 3D audio format like MPEG-H, because MPEG-H decoders do not simply decode; they "spatialize" the entities, meaning that said entities are decoded and rendered accordingto the needs of the target playback system and its channel count. --- spa/include/spa/param/audio/mpegh-utils.h | 6 +----- spa/include/spa/param/audio/mpegh.h | 8 +++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/spa/include/spa/param/audio/mpegh-utils.h b/spa/include/spa/param/audio/mpegh-utils.h index 778dfa946..67e18cf4c 100644 --- a/spa/include/spa/param/audio/mpegh-utils.h +++ b/spa/include/spa/param/audio/mpegh-utils.h @@ -33,8 +33,7 @@ spa_format_audio_mpegh_parse(const struct spa_pod *format, struct spa_audio_info int res; res = spa_pod_parse_object(format, SPA_TYPE_OBJECT_Format, NULL, - SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate), - SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels)); + SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate)); return res; } @@ -52,9 +51,6 @@ spa_format_audio_mpegh_build(struct spa_pod_builder *builder, uint32_t id, if (info->rate != 0) spa_pod_builder_add(builder, SPA_FORMAT_AUDIO_rate, SPA_POD_Int(info->rate), 0); - if (info->channels != 0) - spa_pod_builder_add(builder, - SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0); return (struct spa_pod*)spa_pod_builder_pop(builder, &f); } diff --git a/spa/include/spa/param/audio/mpegh.h b/spa/include/spa/param/audio/mpegh.h index 5c4c8afa1..1c9549338 100644 --- a/spa/include/spa/param/audio/mpegh.h +++ b/spa/include/spa/param/audio/mpegh.h @@ -27,10 +27,16 @@ extern "C" { * * MPEG-H is documented in the ISO/IEC 23008-3 specification. * MHAS is specified in ISO/IEC 23008-3, Clause 14. + * + * Note that unlike other formats, this one does not specify a channel + * count. This is because MPEG-H is entity-based; it contains multiple + * entities of different types (channel beds, audio objects etc.) which + * do not map 1:1 to channels. The channel amount is determined by + * decoders instead, based on the audio scene content and the target + * playback system. */ struct spa_audio_info_mpegh { uint32_t rate; /*< sample rate */ - uint32_t channels; /*< number of channels */ }; #define SPA_AUDIO_INFO_MPEGH_INIT(...) ((struct spa_audio_info_mpegh) { __VA_ARGS__ })