mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-19 07:00:10 -05: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
|
|
@ -31,20 +31,20 @@ extern "C" {
|
|||
SPA_API_AUDIO_RAW_UTILS uint32_t
|
||||
spa_format_audio_raw_get_position(const struct spa_audio_info_raw *info, uint32_t idx)
|
||||
{
|
||||
uint32_t pos;
|
||||
if (idx < SPA_AUDIO_MAX_CHANNELS) {
|
||||
uint32_t pos, max_position = SPA_N_ELEMENTS(info->position);
|
||||
if (idx < max_position) {
|
||||
pos = info->position[idx];
|
||||
} else {
|
||||
pos = info->position[idx % SPA_AUDIO_MAX_CHANNELS];
|
||||
pos = info->position[idx % max_position];
|
||||
if (SPA_AUDIO_CHANNEL_IS_AUX(pos))
|
||||
pos += (idx / SPA_AUDIO_MAX_CHANNELS) * SPA_AUDIO_MAX_CHANNELS;
|
||||
pos += (idx / max_position) * max_position;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
SPA_API_AUDIO_RAW_UTILS void
|
||||
spa_format_audio_raw_set_position(struct spa_audio_info_raw *info, uint32_t idx, uint32_t position)
|
||||
{
|
||||
if (idx < SPA_AUDIO_MAX_CHANNELS)
|
||||
if (idx < SPA_N_ELEMENTS(info->position))
|
||||
info->position[idx] = position;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue