mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
audio: don't use SPA_AUDIO_MAX_CHANNELS in some places
When we know the max size of the array, just use this instead of the SPA_AUDIO_MAX_CHANNELS constant.
This commit is contained in:
parent
c94aff8cae
commit
f453b1545d
14 changed files with 22 additions and 18 deletions
|
|
@ -901,12 +901,12 @@ static int codec_caps_preference_cmp(const struct media_codec *codec, uint32_t f
|
|||
return conf_cmp(&conf1, res1, &conf2, res2);
|
||||
}
|
||||
|
||||
static uint8_t channels_to_positions(uint32_t channels, uint32_t *position)
|
||||
static uint8_t channels_to_positions(uint32_t channels, uint32_t *position, uint32_t max_position)
|
||||
{
|
||||
uint32_t n_channels = get_channel_count(channels);
|
||||
uint8_t n_positions = 0;
|
||||
|
||||
spa_assert(n_channels <= SPA_AUDIO_MAX_CHANNELS);
|
||||
spa_assert(n_channels <= max_position);
|
||||
|
||||
if (channels == 0) {
|
||||
position[0] = SPA_AUDIO_CHANNEL_MONO;
|
||||
|
|
@ -932,7 +932,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
|||
bap_lc3_t conf;
|
||||
struct spa_pod_frame f[2];
|
||||
struct spa_pod_choice *choice;
|
||||
uint32_t position[SPA_AUDIO_MAX_CHANNELS];
|
||||
uint32_t position[LC3_MAX_CHANNELS];
|
||||
uint32_t i = 0;
|
||||
uint8_t res;
|
||||
|
||||
|
|
@ -990,7 +990,7 @@ static int codec_enum_config(const struct media_codec *codec, uint32_t flags,
|
|||
if (i == 0)
|
||||
return -EINVAL;
|
||||
|
||||
res = channels_to_positions(conf.channels, position);
|
||||
res = channels_to_positions(conf.channels, position, SPA_N_ELEMENTS(position));
|
||||
if (res == 0)
|
||||
return -EINVAL;
|
||||
spa_pod_builder_add(b,
|
||||
|
|
@ -1044,7 +1044,8 @@ static int codec_validate_config(const struct media_codec *codec, uint32_t flags
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
res = channels_to_positions(conf.channels, info->info.raw.position);
|
||||
res = channels_to_positions(conf.channels, info->info.raw.position,
|
||||
SPA_N_ELEMENTS(info->info.raw.position));
|
||||
if (res == 0)
|
||||
return -EINVAL;
|
||||
info->info.raw.channels = res;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue