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:
Wim Taymans 2022-11-03 13:10:32 +01:00
parent c30d743198
commit 74447acedb
24 changed files with 182 additions and 59 deletions

View file

@ -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;
}