mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-20 02:10:04 +01:00
spa: make sure unpositioned raw audio has unknown channels
Otherwise we might end up with partial channels when code doesn't check the unpositioned flag. It's better to set everything to unknown when there is a mismatch between channel count and layout.
This commit is contained in:
parent
172a2af982
commit
94c05e9e2d
2 changed files with 10 additions and 3 deletions
|
|
@ -33,6 +33,8 @@ spa_format_audio_dsd_parse(const struct spa_pod *format, struct spa_audio_info_d
|
|||
{
|
||||
struct spa_pod *position = NULL;
|
||||
int res;
|
||||
uint32_t max_position = SPA_N_ELEMENTS(info->position);
|
||||
|
||||
info->flags = 0;
|
||||
res = spa_pod_parse_object(format,
|
||||
SPA_TYPE_OBJECT_Format, NULL,
|
||||
|
|
@ -41,10 +43,13 @@ spa_format_audio_dsd_parse(const struct spa_pod *format, struct spa_audio_info_d
|
|||
SPA_FORMAT_AUDIO_rate, SPA_POD_OPT_Int(&info->rate),
|
||||
SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
|
||||
SPA_FORMAT_AUDIO_position, SPA_POD_OPT_Pod(&position));
|
||||
if (info->channels > max_position)
|
||||
return -ECHRNG;
|
||||
if (position == NULL ||
|
||||
!spa_pod_copy_array(position, SPA_TYPE_Id, info->position, SPA_N_ELEMENTS(info->position)))
|
||||
spa_pod_copy_array(position, SPA_TYPE_Id, info->position, max_position) != info->channels) {
|
||||
SPA_FLAG_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
|
||||
|
||||
spa_memzero(info->position, max_position * sizeof(info->position[0]));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,10 @@ spa_format_audio_raw_ext_parse(const struct spa_pod *format, struct spa_audio_in
|
|||
if (info->channels > max_position)
|
||||
return -ECHRNG;
|
||||
if (position == NULL ||
|
||||
spa_pod_copy_array(position, SPA_TYPE_Id, info->position, max_position) != info->channels)
|
||||
spa_pod_copy_array(position, SPA_TYPE_Id, info->position, max_position) != info->channels) {
|
||||
SPA_FLAG_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);
|
||||
spa_memzero(info->position, max_position * sizeof(info->position[0]));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue