mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Add some more format checks
The format parse functions don't really check if the parsed values make any sense so we need to to this ourselves.
This commit is contained in:
parent
c30d743198
commit
74447acedb
24 changed files with 182 additions and 59 deletions
|
|
@ -535,8 +535,12 @@ static int calc_width(struct spa_audio_info *info)
|
|||
case SPA_AUDIO_FORMAT_S24:
|
||||
case SPA_AUDIO_FORMAT_S24_OE:
|
||||
return 3;
|
||||
default:
|
||||
case SPA_AUDIO_FORMAT_S32P:
|
||||
case SPA_AUDIO_FORMAT_S32:
|
||||
case SPA_AUDIO_FORMAT_S32_OE:
|
||||
return 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -571,6 +575,12 @@ static int port_set_format(void *object,
|
|||
return res;
|
||||
|
||||
port->stride = calc_width(&info);
|
||||
if (port->stride == 0)
|
||||
return -EINVAL;
|
||||
if (info.info.raw.rate == 0 ||
|
||||
info.info.raw.channels == 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (SPA_AUDIO_FORMAT_IS_PLANAR(info.info.raw.format)) {
|
||||
port->blocks = info.info.raw.channels;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue