pulse-server: error on invalid format

When an invalid format is given as a module argument, generate an error.
This commit is contained in:
Wim Taymans 2023-03-01 13:41:17 +01:00
parent 7aae9a3e8b
commit 03abce72e5
3 changed files with 14 additions and 0 deletions

View file

@ -166,6 +166,10 @@ static int module_null_sink_prepare(struct module * const module)
info.format = module->impl->defs.sample_spec.format; info.format = module->impl->defs.sample_spec.format;
if ((str = pw_properties_get(props, "format")) != NULL) { if ((str = pw_properties_get(props, "format")) != NULL) {
info.format = format_paname2id(str, strlen(str)); info.format = format_paname2id(str, strlen(str));
if (info.format == SPA_AUDIO_FORMAT_UNKNOWN) {
pw_log_error("invalid format '%s'", str);
return -EINVAL;
}
pw_properties_set(props, "format", NULL); pw_properties_set(props, "format", NULL);
} }

View file

@ -148,6 +148,11 @@ static int module_pipe_sink_prepare(struct module * const module)
info.format = SPA_AUDIO_FORMAT_S16; info.format = SPA_AUDIO_FORMAT_S16;
if ((str = pw_properties_get(props, "format")) != NULL) { if ((str = pw_properties_get(props, "format")) != NULL) {
info.format = format_paname2id(str, strlen(str)); info.format = format_paname2id(str, strlen(str));
if (info.format == SPA_AUDIO_FORMAT_UNKNOWN) {
pw_log_error("invalid format '%s'", str);
res = -EINVAL;
goto out;
}
pw_properties_set(props, "format", NULL); pw_properties_set(props, "format", NULL);
} }
if ((str = pw_properties_get(props, "sink_name")) != NULL) { if ((str = pw_properties_get(props, "sink_name")) != NULL) {

View file

@ -148,6 +148,11 @@ static int module_pipe_source_prepare(struct module * const module)
info.format = SPA_AUDIO_FORMAT_S16; info.format = SPA_AUDIO_FORMAT_S16;
if ((str = pw_properties_get(props, "format")) != NULL) { if ((str = pw_properties_get(props, "format")) != NULL) {
info.format = format_paname2id(str, strlen(str)); info.format = format_paname2id(str, strlen(str));
if (info.format == SPA_AUDIO_FORMAT_UNKNOWN) {
pw_log_error("invalid format '%s'", str);
res = -EINVAL;
goto out;
}
pw_properties_set(props, "format", NULL); pw_properties_set(props, "format", NULL);
} }
if ((str = pw_properties_get(props, "source_name")) != NULL) { if ((str = pw_properties_get(props, "source_name")) != NULL) {