mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: add spa_atob() to convert a string to a boolean
This replaces the manual check for "true" and some (inconsistent) return value of atoi. All those instances now require either "true" or "1" to parse as true, any other value (including NULL) is boolean false.
This commit is contained in:
parent
4e70799922
commit
cdfd50e166
18 changed files with 58 additions and 34 deletions
|
|
@ -959,9 +959,9 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
if ((str = spa_dict_lookup(info, SPA_KEY_API_ALSA_PATH)) != NULL)
|
||||
snprintf(this->props.device, sizeof(this->props.device), "%s", str);
|
||||
if ((str = spa_dict_lookup(info, "api.acp.auto-port")) != NULL)
|
||||
this->props.auto_port = spa_streq(str, "true") || atoi(str) != 0;
|
||||
this->props.auto_port = spa_atob(str);
|
||||
if ((str = spa_dict_lookup(info, "api.acp.auto-profile")) != NULL)
|
||||
this->props.auto_profile = spa_streq(str, "true") || atoi(str) != 0;
|
||||
this->props.auto_profile = spa_atob(str);
|
||||
|
||||
items = alloca((info->n_items) * sizeof(*items));
|
||||
spa_dict_for_each(it, info)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue