mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -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
|
|
@ -1011,14 +1011,15 @@ static void param_changed(void *data, uint32_t id, const struct spa_pod *param)
|
|||
} else {
|
||||
struct spa_audio_info_raw info;
|
||||
spa_zero(info);
|
||||
spa_format_audio_raw_parse(param, &info);
|
||||
impl->rate = info.rate;
|
||||
res = graph_instantiate(graph);
|
||||
if (res < 0) {
|
||||
pw_stream_set_error(impl->capture, res,
|
||||
"can't start graph: %s",
|
||||
spa_strerror(res));
|
||||
if ((res = spa_format_audio_raw_parse(param, &info)) < 0)
|
||||
goto error;
|
||||
if (info.rate == 0) {
|
||||
res = -EINVAL;
|
||||
goto error;
|
||||
}
|
||||
impl->rate = info.rate;
|
||||
if ((res = graph_instantiate(graph)) < 0)
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
case SPA_PARAM_Props:
|
||||
|
|
@ -1029,6 +1030,11 @@ static void param_changed(void *data, uint32_t id, const struct spa_pod *param)
|
|||
param_latency_changed(impl, param);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
|
||||
error:
|
||||
pw_stream_set_error(impl->capture, res, "can't start graph: %s",
|
||||
spa_strerror(res));
|
||||
}
|
||||
|
||||
static const struct pw_stream_events in_stream_events = {
|
||||
|
|
|
|||
|
|
@ -375,6 +375,10 @@ static void capture_param_changed(void *data, uint32_t id, const struct spa_pod
|
|||
return;
|
||||
if (spa_format_audio_raw_parse(param, &info) < 0)
|
||||
return;
|
||||
if (info.rate == 0 ||
|
||||
info.channels == 0 ||
|
||||
info.channels > SPA_AUDIO_MAX_CHANNELS)
|
||||
return;
|
||||
|
||||
impl->capture_info = info;
|
||||
recalculate_buffer(impl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue