spa: Add channel mode to mp3 audio info and add channel mode docs

This commit is contained in:
Carlos Rafael Giani 2025-05-29 20:46:46 +02:00
parent 2042a0483b
commit 592c7c404c
4 changed files with 25 additions and 4 deletions

View file

@ -33,8 +33,9 @@ spa_format_audio_mp3_parse(const struct spa_pod *format, struct spa_audio_info_m
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),
SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
SPA_FORMAT_AUDIO_MP3_channelMode, SPA_POD_OPT_Id(&info->channel_mode));
return res;
}
@ -55,6 +56,9 @@ spa_format_audio_mp3_build(struct spa_pod_builder *builder, uint32_t id,
if (info->channels != 0)
spa_pod_builder_add(builder,
SPA_FORMAT_AUDIO_channels, SPA_POD_Int(info->channels), 0);
if (info->channel_mode != 0)
spa_pod_builder_add(builder,
SPA_FORMAT_AUDIO_MP3_channelMode, SPA_POD_Id(info->channel_mode), 0);
return (struct spa_pod*)spa_pod_builder_pop(builder, &f);
}

View file

@ -18,15 +18,26 @@ extern "C" {
enum spa_audio_mp3_channel_mode {
SPA_AUDIO_MP3_CHANNEL_MODE_UNKNOWN,
/** Mono mode, only used if channel count is 1 */
SPA_AUDIO_MP3_CHANNEL_MODE_MONO,
/** Regular stereo mode with two independent channels */
SPA_AUDIO_MP3_CHANNEL_MODE_STEREO,
/**
* Joint stereo mode, exploiting the similarities between channels
* using techniques like mid-side coding
*/
SPA_AUDIO_MP3_CHANNEL_MODE_JOINTSTEREO,
/**
* Two mono tracks, different from stereo in that each channel
* contains entirely different content (like two different mono songs)
*/
SPA_AUDIO_MP3_CHANNEL_MODE_DUAL,
};
struct spa_audio_info_mp3 {
uint32_t rate; /*< sample rate */
uint32_t channels; /*< number of channels */
uint32_t rate; /*< sample rate in Hz */
uint32_t channels; /*< number of channels */
enum spa_audio_mp3_channel_mode channel_mode; /*< MP3 channel mode */
};
#define SPA_AUDIO_INFO_MP3_INIT(...) ((struct spa_audio_info_mp3) { __VA_ARGS__ })