mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: avoid using SPA_AUDIO_MAX_CHANNELS
Use SPA_N_ELEMENTS instead of the array we try to handle.
This commit is contained in:
parent
818d1435ce
commit
dbc5c81e4a
7 changed files with 22 additions and 16 deletions
|
|
@ -1228,8 +1228,9 @@ static int probe_ffado_device(struct impl *impl)
|
|||
impl->source.ports[i] = port;
|
||||
}
|
||||
if (impl->source.info.channels != n_channels) {
|
||||
uint32_t n_pos = SPA_MIN(n_channels, SPA_N_ELEMENTS(impl->source.info.position));
|
||||
impl->source.info.channels = n_channels;
|
||||
for (i = 0; i < SPA_MIN(impl->source.info.channels, SPA_AUDIO_MAX_CHANNELS); i++)
|
||||
for (i = 0; i < n_pos; i++)
|
||||
impl->source.info.position[i] = SPA_AUDIO_CHANNEL_AUX0 + i;
|
||||
}
|
||||
|
||||
|
|
@ -1254,8 +1255,9 @@ static int probe_ffado_device(struct impl *impl)
|
|||
impl->sink.ports[i] = port;
|
||||
}
|
||||
if (impl->sink.info.channels != n_channels) {
|
||||
uint32_t n_pos = SPA_MIN(n_channels, SPA_N_ELEMENTS(impl->sink.info.position));
|
||||
impl->sink.info.channels = n_channels;
|
||||
for (i = 0; i < SPA_MIN(impl->sink.info.channels, SPA_AUDIO_MAX_CHANNELS); i++)
|
||||
for (i = 0; i < n_pos; i++)
|
||||
impl->sink.info.position[i] = SPA_AUDIO_CHANNEL_AUX0 + i;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1691,7 +1691,8 @@ static void copy_position(struct spa_audio_info_raw *dst, const struct spa_audio
|
|||
{
|
||||
if (SPA_FLAG_IS_SET(dst->flags, SPA_AUDIO_FLAG_UNPOSITIONED) &&
|
||||
!SPA_FLAG_IS_SET(src->flags, SPA_AUDIO_FLAG_UNPOSITIONED)) {
|
||||
for (uint32_t i = 0; i < SPA_MIN(src->channels, SPA_AUDIO_MAX_CHANNELS); i++)
|
||||
uint32_t i, n_pos = SPA_MIN(src->channels, SPA_N_ELEMENTS(dst->position));
|
||||
for (i = 0; i < n_pos; i++)
|
||||
dst->position[i] = src->position[i];
|
||||
SPA_FLAG_CLEAR(dst->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -546,7 +546,7 @@ static void param_format_changed(struct impl *impl, const struct spa_pod *param,
|
|||
(impl->info.channels != 0 &&
|
||||
(impl->info.channels != info.channels ||
|
||||
memcmp(impl->info.position, info.position,
|
||||
SPA_MIN(info.channels, SPA_AUDIO_MAX_CHANNELS) * sizeof(uint32_t)) != 0))) {
|
||||
SPA_MIN(info.channels, SPA_N_ELEMENTS(info.position)) * sizeof(uint32_t)) != 0))) {
|
||||
uint8_t buffer[1024];
|
||||
struct spa_pod_builder b;
|
||||
const struct spa_pod *params[1];
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ void channel_map_parse(const char *str, struct channel_map *map)
|
|||
|
||||
void channel_map_parse_position(const char *str, struct channel_map *map)
|
||||
{
|
||||
uint32_t channels = 0, position[SPA_AUDIO_MAX_CHANNELS];
|
||||
uint32_t channels = 0, position[CHANNELS_MAX];
|
||||
spa_audio_parse_position_n(str, strlen(str), position,
|
||||
SPA_N_ELEMENTS(position), &channels);
|
||||
positions_to_channel_map(position, channels, map);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue