mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse-server: improve module args compatibility
Boolean switches can also be true with 'y', 'yes', 't' and 'on'
This commit is contained in:
parent
310e6009ca
commit
c8f629a0a3
6 changed files with 14 additions and 5 deletions
|
|
@ -227,6 +227,14 @@ int module_args_to_audioinfo(struct impl *impl, struct pw_properties *props, str
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool module_args_parse_bool(const char *v)
|
||||
{
|
||||
if (spa_streq(v, "1") || !strcasecmp(v, "y") || !strcasecmp(v, "t") ||
|
||||
!strcasecmp(v, "yes") || !strcasecmp(v, "true") || !strcasecmp(v, "on"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
#include "modules/registry.h"
|
||||
|
||||
static const struct module_info module_list[] = {
|
||||
|
|
|
|||
|
|
@ -82,5 +82,6 @@ void module_add_listener(struct module *module,
|
|||
|
||||
void module_args_add_props(struct pw_properties *props, const char *str);
|
||||
int module_args_to_audioinfo(struct impl *impl, struct pw_properties *props, struct spa_audio_info_raw *info);
|
||||
bool module_args_parse_bool(const char *str);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ struct module *create_module_loopback(struct impl *impl, const char *argument)
|
|||
if ((str = pw_properties_get(props, "remix")) != NULL) {
|
||||
/* Note that the boolean is inverted */
|
||||
pw_properties_set(playback_props, PW_KEY_STREAM_DONT_REMIX,
|
||||
pw_properties_parse_bool(str) ? "false" : "true");
|
||||
module_args_parse_bool(str) ? "false" : "true");
|
||||
pw_properties_set(props, "remix", NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ struct module *create_module_remap_sink(struct impl *impl, const char *argument)
|
|||
if ((str = pw_properties_get(props, "remix")) != NULL) {
|
||||
/* Note that the boolean is inverted */
|
||||
pw_properties_set(playback_props, PW_KEY_STREAM_DONT_REMIX,
|
||||
pw_properties_parse_bool(str) ? "false" : "true");
|
||||
module_args_parse_bool(str) ? "false" : "true");
|
||||
pw_properties_set(props, "remix", NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ struct module *create_module_remap_source(struct impl *impl, const char *argumen
|
|||
if ((str = pw_properties_get(props, "remix")) != NULL) {
|
||||
/* Note that the boolean is inverted */
|
||||
pw_properties_set(capture_props, PW_KEY_STREAM_DONT_REMIX,
|
||||
pw_properties_parse_bool(str) ? "false" : "true");
|
||||
module_args_parse_bool(str) ? "false" : "true");
|
||||
pw_properties_set(props, "remix", NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -268,12 +268,12 @@ struct module *create_module_switch_on_connect(struct impl *impl, const char *ar
|
|||
module_args_add_props(props, argument);
|
||||
|
||||
if ((str = pw_properties_get(props, "only_from_unavailable")) != NULL) {
|
||||
only_from_unavailable = pw_properties_parse_bool(str);
|
||||
only_from_unavailable = module_args_parse_bool(str);
|
||||
pw_properties_set(props, "only_from_unavailable", NULL);
|
||||
}
|
||||
|
||||
if ((str = pw_properties_get(props, "ignore_virtual")) != NULL) {
|
||||
ignore_virtual = pw_properties_parse_bool(str);
|
||||
ignore_virtual = module_args_parse_bool(str);
|
||||
pw_properties_set(props, "ignore_virtual", NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue