mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
pw-cat: improve channel checks
Make sure we don't use too many channels.
This commit is contained in:
parent
aa0272f6f3
commit
d18670d7bb
1 changed files with 14 additions and 2 deletions
|
|
@ -2348,10 +2348,22 @@ int main(int argc, char *argv[])
|
|||
.rate = data.rate,
|
||||
.channels = data.channels);
|
||||
|
||||
if (data.channels > MAX_CHANNELS) {
|
||||
fprintf(stderr, "error: too many channels %d > %d\n",
|
||||
data.channels, MAX_CHANNELS);
|
||||
goto error_bad_file;
|
||||
}
|
||||
if (data.channelmap.n_channels) {
|
||||
uint32_t i, n_pos = SPA_MIN(data.channels, SPA_N_ELEMENTS(info.position));
|
||||
for (i = 0; i < n_pos; i++)
|
||||
if (data.channels > MAX_CHANNELS) {
|
||||
fprintf(stderr, "error: too many channels in channelmap %d > %d\n",
|
||||
data.channelmap.n_channels, MAX_CHANNELS);
|
||||
goto error_bad_file;
|
||||
}
|
||||
uint32_t i;
|
||||
for (i = 0; i < data.channelmap.n_channels; i++)
|
||||
info.position[i] = data.channelmap.channels[i];
|
||||
for (; i < data.channels; i++)
|
||||
info.position[i] = SPA_AUDIO_CHANNEL_AUX0 + i;
|
||||
}
|
||||
params[n_params++] = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &info);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue