treewide: remove some obsolete channel checks

The spa_audio_info can not be parsed with too many channels so there
is always enough space for the positions.
This commit is contained in:
Wim Taymans 2025-10-24 10:28:38 +02:00
parent 78219471ff
commit aa0272f6f3
8 changed files with 50 additions and 64 deletions

View file

@ -491,7 +491,7 @@ static void get_default_bitrates(const struct media_codec *codec, bool bidi, int
static int get_mapping(const struct media_codec *codec, const a2dp_opus_05_direction_t *conf,
bool use_surround_encoder, uint8_t *streams_ret, uint8_t *coupled_streams_ret,
const uint8_t **surround_mapping, uint32_t *positions, uint32_t max_positions)
const uint8_t **surround_mapping, uint32_t *positions)
{
const uint32_t channels = conf->channels;
const uint32_t location = OPUS_05_GET_LOCATION(*conf);
@ -539,12 +539,11 @@ static int get_mapping(const struct media_codec *codec, const a2dp_opus_05_direc
if (location & loc.mask) {
uint32_t idx = permutation ? permutation[j] : j;
if (idx < max_positions)
positions[idx] = loc.position;
positions[idx] = loc.position;
j++;
}
}
for (i = SPA_AUDIO_CHANNEL_START_Aux; j < channels && j < max_positions; ++i, ++j)
for (i = SPA_AUDIO_CHANNEL_START_Aux; j < channels; ++i, ++j)
positions[j] = i;
}
@ -779,7 +778,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
dir = !is_duplex_codec(codec) ? &conf.main : &conf.bidi;
if (get_mapping(codec, dir, surround_encoder, NULL, NULL, NULL, position, MAX_CHANNELS) < 0)
if (get_mapping(codec, dir, surround_encoder, NULL, NULL, NULL, position) < 0)
return -EINVAL;
spa_pod_builder_push_object(b, &f[0], SPA_TYPE_OBJECT_Format, id);
@ -832,9 +831,9 @@ static int codec_validate_config(const struct media_codec *codec, uint32_t flags
info->info.raw.channels = dir1->channels;
if (get_mapping(codec, dir1, surround_encoder, NULL, NULL, NULL,
info->info.raw.position, SPA_N_ELEMENTS(info->info.raw.position)) < 0)
info->info.raw.position) < 0)
return -EINVAL;
if (get_mapping(codec, dir2, surround_encoder, NULL, NULL, NULL, NULL, 0) < 0)
if (get_mapping(codec, dir2, surround_encoder, NULL, NULL, NULL, NULL) < 0)
return -EINVAL;
return 0;
@ -925,7 +924,7 @@ static void *codec_init(const struct media_codec *codec, uint32_t flags,
if ((res = codec_validate_config(codec, flags, config, config_len, &config_info)) < 0)
goto error;
if ((res = get_mapping(codec, dir, surround_encoder, &this->streams, &this->coupled_streams,
&enc_mapping, NULL, 0)) < 0)
&enc_mapping, NULL)) < 0)
goto error;
if (config_info.info.raw.channels != info->info.raw.channels) {
res = -EINVAL;