spa: provide information about channels > SPA_AUDIO_MAX_CHANNELS

Define some rules for how the position information works for channels >
SPA_AUDIO_MAX_CHANNELS. We basically wrap around and incrementing the
AUX channel counters. Make a function to implement this.
This commit is contained in:
Wim Taymans 2025-10-21 09:39:15 +02:00
parent ede13a8cb5
commit eb096bfb62
2 changed files with 20 additions and 1 deletions

View file

@ -28,6 +28,20 @@ extern "C" {
#endif
#endif
SPA_API_AUDIO_RAW_UTILS uint32_t
spa_format_audio_get_position(struct spa_audio_info_raw *info, uint32_t idx)
{
uint32_t pos;
if (idx < SPA_AUDIO_MAX_CHANNELS) {
pos = info->position[idx];
} else {
pos = info->position[idx % SPA_AUDIO_MAX_CHANNELS];
if (SPA_AUDIO_CHANNEL_IS_AUX(pos))
pos += (idx / SPA_AUDIO_MAX_CHANNELS) * SPA_AUDIO_MAX_CHANNELS;
}
return pos;
}
SPA_API_AUDIO_RAW_UTILS int
spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_raw *info)
{

View file

@ -18,6 +18,7 @@ extern "C" {
* \{
*/
/* this is the max number of channels for position info */
#define SPA_AUDIO_MAX_CHANNELS 64u
enum spa_audio_format {
@ -259,6 +260,8 @@ enum spa_audio_channel {
SPA_AUDIO_CHANNEL_START_Custom = 0x10000,
};
#define SPA_AUDIO_CHANNEL_IS_AUX(ch) ((ch)>=SPA_AUDIO_CHANNEL_START_Aux && (ch)<=SPA_AUDIO_CHANNEL_LAST_Aux)
enum spa_audio_volume_ramp_scale {
SPA_AUDIO_VOLUME_RAMP_INVALID,
SPA_AUDIO_VOLUME_RAMP_LINEAR,
@ -274,7 +277,9 @@ struct spa_audio_info_raw {
enum spa_audio_format format; /*< format, one of enum spa_audio_format */
uint32_t flags; /*< extra flags */
uint32_t rate; /*< sample rate */
uint32_t channels; /*< number of channels */
uint32_t channels; /*< number of channels. This can be larger than
* SPA_AUDIO_MAX_CHANNELS, the position is taken
* (index % SPA_AUDIO_MAX_CHANNELS) */
uint32_t position[SPA_AUDIO_MAX_CHANNELS]; /*< channel position from enum spa_audio_channel */
};