treewide: replace strcmp() == 0 with spa_streq()

This change is only done in source files for now, header files will be done
separately.
This commit is contained in:
Peter Hutterer 2021-05-18 11:36:13 +10:00
parent d8a9534a9a
commit 7697ed0757
130 changed files with 817 additions and 675 deletions

View file

@ -40,6 +40,7 @@
#endif
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/json.h>
#include <pipewire/impl.h>
@ -92,7 +93,7 @@ static int check_cmdline(struct pw_impl_client *client, int pid, const char *str
goto exit_close;
while (spa_json_get_string(&it[1], key, sizeof(key)) > 0) {
if (strcmp(path, key) == 0) {
if (spa_streq(path, key)) {
res = 1;
goto exit_close;
}

View file

@ -35,6 +35,7 @@
#include <spa/utils/hook.h>
#include <spa/utils/result.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/utils/type-info.h>
#include <spa/param/format.h>
#include <spa/param/format-utils.h>
@ -127,7 +128,7 @@ static void node_port_init(void *data, struct pw_impl_port *port)
"input" : is_monitor ? "monitor" : "output";
if ((str = pw_properties_get(old, PW_KEY_AUDIO_CHANNEL)) == NULL ||
strcmp(str, "UNK") == 0) {
spa_streq(str, "UNK")) {
snprintf(position, sizeof(position), "%d", pw_impl_port_get_id(port) + 1);
str = position;
}

View file

@ -33,6 +33,7 @@
#include "config.h"
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/json.h>
#include <spa/param/profiler.h>
#include <spa/debug/pod.h>
@ -419,7 +420,7 @@ static uint32_t channel_from_name(const char *name)
{
int i;
for (i = 0; spa_type_audio_channel[i].name; i++) {
if (strcmp(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)) == 0)
if (spa_streq(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)))
return spa_type_audio_channel[i].type;
}
return SPA_AUDIO_CHANNEL_UNKNOWN;
@ -536,7 +537,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
if ((str = pw_properties_get(props, "aec.method")) == NULL)
str = "null";
if (strcmp(str, "webrtc") == 0)
if (spa_streq(str, "webrtc"))
impl->aec_info = echo_cancel_webrtc;
else
impl->aec_info = echo_cancel_null;

View file

@ -36,6 +36,7 @@
#include "module-filter-chain/ladspa.h"
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/json.h>
#include <spa/param/profiler.h>
#include <spa/debug/pod.h>
@ -375,7 +376,7 @@ static struct node *find_node(struct graph *graph, const char *name)
{
struct node *node;
spa_list_for_each(node, &graph->node_list, link) {
if (strcmp(node->name, name) == 0)
if (spa_streq(node->name, name))
return node;
}
return NULL;
@ -424,7 +425,7 @@ static struct port *find_port(struct node *node, const char *name, int descripto
d = node->desc->desc;
for (i = 0; i < n_ports; i++) {
struct port *port = &ports[i];
if (strcmp(d->PortNames[port->p], port_name) == 0)
if (spa_streq(d->PortNames[port->p], port_name))
return port;
}
return NULL;
@ -735,7 +736,7 @@ static const LADSPA_Descriptor *find_descriptor(LADSPA_Descriptor_Function desc_
const LADSPA_Descriptor *desc = desc_func(i);
if (desc == NULL)
break;
if (strcmp(desc->Label, label) == 0)
if (spa_streq(desc->Label, label))
return desc;
}
return NULL;
@ -776,7 +777,7 @@ static struct ladspa_handle *ladspa_handle_load(struct impl *impl, const char *p
}
spa_list_for_each(hndl, &impl->ladspa_handle_list, link) {
if (strcmp(hndl->path, path) == 0) {
if (spa_streq(hndl->path, path)) {
hndl->ref++;
return hndl;
}
@ -786,7 +787,7 @@ static struct ladspa_handle *ladspa_handle_load(struct impl *impl, const char *p
hndl->ref = 1;
snprintf(hndl->path, sizeof(hndl->path), "%s", path);
if (strcmp(plugin, "builtin") == 0) {
if (spa_streq(plugin, "builtin")) {
hndl->desc_func = builtin_ladspa_descriptor;
} else {
hndl->handle = dlopen(path, RTLD_NOW);
@ -841,7 +842,7 @@ static struct ladspa_descriptor *ladspa_descriptor_load(struct impl *impl,
return NULL;
spa_list_for_each(desc, &hndl->descriptor_list, link) {
if (strcmp(desc->label, label) == 0) {
if (spa_streq(desc->label, label)) {
desc->ref++;
return desc;
}
@ -946,13 +947,13 @@ static int parse_link(struct graph *graph, struct spa_json *json)
struct link *link;
while (spa_json_get_string(json, key, sizeof(key)) > 0) {
if (strcmp(key, "output") == 0) {
if (spa_streq(key, "output")) {
if (spa_json_get_string(json, output, sizeof(output)) <= 0) {
pw_log_error("output expects a string");
return -EINVAL;
}
}
else if (strcmp(key, "input") == 0) {
else if (spa_streq(key, "input")) {
if (spa_json_get_string(json, input, sizeof(input)) <= 0) {
pw_log_error("input expects a string");
return -EINVAL;
@ -1045,34 +1046,34 @@ static int load_node(struct graph *graph, struct spa_json *json)
uint32_t i;
while (spa_json_get_string(json, key, sizeof(key)) > 0) {
if (strcmp("type", key) == 0) {
if (spa_streq("type", key)) {
if (spa_json_get_string(json, type, sizeof(type)) <= 0) {
pw_log_error("type expects a string");
return -EINVAL;
}
} else if (strcmp("name", key) == 0) {
} else if (spa_streq("name", key)) {
if (spa_json_get_string(json, name, sizeof(name)) <= 0) {
pw_log_error("name expects a string");
return -EINVAL;
}
} else if (strcmp("plugin", key) == 0) {
} else if (spa_streq("plugin", key)) {
if (spa_json_get_string(json, plugin, sizeof(plugin)) <= 0) {
pw_log_error("plugin expects a string");
return -EINVAL;
}
} else if (strcmp("label", key) == 0) {
} else if (spa_streq("label", key)) {
if (spa_json_get_string(json, label, sizeof(label)) <= 0) {
pw_log_error("label expects a string");
return -EINVAL;
}
} else if (strcmp("control", key) == 0) {
} else if (spa_streq("control", key)) {
it[0] = *json;
have_control = true;
} else if (spa_json_next(json, &val) < 0)
break;
}
if (strcmp(type, "builtin") == 0) {
if (spa_streq(type, "builtin")) {
snprintf(plugin, sizeof(plugin), "%s", "builtin");
} else if (strcmp(type, "ladspa") != 0)
return -ENOTSUP;
@ -1323,7 +1324,7 @@ static int setup_graph(struct graph *graph, struct spa_json *inputs, struct spa_
struct spa_json it = *inputs;
while (spa_json_get_string(&it, v, sizeof(v)) > 0) {
gp = &graph->input[graph->n_input];
if (strcmp(v, "null") == 0) {
if (spa_streq(v, "null")) {
gp->desc = NULL;
pw_log_info("ignore input port %d", graph->n_input);
} else if ((port = find_port(first, v, LADSPA_PORT_INPUT)) == NULL) {
@ -1371,7 +1372,7 @@ static int setup_graph(struct graph *graph, struct spa_json *inputs, struct spa_
struct spa_json it = *outputs;
while (spa_json_get_string(&it, v, sizeof(v)) > 0) {
gp = &graph->output[graph->n_output];
if (strcmp(v, "null") == 0) {
if (spa_streq(v, "null")) {
gp->desc = NULL;
pw_log_info("silence output port %d", graph->n_output);
} else if ((port = find_port(last, v, LADSPA_PORT_OUTPUT)) == NULL) {
@ -1476,7 +1477,7 @@ static int load_graph(struct graph *graph, struct pw_properties *props)
}
while (spa_json_get_string(&it[1], key, sizeof(key)) > 0) {
if (strcmp("nodes", key) == 0) {
if (spa_streq("nodes", key)) {
if (spa_json_enter_array(&it[1], &it[2]) <= 0) {
pw_log_error("nodes expect an array");
return -EINVAL;
@ -1486,7 +1487,7 @@ static int load_graph(struct graph *graph, struct pw_properties *props)
return res;
}
}
else if (strcmp("links", key) == 0) {
else if (spa_streq("links", key)) {
if (spa_json_enter_array(&it[1], &it[2]) <= 0)
return -EINVAL;
@ -1495,12 +1496,12 @@ static int load_graph(struct graph *graph, struct pw_properties *props)
return res;
}
}
else if (strcmp("inputs", key) == 0) {
else if (spa_streq("inputs", key)) {
if (spa_json_enter_array(&it[1], &inputs) <= 0)
return -EINVAL;
pinputs = &inputs;
}
else if (strcmp("outputs", key) == 0) {
else if (spa_streq("outputs", key)) {
if (spa_json_enter_array(&it[1], &outputs) <= 0)
return -EINVAL;
poutputs = &outputs;
@ -1582,7 +1583,7 @@ static uint32_t channel_from_name(const char *name)
{
int i;
for (i = 0; spa_type_audio_channel[i].name; i++) {
if (strcmp(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)) == 0)
if (spa_streq(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)))
return spa_type_audio_channel[i].type;
}
return SPA_AUDIO_CHANNEL_UNKNOWN;

View file

@ -30,6 +30,7 @@
#include "config.h"
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <pipewire/impl.h>
@ -222,7 +223,7 @@ static int find_port_func(void *data, struct pw_global *global)
props = pw_global_get_properties(global);
if ((str = pw_properties_get(props, PW_KEY_OBJECT_PATH)) != NULL &&
strcmp(str, find->name) == 0)
spa_streq(str, find->name))
goto found;
return 0;
found:
@ -241,13 +242,13 @@ static int find_node_port_func(void *data, struct pw_impl_port *port)
props = pw_impl_port_get_properties(port);
if ((str = pw_properties_get(props, PW_KEY_PORT_NAME)) != NULL &&
strcmp(str, find->name) == 0)
spa_streq(str, find->name))
goto found;
if ((str = pw_properties_get(props, PW_KEY_PORT_ALIAS)) != NULL &&
strcmp(str, find->name) == 0)
spa_streq(str, find->name))
goto found;
if ((str = pw_properties_get(props, PW_KEY_OBJECT_PATH)) != NULL &&
strcmp(str, find->name) == 0)
spa_streq(str, find->name))
goto found;
return 0;
found:
@ -310,16 +311,16 @@ static int find_node_func(void *data, struct pw_global *global)
props = pw_global_get_properties(global);
if ((str = pw_properties_get(props, PW_KEY_NODE_NAME)) != NULL &&
strcmp(str, find->name) == 0)
spa_streq(str, find->name))
goto found;
if ((str = pw_properties_get(props, PW_KEY_NODE_NICK)) != NULL &&
strcmp(str, find->name) == 0)
spa_streq(str, find->name))
goto found;
if ((str = pw_properties_get(props, PW_KEY_NODE_DESCRIPTION)) != NULL &&
strcmp(str, find->name) == 0)
spa_streq(str, find->name))
goto found;
if ((str = pw_properties_get(props, PW_KEY_OBJECT_PATH)) != NULL &&
strcmp(str, find->name) == 0)
spa_streq(str, find->name))
goto found;
return 0;
found:

View file

@ -33,6 +33,7 @@
#include "config.h"
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/json.h>
#include <spa/param/profiler.h>
#include <spa/debug/pod.h>
@ -299,7 +300,7 @@ static uint32_t channel_from_name(const char *name)
{
int i;
for (i = 0; spa_type_audio_channel[i].name; i++) {
if (strcmp(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)) == 0)
if (spa_streq(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)))
return spa_type_audio_channel[i].type;
}
return SPA_AUDIO_CHANNEL_UNKNOWN;

View file

@ -35,6 +35,7 @@
#include <dbus/dbus.h>
#include <spa/utils/string.h>
#include <spa/support/dbus.h>
#include "pipewire/context.h"
@ -215,7 +216,7 @@ static DBusHandlerResult name_owner_changed_handler(DBusConnection *connection,
if (strcmp(name, "org.freedesktop.portal.Desktop") != 0)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
if (strcmp(new_owner, "") == 0) {
if (spa_streq(new_owner, "")) {
impl->portal_pid = 0;
if (impl->portal_pid_pending != NULL) {
dbus_pending_call_cancel(impl->portal_pid_pending);

View file

@ -44,6 +44,7 @@
#include <spa/pod/iter.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#ifdef HAVE_SYSTEMD
#include <systemd/sd-daemon.h>
@ -1043,7 +1044,7 @@ impl_new_client(struct pw_protocol *protocol,
str = spa_dict_lookup(props, PW_KEY_REMOTE_INTENTION);
if (str == NULL &&
(str = spa_dict_lookup(props, PW_KEY_REMOTE_NAME)) != NULL &&
strcmp(str, "internal") == 0)
spa_streq(str, "internal"))
str = "internal";
}
if (str == NULL)

View file

@ -28,6 +28,7 @@
#include "spa/pod/parser.h"
#include "spa/pod/builder.h"
#include "spa/debug/pod.h"
#include "spa/utils/string.h"
#include "pipewire/pipewire.h"
#include "pipewire/private.h"
@ -251,7 +252,7 @@ static int core_demarshal_permissions(void *object, const struct pw_protocol_nat
str = props.items[i].value;
/* first set global permissions */
if (strcmp(props.items[i].key, PW_CORE_PERMISSIONS_GLOBAL) == 0) {
if (spa_streq(props.items[i].key, PW_CORE_PERMISSIONS_GLOBAL)) {
size_t len;
/* <global-id>:[r][w][x] */
@ -261,7 +262,7 @@ static int core_demarshal_permissions(void *object, const struct pw_protocol_nat
id = atoi(str);
perms = parse_perms(str + len);
permissions[n_permissions++] = PW_PERMISSION_INIT(id, perms);
} else if (strcmp(props.items[i].key, PW_CORE_PERMISSIONS_DEFAULT) == 0) {
} else if (spa_streq(props.items[i].key, PW_CORE_PERMISSIONS_DEFAULT)) {
perms = parse_perms(str);
defperm = PW_PERMISSION_INIT(PW_ID_ANY, perms);
}
@ -815,15 +816,15 @@ static void registry_marshal_global(void *object, uint32_t id, uint32_t permissi
parent_id = 0;
if (props) {
if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) {
if (spa_streq(type, PW_TYPE_INTERFACE_Port)) {
if ((str = spa_dict_lookup(props, "node.id")) != NULL)
parent_id = atoi(str);
} else if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) {
} else if (spa_streq(type, PW_TYPE_INTERFACE_Node)) {
if ((str = spa_dict_lookup(props, "device.id")) != NULL)
parent_id = atoi(str);
} else if (strcmp(type, PW_TYPE_INTERFACE_Client) == 0 ||
strcmp(type, PW_TYPE_INTERFACE_Device) == 0 ||
strcmp(type, PW_TYPE_INTERFACE_Factory) == 0) {
} else if (spa_streq(type, PW_TYPE_INTERFACE_Client) ||
spa_streq(type, PW_TYPE_INTERFACE_Device) ||
spa_streq(type, PW_TYPE_INTERFACE_Factory)) {
if ((str = spa_dict_lookup(props, "module.id")) != NULL)
parent_id = atoi(str);
}

View file

@ -22,6 +22,8 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <spa/utils/string.h>
struct selector {
bool (*type) (struct pw_manager_object *o);
uint32_t id;
@ -64,7 +66,7 @@ static struct pw_manager_object *select_object(struct pw_manager *m,
s->accumulate(s, o);
if (o->props && s->key != NULL && s->value != NULL &&
(str = pw_properties_get(o->props, s->key)) != NULL &&
strcmp(str, s->value) == 0)
spa_streq(str, s->value))
return o;
if (s->value != NULL && (uint32_t)atoi(s->value) == o->id)
return o;
@ -192,9 +194,9 @@ static uint32_t collect_profile_info(struct pw_manager_object *card, struct card
SPA_POD_Int(&count)) < 0)
continue;
if (strcmp(class, "Audio/Sink") == 0)
if (spa_streq(class, "Audio/Sink"))
pi->n_sinks += count;
else if (strcmp(class, "Audio/Source") == 0)
else if (spa_streq(class, "Audio/Source"))
pi->n_sources += count;
}
}
@ -223,7 +225,7 @@ static uint32_t find_profile_id(struct pw_manager_object *card, const char *name
SPA_PARAM_PROFILE_name, SPA_POD_String(&test_name)) < 0)
continue;
if (strcmp(test_name, name) == 0)
if (spa_streq(test_name, name))
return id;
}
@ -409,9 +411,9 @@ static uint32_t collect_port_info(struct pw_manager_object *card, struct card_in
SPA_POD_String(&value),
NULL) < 0)
break;
if (strcmp(key, "port.availability-group") == 0)
if (spa_streq(key, "port.availability-group"))
pi->availability_group = value;
else if (strcmp(key, "port.type") == 0)
else if (spa_streq(key, "port.type"))
pi->type = port_type_value(value);
}
spa_pod_parser_pop(&prs, &f[0]);
@ -443,7 +445,7 @@ static uint32_t find_port_id(struct pw_manager_object *card, uint32_t direction,
continue;
if (dir != direction)
continue;
if (strcmp(name, port_name) == 0)
if (spa_streq(name, port_name))
return id;
}

View file

@ -24,6 +24,8 @@
#define EXT_STREAM_RESTORE_VERSION 1
#include <spa/utils/string.h>
static const struct extension_sub ext_stream_restore[];
static int do_extension_stream_restore_test(struct client *client, uint32_t command, uint32_t tag, struct message *m)
@ -139,15 +141,15 @@ static int do_extension_stream_restore_read(struct client *client, uint32_t comm
continue;
while (spa_json_get_string(&it[1], key, sizeof(key)-1) > 0) {
if (strcmp(key, "volume") == 0) {
if (spa_streq(key, "volume")) {
if (spa_json_get_float(&it[1], &volume) <= 0)
continue;
}
else if (strcmp(key, "mute") == 0) {
else if (spa_streq(key, "mute")) {
if (spa_json_get_bool(&it[1], &mute) <= 0)
continue;
}
else if (strcmp(key, "volumes") == 0) {
else if (spa_streq(key, "volumes")) {
vol = VOLUME_INIT;
if (spa_json_enter_array(&it[1], &it[2]) <= 0)
continue;
@ -157,7 +159,7 @@ static int do_extension_stream_restore_read(struct client *client, uint32_t comm
break;
}
}
else if (strcmp(key, "channels") == 0) {
else if (spa_streq(key, "channels")) {
if (spa_json_enter_array(&it[1], &it[2]) <= 0)
continue;
@ -168,7 +170,7 @@ static int do_extension_stream_restore_read(struct client *client, uint32_t comm
map.map[map.channels] = channel_name2id(chname);
}
}
else if (strcmp(key, "target-node") == 0) {
else if (spa_streq(key, "target-node")) {
if (spa_json_get_string(&it[1], device_name, sizeof(device_name)) <= 0)
continue;
}

View file

@ -22,6 +22,8 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <spa/utils/string.h>
struct extension_sub {
const char *name;
uint32_t command;
@ -57,7 +59,7 @@ static struct extension *find_extension(uint32_t idx, const char *name)
uint32_t i;
for (i = 0; i < SPA_N_ELEMENTS(extensions); i++) {
if (idx == extensions[i].idx ||
(name && strcmp(name, extensions[i].name) == 0))
(name && spa_streq(name, extensions[i].name)))
return &extensions[i];
}
return 0;

View file

@ -24,6 +24,8 @@
#include "format.h"
#include <spa/utils/string.h>
static const struct format audio_formats[] = {
[SAMPLE_U8] = { SAMPLE_U8, SPA_AUDIO_FORMAT_U8, "u8", 1 },
[SAMPLE_ALAW] = { SAMPLE_ALAW, SPA_AUDIO_FORMAT_UNKNOWN, "aLaw", 1 },
@ -81,7 +83,7 @@ uint32_t format_name2id(const char *name)
{
int i;
for (i = 0; spa_type_audio_format[i].name; i++) {
if (strcmp(name, spa_debug_type_short_name(spa_type_audio_format[i].name)) == 0)
if (spa_streq(name, spa_debug_type_short_name(spa_type_audio_format[i].name)))
return spa_type_audio_format[i].type;
}
return SPA_AUDIO_CHANNEL_UNKNOWN;
@ -287,20 +289,20 @@ void channel_map_parse(const char *str, struct channel_map *map)
const char *p = str;
size_t len;
if (strcmp(p, "stereo") == 0) {
if (spa_streq(p, "stereo")) {
*map = (struct channel_map) {
.channels = 2,
.map[0] = SPA_AUDIO_CHANNEL_FL,
.map[1] = SPA_AUDIO_CHANNEL_FR,
};
} else if (strcmp(p, "surround-21") == 0) {
} else if (spa_streq(p, "surround-21")) {
*map = (struct channel_map) {
.channels = 3,
.map[0] = SPA_AUDIO_CHANNEL_FL,
.map[1] = SPA_AUDIO_CHANNEL_FR,
.map[2] = SPA_AUDIO_CHANNEL_LFE,
};
} else if (strcmp(p, "surround-40") == 0) {
} else if (spa_streq(p, "surround-40")) {
*map = (struct channel_map) {
.channels = 4,
.map[0] = SPA_AUDIO_CHANNEL_FL,
@ -308,7 +310,7 @@ void channel_map_parse(const char *str, struct channel_map *map)
.map[2] = SPA_AUDIO_CHANNEL_RL,
.map[3] = SPA_AUDIO_CHANNEL_RR,
};
} else if (strcmp(p, "surround-41") == 0) {
} else if (spa_streq(p, "surround-41")) {
*map = (struct channel_map) {
.channels = 5,
.map[0] = SPA_AUDIO_CHANNEL_FL,
@ -317,7 +319,7 @@ void channel_map_parse(const char *str, struct channel_map *map)
.map[3] = SPA_AUDIO_CHANNEL_RR,
.map[4] = SPA_AUDIO_CHANNEL_LFE,
};
} else if (strcmp(p, "surround-50") == 0) {
} else if (spa_streq(p, "surround-50")) {
*map = (struct channel_map) {
.channels = 5,
.map[0] = SPA_AUDIO_CHANNEL_FL,
@ -326,7 +328,7 @@ void channel_map_parse(const char *str, struct channel_map *map)
.map[3] = SPA_AUDIO_CHANNEL_RR,
.map[4] = SPA_AUDIO_CHANNEL_FC,
};
} else if (strcmp(p, "surround-51") == 0) {
} else if (spa_streq(p, "surround-51")) {
*map = (struct channel_map) {
.channels = 6,
.map[0] = SPA_AUDIO_CHANNEL_FL,
@ -336,7 +338,7 @@ void channel_map_parse(const char *str, struct channel_map *map)
.map[4] = SPA_AUDIO_CHANNEL_FC,
.map[5] = SPA_AUDIO_CHANNEL_LFE,
};
} else if (strcmp(p, "surround-71") == 0) {
} else if (spa_streq(p, "surround-71")) {
*map = (struct channel_map) {
.channels = 8,
.map[0] = SPA_AUDIO_CHANNEL_FL,

View file

@ -27,6 +27,7 @@
#include <spa/pod/iter.h>
#include <spa/pod/parser.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <extensions/metadata.h>
#define MAX_PARAMS 32
@ -540,7 +541,7 @@ static const struct object_info *find_info(const char *type, uint32_t version)
{
size_t i;
for (i = 0; i < SPA_N_ELEMENTS(objects); i++) {
if (strcmp(objects[i]->type, type) == 0 &&
if (spa_streq(objects[i]->type, type) &&
objects[i]->version <= version)
return objects[i];
}
@ -810,7 +811,7 @@ static struct object_data *object_find_data(struct object *o, const char *id)
{
struct object_data *d;
spa_list_for_each(d, &o->data_list, link) {
if (strcmp(d->id, id) == 0)
if (spa_streq(d->id, id))
return d;
}
return NULL;
@ -847,57 +848,57 @@ int pw_manager_sync(struct pw_manager *manager)
bool pw_manager_object_is_client(struct pw_manager_object *o)
{
return strcmp(o->type, PW_TYPE_INTERFACE_Client) == 0;
return spa_streq(o->type, PW_TYPE_INTERFACE_Client);
}
bool pw_manager_object_is_module(struct pw_manager_object *o)
{
return strcmp(o->type, PW_TYPE_INTERFACE_Module) == 0;
return spa_streq(o->type, PW_TYPE_INTERFACE_Module);
}
bool pw_manager_object_is_card(struct pw_manager_object *o)
{
const char *str;
return strcmp(o->type, PW_TYPE_INTERFACE_Device) == 0 &&
return spa_streq(o->type, PW_TYPE_INTERFACE_Device) &&
o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
strcmp(str, "Audio/Device") == 0;
spa_streq(str, "Audio/Device");
}
bool pw_manager_object_is_sink(struct pw_manager_object *o)
{
const char *str;
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
return spa_streq(o->type, PW_TYPE_INTERFACE_Node) &&
o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
(strcmp(str, "Audio/Sink") == 0 || strcmp(str, "Audio/Duplex") == 0);
(spa_streq(str, "Audio/Sink") || spa_streq(str, "Audio/Duplex"));
}
bool pw_manager_object_is_source(struct pw_manager_object *o)
{
const char *str;
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
return spa_streq(o->type, PW_TYPE_INTERFACE_Node) &&
o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
(strcmp(str, "Audio/Source") == 0 ||
strcmp(str, "Audio/Duplex") == 0 ||
strcmp(str, "Audio/Source/Virtual") == 0);
(spa_streq(str, "Audio/Source") ||
spa_streq(str, "Audio/Duplex") ||
spa_streq(str, "Audio/Source/Virtual"));
}
bool pw_manager_object_is_monitor(struct pw_manager_object *o)
{
const char *str;
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
return spa_streq(o->type, PW_TYPE_INTERFACE_Node) &&
o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
(strcmp(str, "Audio/Sink") == 0);
(spa_streq(str, "Audio/Sink"));
}
bool pw_manager_object_is_virtual(struct pw_manager_object *o)
{
const char *str;
struct pw_node_info *info;
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
return spa_streq(o->type, PW_TYPE_INTERFACE_Node) &&
(info = o->info) != NULL && info->props != NULL &&
(str = spa_dict_lookup(info->props, PW_KEY_NODE_VIRTUAL)) != NULL &&
pw_properties_parse_bool(str);
@ -911,19 +912,19 @@ bool pw_manager_object_is_source_or_monitor(struct pw_manager_object *o)
bool pw_manager_object_is_sink_input(struct pw_manager_object *o)
{
const char *str;
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
return spa_streq(o->type, PW_TYPE_INTERFACE_Node) &&
o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
strcmp(str, "Stream/Output/Audio") == 0;
spa_streq(str, "Stream/Output/Audio");
}
bool pw_manager_object_is_source_output(struct pw_manager_object *o)
{
const char *str;
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
return spa_streq(o->type, PW_TYPE_INTERFACE_Node) &&
o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
strcmp(str, "Stream/Input/Audio") == 0;
spa_streq(str, "Stream/Input/Audio");
}
bool pw_manager_object_is_recordable(struct pw_manager_object *o)
@ -933,5 +934,5 @@ bool pw_manager_object_is_recordable(struct pw_manager_object *o)
bool pw_manager_object_is_link(struct pw_manager_object *o)
{
return strcmp(o->type, PW_TYPE_INTERFACE_Link) == 0;
return spa_streq(o->type, PW_TYPE_INTERFACE_Link);
}

View file

@ -1,3 +1,5 @@
#include <spa/utils/string.h>
static int bluez_card_object_message_handler(struct pw_manager *m, struct pw_manager_object *o, const char *message, const char *params, char **response)
{
struct transport_codec_info codecs[64];
@ -10,7 +12,7 @@ static int bluez_card_object_message_handler(struct pw_manager *m, struct pw_man
if (n_codecs == 0)
return -EINVAL;
if (strcmp(message, "switch-codec") == 0) {
if (spa_streq(message, "switch-codec")) {
regex_t re;
regmatch_t matches[2];
char *codec;
@ -47,7 +49,7 @@ static int bluez_card_object_message_handler(struct pw_manager *m, struct pw_man
pw_device_set_param((struct pw_device *)o->proxy,
SPA_PARAM_Props, 0, param);
return 0;
} else if (strcmp(message, "list-codecs") == 0) {
} else if (spa_streq(message, "list-codecs")) {
uint32_t i;
FILE *r;
size_t size;
@ -64,7 +66,7 @@ static int bluez_card_object_message_handler(struct pw_manager *m, struct pw_man
fputc('}', r);
return fclose(r) ? -errno : 0;
} else if (strcmp(message, "get-codec") == 0) {
} else if (spa_streq(message, "get-codec")) {
if (active == SPA_ID_INVALID)
*response = strdup("{none}");
else
@ -79,7 +81,7 @@ static int core_object_message_handler(struct pw_manager *m, struct pw_manager_o
{
pw_log_debug(NAME "core %p object message:'%s' params:'%s'", o, message, params);
if (strcmp(message, "list-handlers") == 0) {
if (spa_streq(message, "list-handlers")) {
FILE *r;
size_t size;
@ -112,7 +114,7 @@ static void register_object_message_handlers(struct pw_manager_object *o)
if (pw_manager_object_is_card(o) && o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_DEVICE_API)) != NULL &&
strcmp(str, "bluez5") == 0) {
spa_streq(str, "bluez5")) {
str = pw_properties_get(o->props, PW_KEY_DEVICE_NAME);
if (str) {
free(o->message_object_path);

View file

@ -22,6 +22,8 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <spa/utils/string.h>
#define VOLUME_MUTED ((uint32_t) 0U)
#define VOLUME_NORM ((uint32_t) 0x10000U)
#define VOLUME_MAX ((uint32_t) UINT32_MAX/2)
@ -82,8 +84,8 @@ static inline const struct str_map *str_map_find(const struct str_map *map, cons
{
uint32_t i;
for (i = 0; map[i].pw_str; i++)
if ((pw && strcmp(map[i].pw_str, pw) == 0) ||
(pa && strcmp(map[i].pa_str, pa) == 0))
if ((pw && spa_streq(map[i].pw_str, pw)) ||
(pa && spa_streq(map[i].pa_str, pa)))
return &map[i];
return NULL;
}
@ -569,9 +571,9 @@ static void add_stream_group(struct message *m, struct spa_dict *dict, const cha
if (media_class == NULL)
return;
if (strcmp(media_class, "Stream/Output/Audio") == 0)
if (spa_streq(media_class, "Stream/Output/Audio"))
prefix = "sink-input";
else if (strcmp(media_class, "Stream/Input/Audio") == 0)
else if (spa_streq(media_class, "Stream/Input/Audio"))
prefix = "source-output";
else
return;
@ -614,9 +616,9 @@ static void write_dict(struct message *m, struct spa_dict *dict, bool remap)
(map = str_map_find(map->child, val, NULL)) != NULL)
val = map->pa_str;
}
if (strcmp(key, "media.class") == 0)
if (spa_streq(key, "media.class"))
media_class = val;
if (strcmp(key, "media.role") == 0)
if (spa_streq(key, "media.role"))
media_role = val;
write_string(m, key);

View file

@ -25,6 +25,8 @@
#include "module.h"
#include <spa/utils/string.h>
static int module_unload(struct client *client, struct module *module);
static void on_module_unload(void *obj, void *data, int res, uint32_t id)
@ -231,7 +233,7 @@ static const struct module_info *find_module_info(const char *name)
{
int i;
for (i = 0; module_list[i].name != NULL; i++) {
if (strcmp(module_list[i].name, name) == 0)
if (spa_streq(module_list[i].name, name))
return &module_list[i];
}
return NULL;

View file

@ -62,6 +62,7 @@
#include <spa/support/cpu.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/debug/dict.h>
#include <spa/debug/mem.h>
#include <spa/debug/types.h>
@ -147,7 +148,7 @@ static struct sample *find_sample(struct impl *impl, uint32_t idx, const char *n
pw_array_for_each(item, &impl->samples.items) {
struct sample *s = item->data;
if (!pw_map_item_is_free(item) &&
strcmp(s->name, name) == 0)
spa_streq(s->name, name))
return s;
}
return NULL;
@ -726,11 +727,11 @@ static void send_default_change_subscribe_event(struct client *client, bool sink
static void handle_metadata(struct client *client, struct pw_manager_object *old,
struct pw_manager_object *new, const char *name)
{
if (strcmp(name, "default") == 0) {
if (spa_streq(name, "default")) {
if (client->metadata_default == old)
client->metadata_default = new;
}
else if (strcmp(name, "route-settings") == 0) {
else if (spa_streq(name, "route-settings")) {
if (client->metadata_routes == old)
client->metadata_routes = new;
}
@ -743,7 +744,7 @@ static void manager_added(void *data, struct pw_manager_object *o)
register_object_message_handlers(o);
if (strcmp(o->type, PW_TYPE_INTERFACE_Metadata) == 0) {
if (spa_streq(o->type, PW_TYPE_INTERFACE_Metadata)) {
if (o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_METADATA_NAME)) != NULL)
handle_metadata(client, NULL, o, str);
@ -774,7 +775,7 @@ static void manager_removed(void *data, struct pw_manager_object *o)
send_default_change_subscribe_event(client, pw_manager_object_is_sink(o), pw_manager_object_is_source_or_monitor(o));
if (strcmp(o->type, PW_TYPE_INTERFACE_Metadata) == 0) {
if (spa_streq(o->type, PW_TYPE_INTERFACE_Metadata)) {
if (o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_METADATA_NAME)) != NULL)
handle_metadata(client, o, NULL, str);
@ -792,7 +793,7 @@ static int json_object_find(const char *obj, const char *key, char *value, size_
return -EINVAL;
while (spa_json_get_string(&it[1], k, sizeof(k)-1) > 0) {
if (strcmp(k, key) == 0) {
if (spa_streq(k, key)) {
if (spa_json_get_string(&it[1], value, len) <= 0)
continue;
return 0;
@ -825,7 +826,7 @@ static void manager_metadata(void *data, struct pw_manager_object *o,
if (subject == PW_ID_CORE && o == client->metadata_default) {
char name[1024];
if (key == NULL || strcmp(key, "default.audio.sink") == 0) {
if (key == NULL || spa_streq(key, "default.audio.sink")) {
if (value != NULL) {
if (json_object_find(value,
"name", name, sizeof(name)) < 0)
@ -838,7 +839,7 @@ static void manager_metadata(void *data, struct pw_manager_object *o,
client->default_sink = value ? strdup(value) : NULL;
}
}
if (key == NULL || strcmp(key, "default.audio.source") == 0) {
if (key == NULL || spa_streq(key, "default.audio.source")) {
if (value != NULL) {
if (json_object_find(value,
"name", name, sizeof(name)) < 0)
@ -2597,7 +2598,7 @@ static struct pw_manager_object *find_device(struct client *client,
if (pw_endswith(name, ".monitor")) {
name = strndupa(name, strlen(name)-8);
monitor = true;
} else if (strcmp(name, DEFAULT_MONITOR) == 0) {
} else if (spa_streq(name, DEFAULT_MONITOR)) {
name = NULL;
monitor = true;
}
@ -2626,8 +2627,8 @@ static struct pw_manager_object *find_device(struct client *client,
def = DEFAULT_SOURCE;
}
if (id == SPA_ID_INVALID &&
(sel.value == NULL || strcmp(sel.value, def) == 0 ||
strcmp(sel.value, "0") == 0))
(sel.value == NULL || spa_streq(sel.value, def) ||
spa_streq(sel.value, "0")))
sel.value = get_default(client, sink);
return select_object(client->manager, &sel);
@ -4412,7 +4413,7 @@ static int do_get_info(struct client *client, uint32_t command, uint32_t tag, st
if (command == COMMAND_GET_SINK_INFO || command == COMMAND_GET_SOURCE_INFO) {
if ((sel.value == NULL && (sel.id == SPA_ID_INVALID || sel.id == 0)) ||
(sel.value != NULL && (strcmp(sel.value, def) == 0 || strcmp(sel.value, "0") == 0)))
(sel.value != NULL && (spa_streq(sel.value, def) || spa_streq(sel.value, "0"))))
sel.value = get_default(client, command == COMMAND_GET_SINK_INFO);
} else {
if (sel.value == NULL && sel.id == SPA_ID_INVALID)
@ -5144,7 +5145,7 @@ static int do_send_object_message(struct client *client, uint32_t command, uint3
res = -ENOENT;
spa_list_for_each(o, &manager->object_list, link) {
if (o->message_object_path && strcmp(o->message_object_path, path) == 0) {
if (o->message_object_path && spa_streq(o->message_object_path, path)) {
if (o->message_handler)
res = o->message_handler(manager, o, message, params, &response);
else

View file

@ -39,6 +39,7 @@
#include "config.h"
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/json.h>
#include <spa/pod/pod.h>
#include <spa/pod/builder.h>
@ -671,7 +672,7 @@ static inline uint32_t channel_from_name(const char *name)
{
int i;
for (i = 0; spa_type_audio_channel[i].name; i++) {
if (strcmp(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)) == 0)
if (spa_streq(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)))
return spa_type_audio_channel[i].type;
}
return SPA_AUDIO_CHANNEL_UNKNOWN;

View file

@ -37,6 +37,7 @@
#include "config.h"
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/json.h>
#include <spa/utils/ringbuffer.h>
#include <spa/debug/pod.h>
@ -645,7 +646,7 @@ static uint32_t channel_from_name(const char *name)
{
int i;
for (i = 0; spa_type_audio_channel[i].name; i++) {
if (strcmp(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)) == 0)
if (spa_streq(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)))
return spa_type_audio_channel[i].type;
}
return SPA_AUDIO_CHANNEL_UNKNOWN;
@ -731,9 +732,9 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
impl->buffer = calloc(1, RINGBUFFER_SIZE);
if ((str = pw_properties_get(props, "tunnel.mode")) != NULL) {
if (strcmp(str, "capture") == 0) {
if (spa_streq(str, "capture")) {
impl->mode = MODE_CAPTURE;
} else if (strcmp(str, "playback") == 0) {
} else if (spa_streq(str, "playback")) {
impl->mode = MODE_PLAYBACK;
} else {
pw_log_error("invalid tunnel.mode '%s'", str);

View file

@ -41,6 +41,7 @@
#include <spa/support/dbus.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <pipewire/impl.h>
@ -181,13 +182,13 @@ static int translate_error(const char *name)
{
pw_log_warn("RTKit error: %s", name);
if (0 == strcmp(name, DBUS_ERROR_NO_MEMORY))
if (spa_streq(name, DBUS_ERROR_NO_MEMORY))
return -ENOMEM;
if (0 == strcmp(name, DBUS_ERROR_SERVICE_UNKNOWN) ||
0 == strcmp(name, DBUS_ERROR_NAME_HAS_NO_OWNER))
if (spa_streq(name, DBUS_ERROR_SERVICE_UNKNOWN) ||
spa_streq(name, DBUS_ERROR_NAME_HAS_NO_OWNER))
return -ENOENT;
if (0 == strcmp(name, DBUS_ERROR_ACCESS_DENIED) ||
0 == strcmp(name, DBUS_ERROR_AUTH_FAILED))
if (spa_streq(name, DBUS_ERROR_ACCESS_DENIED) ||
spa_streq(name, DBUS_ERROR_AUTH_FAILED))
return -EACCES;
return -EIO;

View file

@ -33,6 +33,7 @@
#include "config.h"
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/json.h>
#include <pipewire/impl.h>
@ -136,9 +137,9 @@ static struct tunnel *find_tunnel(struct impl *impl, const struct tunnel_info *i
spa_list_for_each(t, &impl->tunnel_list, link) {
if (t->info.interface == info->interface &&
t->info.protocol == info->protocol &&
strcmp(t->info.name, info->name) == 0 &&
strcmp(t->info.type, info->type) == 0 &&
strcmp(t->info.domain, info->domain) == 0)
spa_streq(t->info.name, info->name) &&
spa_streq(t->info.type, info->type) &&
spa_streq(t->info.domain, info->domain))
return t;
}
return NULL;
@ -229,33 +230,33 @@ static void resolver_cb(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiPr
if (avahi_string_list_get_pair(l, &key, &value, NULL) != 0)
break;
if (strcmp(key, "device") == 0) {
if (spa_streq(key, "device")) {
pw_properties_set(props, PW_KEY_NODE_TARGET, value);
}
else if (strcmp(key, "rate") == 0) {
else if (spa_streq(key, "rate")) {
pw_properties_setf(props, PW_KEY_AUDIO_RATE, "%u", atoi(value));
}
else if (strcmp(key, "channels") == 0) {
else if (spa_streq(key, "channels")) {
pw_properties_setf(props, PW_KEY_AUDIO_CHANNELS, "%u", atoi(value));
}
else if (strcmp(key, "format") == 0) {
else if (spa_streq(key, "format")) {
pw_properties_set(props, PW_KEY_AUDIO_FORMAT, value);
}
else if (strcmp(key, "icon-name") == 0) {
else if (spa_streq(key, "icon-name")) {
pw_properties_set(props, PW_KEY_DEVICE_ICON_NAME, value);
}
else if (strcmp(key, "channel_map") == 0) {
else if (spa_streq(key, "channel_map")) {
}
else if (strcmp(key, "product-name") == 0) {
else if (spa_streq(key, "product-name")) {
pw_properties_set(props, PW_KEY_DEVICE_PRODUCT_NAME, value);
}
else if (strcmp(key, "description") == 0) {
else if (spa_streq(key, "description")) {
pw_properties_set(props, "tunnel.remote.description", value);
}
else if (strcmp(key, "fqdn") == 0) {
else if (spa_streq(key, "fqdn")) {
pw_properties_set(props, "tunnel.remote.fqdn", value);
}
else if (strcmp(key, "user-name") == 0) {
else if (spa_streq(key, "user-name")) {
pw_properties_set(props, "tunnel.remote.user", value);
}
avahi_free(key);