diff --git a/pipewire-alsa/alsa-plugins/ctl_pipewire.c b/pipewire-alsa/alsa-plugins/ctl_pipewire.c index 0985fef3d..ebfa5f53a 100644 --- a/pipewire-alsa/alsa-plugins/ctl_pipewire.c +++ b/pipewire-alsa/alsa-plugins/ctl_pipewire.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -163,11 +164,11 @@ static struct global *find_global(snd_ctl_pipewire_t *ctl, uint32_t id, spa_list_for_each(g, &ctl->globals, link) { if ((g->id == id || g->id == name_id) && - (type == NULL || strcmp(g->ginfo->type, type) == 0)) + (type == NULL || spa_streq(g->ginfo->type, type))) return g; if (name != NULL && name[0] != '\0' && (str = pw_properties_get(g->props, PW_KEY_NODE_NAME)) != NULL && - strcmp(name, str) == 0) + spa_streq(name, str)) return g; } return NULL; @@ -177,7 +178,7 @@ static struct global *find_best_node(snd_ctl_pipewire_t *ctl, uint32_t flags) { struct global *g, *best = NULL; spa_list_for_each(g, &ctl->globals, link) { - if ((strcmp(g->ginfo->type, PW_TYPE_INTERFACE_Node) == 0) && + if ((spa_streq(g->ginfo->type, PW_TYPE_INTERFACE_Node)) && (flags == 0 || (g->node.flags & flags) == flags) && (best == NULL || best->node.priority < g->node.priority)) best = g; @@ -344,13 +345,13 @@ static snd_ctl_ext_key_t pipewire_find_elem(snd_ctl_ext_t * ext, name = snd_ctl_elem_id_get_name(id); - if (strcmp(name, SOURCE_VOL_NAME) == 0) + if (spa_streq(name, SOURCE_VOL_NAME)) return 0; - if (strcmp(name, SOURCE_MUTE_NAME) == 0) + if (spa_streq(name, SOURCE_MUTE_NAME)) return 1; - if (strcmp(name, SINK_VOL_NAME) == 0) + if (spa_streq(name, SINK_VOL_NAME)) return 2; - if (strcmp(name, SINK_MUTE_NAME) == 0) + if (spa_streq(name, SINK_MUTE_NAME)) return 3; return SND_CTL_EXT_KEY_NOT_FOUND; @@ -836,7 +837,7 @@ static struct global *find_node_for_route(snd_ctl_pipewire_t *ctl, uint32_t card { struct global *n; spa_list_for_each(n, &ctl->globals, link) { - if (strcmp(n->ginfo->type, PW_TYPE_INTERFACE_Node) == 0 && + if (spa_streq(n->ginfo->type, PW_TYPE_INTERFACE_Node) && (n->node.device_id == card) && (n->node.profile_device_id == device)) return n; @@ -925,9 +926,9 @@ static void node_event_info(void *object, const struct pw_node_info *info) if ((str = spa_dict_lookup(info->props, PW_KEY_PRIORITY_SESSION))) g->node.priority = atoi(str); if ((str = spa_dict_lookup(info->props, PW_KEY_MEDIA_CLASS))) { - if (strcmp(str, "Audio/Sink") == 0) + if (spa_streq(str, "Audio/Sink")) g->node.flags |= NODE_FLAG_SINK; - else if (strcmp(str, "Audio/Source") == 0) + else if (spa_streq(str, "Audio/Source")) g->node.flags |= NODE_FLAG_SOURCE; } } @@ -991,7 +992,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; @@ -1013,14 +1014,14 @@ static int metadata_property(void *object, snd_ctl_pipewire_t *ctl = g->ctl; if (subject == PW_ID_CORE) { - if (key == NULL || strcmp(key, "default.audio.sink") == 0) { + if (key == NULL || spa_streq(key, "default.audio.sink")) { if (value == NULL || json_object_find(value, "name", ctl->default_sink, sizeof(ctl->default_sink)) < 0) ctl->default_sink[0] = '\0'; pw_log_debug("found default sink: %s", ctl->default_sink); } - if (key == NULL || strcmp(key, "default.audio.source") == 0) { + if (key == NULL || spa_streq(key, "default.audio.source")) { if (value == NULL || json_object_find(value, "name", ctl->default_source, sizeof(ctl->default_source)) < 0) @@ -1081,7 +1082,7 @@ static void registry_event_global(void *data, uint32_t id, pw_log_debug("got %d %s", id, type); - if (strcmp(type, PW_TYPE_INTERFACE_Device) == 0) { + if (spa_streq(type, PW_TYPE_INTERFACE_Device)) { if (props == NULL || ((str = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS)) == NULL) || (strcmp(str, "Audio/Device") != 0)) @@ -1089,7 +1090,7 @@ static void registry_event_global(void *data, uint32_t id, pw_log_debug("found device %d", id); info = &device_info; - } else if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) { + } else if (spa_streq(type, PW_TYPE_INTERFACE_Node)) { if (props == NULL || ((str = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS)) == NULL) || ((strcmp(str, "Audio/Sink") != 0) && @@ -1098,7 +1099,7 @@ static void registry_event_global(void *data, uint32_t id, pw_log_debug("found node %d type:%s", id, str); info = &node_info; - } else if (strcmp(type, PW_TYPE_INTERFACE_Metadata) == 0) { + } else if (spa_streq(type, PW_TYPE_INTERFACE_Metadata)) { if (ctl->metadata != NULL) return; info = &metadata_info; @@ -1146,9 +1147,9 @@ static void registry_event_global_remove(void *data, uint32_t id) if ((name = pw_properties_get(g->props, PW_KEY_NODE_NAME)) == NULL) return; - if (strcmp(name, ctl->default_sink) == 0) + if (spa_streq(name, ctl->default_sink)) ctl->default_sink[0] = '\0'; - if (strcmp(name, ctl->default_source) == 0) + if (spa_streq(name, ctl->default_source)) ctl->default_source[0] = '\0'; } @@ -1218,10 +1219,10 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pipewire) const char *id; if (snd_config_get_id(n, &id) < 0) continue; - if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0 - || strcmp(id, "hint") == 0) + if (spa_streq(id, "comment") || spa_streq(id, "type") + || spa_streq(id, "hint")) continue; - if (strcmp(id, "server") == 0) { + if (spa_streq(id, "server")) { if (snd_config_get_string(n, &server) < 0) { SNDERR("Invalid type for %s", id); return -EINVAL; @@ -1230,7 +1231,7 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pipewire) } continue; } - if (strcmp(id, "device") == 0) { + if (spa_streq(id, "device")) { if (snd_config_get_string(n, &device) < 0) { SNDERR("Invalid type for %s", id); return -EINVAL; @@ -1239,7 +1240,7 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pipewire) } continue; } - if (strcmp(id, "source") == 0) { + if (spa_streq(id, "source")) { if (snd_config_get_string(n, &source) < 0) { SNDERR("Invalid type for %s", id); return -EINVAL; @@ -1248,7 +1249,7 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pipewire) } continue; } - if (strcmp(id, "sink") == 0) { + if (spa_streq(id, "sink")) { if (snd_config_get_string(n, &sink) < 0) { SNDERR("Invalid type for %s", id); return -EINVAL; @@ -1257,7 +1258,7 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pipewire) } continue; } - if (strcmp(id, "fallback") == 0) { + if (spa_streq(id, "fallback")) { if (snd_config_get_string(n, &fallback_name) < 0) { SNDERR("Invalid value for %s", id); return -EINVAL; diff --git a/pipewire-alsa/alsa-plugins/pcm_pipewire.c b/pipewire-alsa/alsa-plugins/pcm_pipewire.c index 24f692c1f..ee22b2a31 100644 --- a/pipewire-alsa/alsa-plugins/pcm_pipewire.c +++ b/pipewire-alsa/alsa-plugins/pcm_pipewire.c @@ -41,6 +41,7 @@ #include #include #include +#include #include @@ -1105,30 +1106,30 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pipewire) const char *id; if (snd_config_get_id(n, &id) < 0) continue; - if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0 || strcmp(id, "hint") == 0) + if (spa_streq(id, "comment") || spa_streq(id, "type") || spa_streq(id, "hint")) continue; - if (strcmp(id, "name") == 0) { + if (spa_streq(id, "name")) { snd_config_get_string(n, &node_name); continue; } - if (strcmp(id, "server") == 0) { + if (spa_streq(id, "server")) { snd_config_get_string(n, &server_name); continue; } - if (strcmp(id, "playback_node") == 0) { + if (spa_streq(id, "playback_node")) { snd_config_get_string(n, &playback_node); continue; } - if (strcmp(id, "capture_node") == 0) { + if (spa_streq(id, "capture_node")) { snd_config_get_string(n, &capture_node); continue; } - if (strcmp(id, "exclusive") == 0) { + if (spa_streq(id, "exclusive")) { if (snd_config_get_bool(n)) flags |= PW_STREAM_FLAG_EXCLUSIVE; continue; } - if (strcmp(id, "rate") == 0) { + if (spa_streq(id, "rate")) { long val; if (snd_config_get_integer(n, &val) == 0) @@ -1137,7 +1138,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pipewire) SNDERR("%s: invalid type", id); continue; } - if (strcmp(id, "format") == 0) { + if (spa_streq(id, "format")) { const char *str; if (snd_config_get_string(n, &str) == 0) { @@ -1149,7 +1150,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pipewire) } continue; } - if (strcmp(id, "channels") == 0) { + if (spa_streq(id, "channels")) { long val; if (snd_config_get_integer(n, &val) == 0) @@ -1158,7 +1159,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(pipewire) SNDERR("%s: invalid type", id); continue; } - if (strcmp(id, "period_bytes") == 0) { + if (spa_streq(id, "period_bytes")) { long val; if (snd_config_get_integer(n, &val) == 0) diff --git a/pipewire-jack/src/metadata.c b/pipewire-jack/src/metadata.c index 280846508..20b259449 100644 --- a/pipewire-jack/src/metadata.c +++ b/pipewire-jack/src/metadata.c @@ -30,6 +30,8 @@ #include #include +#include + #include #include @@ -98,7 +100,7 @@ static jack_property_t *find_property(jack_description_t *desc, const char *key) uint32_t i; for (i = 0; i < desc->property_cnt; i++) { jack_property_t *prop = &desc->properties[i]; - if (strcmp(prop->key, key) == 0) + if (spa_streq(prop->key, key)) return prop; } return NULL; diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index 4bbbef9ec..8cadf3198 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -568,8 +569,8 @@ static bool is_port_default(struct client *c, struct object *o) return false; if ((ot = o->port.node) != NULL && - (strcmp(ot->node.node_name, c->metadata->default_audio_source) == 0 || - strcmp(ot->node.node_name, c->metadata->default_audio_sink) == 0)) + (spa_streq(ot->node.node_name, c->metadata->default_audio_source) || + spa_streq(ot->node.node_name, c->metadata->default_audio_sink))) return true; return false; @@ -580,11 +581,11 @@ static struct object *find_port(struct client *c, const char *name) struct object *o; spa_list_for_each(o, &c->context.ports, link) { - if (strcmp(o->port.name, name) == 0 || - strcmp(o->port.alias1, name) == 0 || - strcmp(o->port.alias2, name) == 0) + if (spa_streq(o->port.name, name) || + spa_streq(o->port.alias1, name) || + spa_streq(o->port.alias2, name)) return o; - if (is_port_default(c, o) && strcmp(o->port.system, name) == 0) + if (is_port_default(c, o) && spa_streq(o->port.system, name)) return o; } return NULL; @@ -2082,7 +2083,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; @@ -2104,7 +2105,7 @@ static int metadata_property(void *object, uint32_t id, pw_log_debug("set id:%u key:'%s' value:'%s' type:'%s'", id, key, value, type); if (id == PW_ID_CORE) { - 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", c->metadata->default_audio_sink, @@ -2114,7 +2115,7 @@ static int metadata_property(void *object, uint32_t id, if (value == NULL) c->metadata->default_audio_sink[0] = '\0'; } - 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", c->metadata->default_audio_source, @@ -2177,7 +2178,7 @@ static void registry_event_global(void *data, uint32_t id, if (props == NULL) return; - if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) { + if (spa_streq(type, PW_TYPE_INTERFACE_Node)) { const char *app, *node_name; char tmp[JACK_CLIENT_NAME_SIZE+1]; @@ -2238,7 +2239,7 @@ static void registry_event_global(void *data, uint32_t id, spa_list_append(&c->context.nodes, &o->link); pthread_mutex_unlock(&c->context.lock); } - else if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) { + else if (spa_streq(type, PW_TYPE_INTERFACE_Port)) { const struct spa_dict_item *item; unsigned long flags = 0; jack_port_type_id_t type_id; @@ -2265,9 +2266,9 @@ static void registry_event_global(void *data, uint32_t id, spa_dict_for_each(item, props) { if (!strcmp(item->key, PW_KEY_PORT_DIRECTION)) { - if (strcmp(item->value, "in") == 0) + if (spa_streq(item->value, "in")) flags |= JackPortIsInput; - else if (strcmp(item->value, "out") == 0) + else if (spa_streq(item->value, "out")) flags |= JackPortIsOutput; } else if (!strcmp(item->key, PW_KEY_PORT_PHYSICAL)) { @@ -2348,7 +2349,7 @@ static void registry_event_global(void *data, uint32_t id, pw_log_debug(NAME" %p: add port %d name:%s %d", c, id, o->port.name, type_id); } - else if (strcmp(type, PW_TYPE_INTERFACE_Link) == 0) { + else if (spa_streq(type, PW_TYPE_INTERFACE_Link)) { o = alloc_object(c, INTERFACE_Link); pthread_mutex_lock(&c->context.lock); @@ -2366,7 +2367,7 @@ static void registry_event_global(void *data, uint32_t id, pw_log_debug(NAME" %p: add link %d %d->%d", c, id, o->port_link.src, o->port_link.dst); } - else if (strcmp(type, PW_TYPE_INTERFACE_Metadata) == 0) { + else if (spa_streq(type, PW_TYPE_INTERFACE_Metadata)) { struct pw_proxy *proxy; if (c->metadata) @@ -2454,9 +2455,9 @@ static void registry_event_global_remove(void *object, uint32_t id) switch (o->type) { case INTERFACE_Node: if (c->metadata) { - if (strcmp(o->node.node_name, c->metadata->default_audio_sink) == 0) + if (spa_streq(o->node.node_name, c->metadata->default_audio_sink)) c->metadata->default_audio_sink[0] = '\0'; - if (strcmp(o->node.node_name, c->metadata->default_audio_source) == 0) + if (spa_streq(o->node.node_name, c->metadata->default_audio_source)) c->metadata->default_audio_source[0] = '\0'; } if (c->registration_callback && is_last) @@ -2537,7 +2538,7 @@ jack_client_t * jack_client_open (const char *client_name, va_end(ap); if (client->server_name != NULL && - strcmp(client->server_name, "default") == 0) + spa_streq(client->server_name, "default")) client->server_name = NULL; client->props = pw_properties_new( @@ -2580,13 +2581,13 @@ jack_client_t * jack_client_open (const char *client_name, client->self_connect_mode = SELF_CONNECT_ALLOW; if ((str = pw_properties_get(client->props, "jack.self-connect-mode")) != NULL) { - if (strcmp(str, "fail-external") == 0) + if (spa_streq(str, "fail-external")) client->self_connect_mode = SELF_CONNECT_FAIL_EXT; - else if (strcmp(str, "ignore-external") == 0) + else if (spa_streq(str, "ignore-external")) client->self_connect_mode = SELF_CONNECT_IGNORE_EXT; - else if (strcmp(str, "fail-all") == 0) + else if (spa_streq(str, "fail-all")) client->self_connect_mode = SELF_CONNECT_FAIL_ALL; - else if (strcmp(str, "ignore-all") == 0) + else if (spa_streq(str, "ignore-all")) client->self_connect_mode = SELF_CONNECT_IGNORE_ALL; } @@ -2811,7 +2812,7 @@ char *jack_get_uuid_for_client_name (jack_client_t *client, pthread_mutex_lock(&c->context.lock); spa_list_for_each(o, &c->context.nodes, link) { - if (strcmp(o->node.name, client_name) == 0) { + if (spa_streq(o->node.name, client_name)) { uuid = spa_aprintf( "%" PRIu64, client_make_uuid(o->id)); pw_log_debug(NAME" %p: name %s -> %s", client, client_name, uuid); @@ -3976,9 +3977,9 @@ int jack_port_unset_alias (jack_port_t *port, const char *alias) pw_thread_loop_lock(c->context.loop); - if (strcmp(o->port.alias1, alias) == 0) + if (spa_streq(o->port.alias1, alias)) key = PW_KEY_OBJECT_PATH; - else if (strcmp(o->port.alias2, alias) == 0) + else if (spa_streq(o->port.alias2, alias)) key = PW_KEY_PORT_ALIAS; else goto error; @@ -4433,19 +4434,19 @@ static int port_compare_func(const void *v1, const void *v2) ot1 = (*o1)->port.node; if (is_cap1) - is_def1 = ot1 != NULL && strcmp(ot1->node.node_name, - c->metadata->default_audio_source) == 0; + is_def1 = ot1 != NULL && spa_streq(ot1->node.node_name, + c->metadata->default_audio_source); else if (!is_cap1) - is_def1 = ot1 != NULL && strcmp(ot1->node.node_name, - c->metadata->default_audio_sink) == 0; + is_def1 = ot1 != NULL && spa_streq(ot1->node.node_name, + c->metadata->default_audio_sink); ot2 = (*o2)->port.node; if (is_cap2) - is_def2 = ot2 != NULL && strcmp(ot2->node.node_name, - c->metadata->default_audio_source) == 0; + is_def2 = ot2 != NULL && spa_streq(ot2->node.node_name, + c->metadata->default_audio_source); else if (!is_cap2) - is_def2 = ot2 != NULL && strcmp(ot2->node.node_name, - c->metadata->default_audio_sink) == 0; + is_def2 = ot2 != NULL && spa_streq(ot2->node.node_name, + c->metadata->default_audio_sink); } if ((*o1)->port.type_id != (*o2)->port.type_id) res = (*o1)->port.type_id - (*o2)->port.type_id; diff --git a/spa/plugins/alsa/acp/acp.c b/spa/plugins/alsa/acp/acp.c index 1b15bd44c..e481cd19a 100644 --- a/spa/plugins/alsa/acp/acp.c +++ b/spa/plugins/alsa/acp/acp.c @@ -26,6 +26,8 @@ #include "alsa-mixer.h" #include "alsa-ucm.h" +#include + int _acp_log_level = 1; acp_log_func _acp_log_func; void *_acp_log_data; @@ -938,7 +940,7 @@ uint32_t acp_card_find_best_profile_index(struct acp_card *card, const char *nam struct acp_card_profile *p = profiles[i]; if (name) { - if (strcmp(name, p->name) == 0) + if (spa_streq(name, p->name)) best = i; } else if (p->flags & ACP_PROFILE_OFF) { off = i; @@ -1442,7 +1444,7 @@ static const char *acp_dict_lookup(const struct acp_dict *dict, const char *key) { const struct acp_dict_item *it; acp_dict_for_each(it, dict) { - if (strcmp(key, it->key) == 0) + if (spa_streq(key, it->key)) return it->value; } return NULL; @@ -1478,19 +1480,19 @@ struct acp_card *acp_card_new(uint32_t index, const struct acp_dict *props) if (props) { if ((s = acp_dict_lookup(props, "api.alsa.use-ucm")) != NULL) - impl->use_ucm = (strcmp(s, "true") == 0 || atoi(s) == 1); + impl->use_ucm = (spa_streq(s, "true") || atoi(s) == 1); if ((s = acp_dict_lookup(props, "api.alsa.soft-mixer")) != NULL) - impl->soft_mixer = (strcmp(s, "true") == 0 || atoi(s) == 1); + impl->soft_mixer = (spa_streq(s, "true") || atoi(s) == 1); if ((s = acp_dict_lookup(props, "api.alsa.ignore-dB")) != NULL) - ignore_dB = (strcmp(s, "true") == 0 || atoi(s) == 1); + ignore_dB = (spa_streq(s, "true") || atoi(s) == 1); if ((s = acp_dict_lookup(props, "device.profile-set")) != NULL) profile_set = s; if ((s = acp_dict_lookup(props, "device.profile")) != NULL) profile = s; if ((s = acp_dict_lookup(props, "api.acp.auto-profile")) != NULL) - impl->auto_profile = (strcmp(s, "true") == 0 || atoi(s) == 1); + impl->auto_profile = (spa_streq(s, "true") || atoi(s) == 1); if ((s = acp_dict_lookup(props, "api.acp.auto-port")) != NULL) - impl->auto_port = (strcmp(s, "true") == 0 || atoi(s) == 1); + impl->auto_port = (spa_streq(s, "true") || atoi(s) == 1); } impl->ucm.default_sample_spec.format = PA_SAMPLE_S16NE; @@ -1715,7 +1717,7 @@ uint32_t acp_device_find_best_port_index(struct acp_device *dev, const char *nam struct acp_port *p = ports[i]; if (name) { - if (strcmp(name, p->name) == 0) + if (spa_streq(name, p->name)) best = i; } else if (p->available == ACP_AVAILABLE_YES) { if (best == ACP_INVALID_INDEX || p->priority > ports[best]->priority) diff --git a/spa/plugins/alsa/alsa-acp-device.c b/spa/plugins/alsa/alsa-acp-device.c index a20c19081..a0e8c3013 100644 --- a/spa/plugins/alsa/alsa-acp-device.c +++ b/spa/plugins/alsa/alsa-acp-device.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -880,7 +881,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) *interface = &this->device; else return -ENOENT; @@ -958,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 = strcmp(str, "true") == 0 || atoi(str) != 0; + this->props.auto_port = spa_streq(str, "true") || atoi(str) != 0; if ((str = spa_dict_lookup(info, "api.acp.auto-profile")) != NULL) - this->props.auto_profile = strcmp(str, "true") == 0 || atoi(str) != 0; + this->props.auto_profile = spa_streq(str, "true") || atoi(str) != 0; items = alloca((info->n_items) * sizeof(*items)); spa_dict_for_each(it, info) diff --git a/spa/plugins/alsa/alsa-pcm-device.c b/spa/plugins/alsa/alsa-pcm-device.c index af30ed2da..dde4db4ba 100644 --- a/spa/plugins/alsa/alsa-pcm-device.c +++ b/spa/plugins/alsa/alsa-pcm-device.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -492,7 +493,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) *interface = &this->device; else return -ENOENT; diff --git a/spa/plugins/alsa/alsa-pcm-sink.c b/spa/plugins/alsa/alsa-pcm-sink.c index 43285862e..8449ed57e 100644 --- a/spa/plugins/alsa/alsa-pcm-sink.c +++ b/spa/plugins/alsa/alsa-pcm-sink.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -694,7 +695,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct state *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; @@ -807,11 +808,11 @@ impl_init(const struct spa_handle_factory *factory, } else if (!strcmp(k, "api.alsa.start-delay")) { this->default_start_delay = atoi(s); } else if (!strcmp(k, "api.alsa.disable-mmap")) { - this->disable_mmap = (strcmp(s, "true") == 0 || atoi(s) == 1); + this->disable_mmap = (spa_streq(s, "true") || atoi(s) == 1); } else if (!strcmp(k, "api.alsa.disable-batch")) { - this->disable_batch = (strcmp(s, "true") == 0 || atoi(s) == 1); + this->disable_batch = (spa_streq(s, "true") || atoi(s) == 1); } else if (!strcmp(k, "api.alsa.use-chmap")) { - this->props.use_chmap = (strcmp(s, "true") == 0 || atoi(s) == 1); + this->props.use_chmap = (spa_streq(s, "true") || atoi(s) == 1); } } return 0; diff --git a/spa/plugins/alsa/alsa-pcm-source.c b/spa/plugins/alsa/alsa-pcm-source.c index 81fd610e5..68a912773 100644 --- a/spa/plugins/alsa/alsa-pcm-source.c +++ b/spa/plugins/alsa/alsa-pcm-source.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -716,7 +717,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct state *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; @@ -825,11 +826,11 @@ impl_init(const struct spa_handle_factory *factory, } else if (!strcmp(k, "api.alsa.headroom")) { this->default_headroom = atoi(s); } else if (!strcmp(k, "api.alsa.disable-mmap")) { - this->disable_mmap = (strcmp(s, "true") == 0 || atoi(s) == 1); + this->disable_mmap = (spa_streq(s, "true") || atoi(s) == 1); } else if (!strcmp(k, "api.alsa.disable-batch")) { - this->disable_batch = (strcmp(s, "true") == 0 || atoi(s) == 1); + this->disable_batch = (spa_streq(s, "true") || atoi(s) == 1); } else if (!strcmp(k, "api.alsa.use-chmap")) { - this->props.use_chmap = (strcmp(s, "true") == 0 || atoi(s) == 1); + this->props.use_chmap = (spa_streq(s, "true") || atoi(s) == 1); } } return 0; diff --git a/spa/plugins/alsa/alsa-seq-bridge.c b/spa/plugins/alsa/alsa-seq-bridge.c index 86b433fbb..254648bce 100644 --- a/spa/plugins/alsa/alsa-seq-bridge.c +++ b/spa/plugins/alsa/alsa-seq-bridge.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -799,7 +800,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct seq_state *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/alsa/alsa-udev.c b/spa/plugins/alsa/alsa-udev.c index 5d77ebed6..2f5e70d9c 100644 --- a/spa/plugins/alsa/alsa-udev.c +++ b/spa/plugins/alsa/alsa-udev.c @@ -138,7 +138,7 @@ static uint32_t get_card_id(struct impl *this, struct udev_device *dev) if (udev_device_get_property_value(dev, "ACP_IGNORE")) return SPA_ID_INVALID; - if ((str = udev_device_get_property_value(dev, "SOUND_CLASS")) && strcmp(str, "modem") == 0) + if ((str = udev_device_get_property_value(dev, "SOUND_CLASS")) && spa_streq(str, "modem")) return SPA_ID_INVALID; if ((str = udev_device_get_property_value(dev, "SOUND_INITIALIZED")) == NULL) @@ -553,9 +553,9 @@ static void impl_on_fd_events(struct spa_source *source) start_inotify(this); - if (strcmp(action, "change") == 0) { + if (spa_streq(action, "change")) { process_device(this, ACTION_ADD, dev); - } else if (strcmp(action, "remove") == 0) { + } else if (spa_streq(action, "remove")) { process_device(this, ACTION_REMOVE, dev); } udev_device_unref(dev); @@ -705,7 +705,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) *interface = &this->device; else return -ENOENT; @@ -768,7 +768,7 @@ impl_init(const struct spa_handle_factory *factory, if (info) { if ((str = spa_dict_lookup(info, "alsa.use-acp")) != NULL) - this->use_acp = strcmp(str, "true") == 0 || atoi(str) != 0; + this->use_acp = spa_streq(str, "true") || atoi(str) != 0; } return 0; diff --git a/spa/plugins/audioconvert/audioadapter.c b/spa/plugins/audioconvert/audioadapter.c index 8244834c7..2b6dce49f 100644 --- a/spa/plugins/audioconvert/audioadapter.c +++ b/spa/plugins/audioconvert/audioadapter.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1096,7 +1097,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index 046ec98d1..9e4b376fb 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1190,7 +1191,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/audioconvert/channelmix.c b/spa/plugins/audioconvert/channelmix.c index 2f76ac4ef..2c8bd65a8 100644 --- a/spa/plugins/audioconvert/channelmix.c +++ b/spa/plugins/audioconvert/channelmix.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1312,7 +1313,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; @@ -1336,7 +1337,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; @@ -1391,18 +1392,18 @@ impl_init(const struct spa_handle_factory *factory, for (i = 0; info && i < info->n_items; i++) { const char *k = info->items[i].key; const char *s = info->items[i].value; - if (strcmp(k, "channelmix.normalize") == 0 && - (strcmp(s, "true") == 0 || atoi(s) != 0)) + if (spa_streq(k, "channelmix.normalize") && + (spa_streq(s, "true") || atoi(s) != 0)) this->mix.options |= CHANNELMIX_OPTION_NORMALIZE; - if (strcmp(k, "channelmix.mix-lfe") == 0 && - (strcmp(s, "true") == 0 || atoi(s) != 0)) + if (spa_streq(k, "channelmix.mix-lfe") && + (spa_streq(s, "true") || atoi(s) != 0)) this->mix.options |= CHANNELMIX_OPTION_MIX_LFE; - if (strcmp(k, "channelmix.upmix") == 0 && - (strcmp(s, "true") == 0 || atoi(s) != 0)) + if (spa_streq(k, "channelmix.upmix") && + (spa_streq(s, "true") || atoi(s) != 0)) this->mix.options |= CHANNELMIX_OPTION_UPMIX; - if (strcmp(k, "channelmix.lfe-cutoff") == 0) + if (spa_streq(k, "channelmix.lfe-cutoff")) this->mix.lfe_cutoff = atoi(s); - if (strcmp(k, SPA_KEY_AUDIO_POSITION) == 0) + if (spa_streq(k, SPA_KEY_AUDIO_POSITION)) this->props.n_channels = parse_position(this->props.channel_map, s, strlen(s)); } this->props.channel.n_volumes = this->props.n_channels; diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index 85ea2305a..f9518860d 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -952,7 +953,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index c12174f5f..0702f1051 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -1336,7 +1337,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; @@ -1384,7 +1385,7 @@ impl_init(const struct spa_handle_factory *factory, this->monitor_channel_volumes = false; if (info) { if ((str = spa_dict_lookup(info, "monitor.channel-volumes")) != NULL) - this->monitor_channel_volumes = strcmp(str, "true") == 0 || atoi(str) == 1; + this->monitor_channel_volumes = spa_streq(str, "true") || atoi(str) == 1; } this->node.iface = SPA_INTERFACE_INIT( diff --git a/spa/plugins/audioconvert/resample.c b/spa/plugins/audioconvert/resample.c index ca1c7ec17..2e9d475d8 100644 --- a/spa/plugins/audioconvert/resample.c +++ b/spa/plugins/audioconvert/resample.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -947,7 +948,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; @@ -1006,11 +1007,11 @@ impl_init(const struct spa_handle_factory *factory, if ((str = spa_dict_lookup(info, "resample.quality")) != NULL) this->props.quality = atoi(str); if ((str = spa_dict_lookup(info, "resample.peaks")) != NULL) - this->peaks = strcmp(str, "true") == 0 || atoi(str) == 1; + this->peaks = spa_streq(str, "true") || atoi(str) == 1; if ((str = spa_dict_lookup(info, "factory.mode")) != NULL) { - if (strcmp(str, "split") == 0) + if (spa_streq(str, "split")) this->mode = MODE_SPLIT; - else if (strcmp(str, "merge") == 0) + else if (spa_streq(str, "merge")) this->mode = MODE_MERGE; else this->mode = MODE_CONVERT; diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c index e4cd7b547..7ce5c23c3 100644 --- a/spa/plugins/audioconvert/splitter.c +++ b/spa/plugins/audioconvert/splitter.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1017,7 +1018,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/audioconvert/test-audioadapter.c b/spa/plugins/audioconvert/test-audioadapter.c index 00b021a1f..300410b66 100644 --- a/spa/plugins/audioconvert/test-audioadapter.c +++ b/spa/plugins/audioconvert/test-audioadapter.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -56,7 +57,7 @@ static const struct spa_handle_factory *find_factory(const char *name) const struct spa_handle_factory *factory; while (spa_handle_factory_enum(&factory, &index) == 1) { - if (strcmp(factory->name, name) == 0) + if (spa_streq(factory->name, name)) return factory; } return NULL; diff --git a/spa/plugins/audioconvert/test-audioconvert.c b/spa/plugins/audioconvert/test-audioconvert.c index 02be12e5f..b99923f50 100644 --- a/spa/plugins/audioconvert/test-audioconvert.c +++ b/spa/plugins/audioconvert/test-audioconvert.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -59,7 +60,7 @@ static const struct spa_handle_factory *find_factory(const char *name) const struct spa_handle_factory *factory; while (spa_handle_factory_enum(&factory, &index) == 1) { - if (strcmp(factory->name, name) == 0) + if (spa_streq(factory->name, name)) return factory; } return NULL; diff --git a/spa/plugins/audioconvert/test-source.c b/spa/plugins/audioconvert/test-source.c index d00593b2e..4194dbe8b 100644 --- a/spa/plugins/audioconvert/test-source.c +++ b/spa/plugins/audioconvert/test-source.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -799,7 +800,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c index 1c9f2f677..4c058934b 100644 --- a/spa/plugins/audiomixer/audiomixer.c +++ b/spa/plugins/audiomixer/audiomixer.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -835,7 +836,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/audiomixer/mixer-dsp.c b/spa/plugins/audiomixer/mixer-dsp.c index d36fc852c..5fdbc9388 100644 --- a/spa/plugins/audiomixer/mixer-dsp.c +++ b/spa/plugins/audiomixer/mixer-dsp.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -770,7 +771,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index e347724cc..dace30675 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -973,7 +974,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/bluez5/a2dp-codec-sbc.c b/spa/plugins/bluez5/a2dp-codec-sbc.c index cf4e51104..875adba04 100644 --- a/spa/plugins/bluez5/a2dp-codec-sbc.c +++ b/spa/plugins/bluez5/a2dp-codec-sbc.c @@ -28,6 +28,7 @@ #include #include +#include #include @@ -164,7 +165,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, if (caps_size < sizeof(conf)) return -EINVAL; - xq = (strcmp(codec->name, "sbc_xq") == 0); + xq = (spa_streq(codec->name, "sbc_xq")); memcpy(&conf, caps, sizeof(conf)); @@ -235,7 +236,7 @@ static int codec_caps_preference_cmp(const struct a2dp_codec *codec, const void a2dp_sbc_t *conf; int res1, res2; int a, b; - bool xq = (strcmp(codec->name, "sbc_xq") == 0); + bool xq = (spa_streq(codec->name, "sbc_xq")); /* Order selected configurations by preference */ res1 = codec->select_config(codec, 0, caps1, caps1_size, info, NULL, (uint8_t *)&conf1); diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c index 7817c23ca..37550e1a8 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/a2dp-sink.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -1324,7 +1325,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/bluez5/a2dp-source.c b/spa/plugins/bluez5/a2dp-source.c index 30107c76c..6a243d702 100644 --- a/spa/plugins/bluez5/a2dp-source.c +++ b/spa/plugins/bluez5/a2dp-source.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -1236,7 +1237,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; @@ -1341,7 +1342,7 @@ impl_init(const struct spa_handle_factory *factory, if ((str = spa_dict_lookup(info, SPA_KEY_API_BLUEZ5_TRANSPORT)) != NULL) sscanf(str, "pointer:%p", &this->transport); if ((str = spa_dict_lookup(info, "bluez5.a2dp-source-role")) != NULL) - this->is_input = strcmp(str, "input") == 0; + this->is_input = spa_streq(str, "input"); } if (this->transport == NULL) { diff --git a/spa/plugins/bluez5/backend-hsphfpd.c b/spa/plugins/bluez5/backend-hsphfpd.c index 591bff41f..17b701bb9 100644 --- a/spa/plugins/bluez5/backend-hsphfpd.c +++ b/spa/plugins/bluez5/backend-hsphfpd.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -175,7 +176,7 @@ static struct hsphfpd_endpoint *endpoint_find(struct impl *backend, const char * { struct hsphfpd_endpoint *d; spa_list_for_each(d, &backend->endpoint_list, link) - if (strcmp(d->path, path) == 0) + if (spa_streq(d->path, path)) return d; return NULL; } @@ -193,7 +194,7 @@ static void endpoint_free(struct hsphfpd_endpoint *endpoint) static bool hsphfpd_cmp_transport_path(struct spa_bt_transport *t, const void *data) { struct hsphfpd_transport_data *td = t->user_data; - if (strcmp(td->transport_path, data) == 0) + if (spa_streq(td->transport_path, data)) return true; return false; @@ -201,7 +202,7 @@ static bool hsphfpd_cmp_transport_path(struct spa_bt_transport *t, const void *d static inline bool check_signature(DBusMessage *m, const char sig[]) { - return strcmp(dbus_message_get_signature(m), sig) == 0; + return spa_streq(dbus_message_get_signature(m), sig); } static int set_dbus_property(struct impl *backend, @@ -316,41 +317,41 @@ static void parse_transport_properties_values(struct impl *backend, switch (dbus_message_iter_get_arg_type(&variant_i)) { case DBUS_TYPE_STRING: - if (strcmp(key, "RxVolumeControl") == 0 || strcmp(key, "TxVolumeControl") == 0) { + if (spa_streq(key, "RxVolumeControl") || spa_streq(key, "TxVolumeControl")) { const char *value; enum hsphfpd_volume_control volume_control; dbus_message_iter_get_basic(&variant_i, &value); - if (strcmp(value, "none") == 0) + if (spa_streq(value, "none")) volume_control = HSPHFPD_VOLUME_CONTROL_NONE; - else if (strcmp(value, "local") == 0) + else if (spa_streq(value, "local")) volume_control = HSPHFPD_VOLUME_CONTROL_LOCAL; - else if (strcmp(value, "remote") == 0) + else if (spa_streq(value, "remote")) volume_control = HSPHFPD_VOLUME_CONTROL_REMOTE; else volume_control = 0; if (!volume_control) spa_log_warn(backend->log, NAME": Transport %s received invalid '%s' property value '%s', ignoring", transport_path, key, value); - else if (strcmp(key, "RxVolumeControl") == 0) + else if (spa_streq(key, "RxVolumeControl")) *rx_volume_control = volume_control; - else if (strcmp(key, "TxVolumeControl") == 0) + else if (spa_streq(key, "TxVolumeControl")) *tx_volume_control = volume_control; - } else if (strcmp(key, "AirCodec") == 0) + } else if (spa_streq(key, "AirCodec")) dbus_message_iter_get_basic(&variant_i, air_codec); break; case DBUS_TYPE_UINT16: - if (strcmp(key, "MTU") == 0) + if (spa_streq(key, "MTU")) dbus_message_iter_get_basic(&variant_i, mtu); - else if (strcmp(key, "RxVolumeGain") == 0) + else if (spa_streq(key, "RxVolumeGain")) dbus_message_iter_get_basic(&variant_i, rx_volume_gain); - else if (strcmp(key, "TxVolumeGain") == 0) + else if (spa_streq(key, "TxVolumeGain")) dbus_message_iter_get_basic(&variant_i, tx_volume_gain); break; case DBUS_TYPE_OBJECT_PATH: - if (strcmp(key, "Endpoint") == 0) + if (spa_streq(key, "Endpoint")) dbus_message_iter_get_basic(&variant_i, endpoint_path); break; } @@ -484,9 +485,9 @@ static DBusHandlerResult audio_agent_get_property(DBusConnection *conn, DBusMess goto fail; } - if (strcmp(path, HSPHFP_AUDIO_CLIENT_PCM_S16LE_8KHZ) == 0) + if (spa_streq(path, HSPHFP_AUDIO_CLIENT_PCM_S16LE_8KHZ)) agent_codec = HSPHFP_AGENT_CODEC_PCM; - else if (strcmp(path, HSPHFP_AUDIO_CLIENT_MSBC) == 0) + else if (spa_streq(path, HSPHFP_AUDIO_CLIENT_MSBC)) agent_codec = HSPHFP_AGENT_CODEC_MSBC; else { r = dbus_message_new_error(m, DBUS_ERROR_INVALID_ARGS, "Invalid path in method call"); @@ -526,9 +527,9 @@ static DBusHandlerResult audio_agent_getall_properties(DBusConnection *conn, DBu goto fail; } - if (strcmp(path, HSPHFP_AUDIO_CLIENT_PCM_S16LE_8KHZ) == 0) + if (spa_streq(path, HSPHFP_AUDIO_CLIENT_PCM_S16LE_8KHZ)) agent_codec = HSPHFP_AGENT_CODEC_PCM; - else if (strcmp(path, HSPHFP_AUDIO_CLIENT_MSBC) == 0) + else if (spa_streq(path, HSPHFP_AUDIO_CLIENT_MSBC)) agent_codec = HSPHFP_AGENT_CODEC_MSBC; else { r = dbus_message_new_error(m, DBUS_ERROR_INVALID_ARGS, "Invalid path in method call"); @@ -599,9 +600,9 @@ static DBusHandlerResult hsphfpd_new_audio_connection(DBusConnection *conn, DBus goto fail; } - if (strcmp(path, HSPHFP_AUDIO_CLIENT_PCM_S16LE_8KHZ) == 0) + if (spa_streq(path, HSPHFP_AUDIO_CLIENT_PCM_S16LE_8KHZ)) codec = HFP_AUDIO_CODEC_CVSD; - else if (strcmp(path, HSPHFP_AUDIO_CLIENT_MSBC) == 0) + else if (spa_streq(path, HSPHFP_AUDIO_CLIENT_MSBC)) codec = HFP_AUDIO_CODEC_MSBC; else { r = dbus_message_new_error(m, HSPHFPD_ERROR_REJECTED, "Invalid path"); @@ -1013,25 +1014,25 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct impl *backend, { const char *value; dbus_message_iter_get_basic(&value_i, &value); - if (strcmp(key, "RemoteAddress") == 0) + if (spa_streq(key, "RemoteAddress")) endpoint->remote_address = strdup(value); - else if (strcmp(key, "LocalAddress") == 0) + else if (spa_streq(key, "LocalAddress")) endpoint->local_address = strdup(value); - else if (strcmp(key, "Profile") == 0) { + else if (spa_streq(key, "Profile")) { if (endpoint->profile) spa_log_warn(backend->log, NAME": Endpoint %s received a duplicate '%s' property, ignoring", endpoint->path, key); - else if (strcmp(value, "headset") == 0) + else if (spa_streq(value, "headset")) endpoint->profile = HSPHFPD_PROFILE_HEADSET; - else if (strcmp(value, "handsfree") == 0) + else if (spa_streq(value, "handsfree")) endpoint->profile = HSPHFPD_PROFILE_HANDSFREE; else spa_log_warn(backend->log, NAME": Endpoint %s received invalid '%s' property value '%s', ignoring", endpoint->path, key, value); - } else if (strcmp(key, "Role") == 0) { + } else if (spa_streq(key, "Role")) { if (endpoint->role) spa_log_warn(backend->log, NAME": Endpoint %s received a duplicate '%s' property, ignoring", endpoint->path, key); - else if (strcmp(value, "client") == 0) + else if (spa_streq(value, "client")) endpoint->role = HSPHFPD_ROLE_CLIENT; - else if (strcmp(value, "gateway") == 0) + else if (spa_streq(value, "gateway")) endpoint->role = HSPHFPD_ROLE_GATEWAY; else spa_log_warn(backend->log, NAME": Endpoint %s received invalid '%s' property value '%s', ignoring", endpoint->path, key, value); @@ -1044,7 +1045,7 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct impl *backend, { bool value; dbus_message_iter_get_basic(&value_i, &value); - if (strcmp(key, "Connected") == 0) + if (spa_streq(key, "Connected")) endpoint->connected = value; spa_log_trace(backend->log, NAME": %s: %d", key, value); } @@ -1052,7 +1053,7 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct impl *backend, case DBUS_TYPE_ARRAY: { - if (strcmp(key, "AudioCodecs") == 0) { + if (spa_streq(key, "AudioCodecs")) { DBusMessageIter array_i; const char *value; @@ -1060,9 +1061,9 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct impl *backend, dbus_message_iter_recurse(&value_i, &array_i); while (dbus_message_iter_get_arg_type(&array_i) != DBUS_TYPE_INVALID) { dbus_message_iter_get_basic(&array_i, &value); - if (strcmp(value, HSPHFP_AIR_CODEC_CVSD) == 0) + if (spa_streq(value, HSPHFP_AIR_CODEC_CVSD)) endpoint->air_codecs |= HFP_AUDIO_CODEC_CVSD; - if (strcmp(value, HSPHFP_AIR_CODEC_MSBC) == 0) + if (spa_streq(value, HSPHFP_AIR_CODEC_MSBC)) endpoint->air_codecs |= HFP_AUDIO_CODEC_MSBC; dbus_message_iter_next(&array_i); } @@ -1163,7 +1164,7 @@ static DBusHandlerResult hsphfpd_parse_interfaces(struct impl *backend, DBusMess dbus_message_iter_get_basic(&iface_i, &interface); dbus_message_iter_next(&iface_i); - if (strcmp(interface, HSPHFPD_ENDPOINT_INTERFACE) == 0) { + if (spa_streq(interface, HSPHFPD_ENDPOINT_INTERFACE)) { struct hsphfpd_endpoint *endpoint; endpoint = endpoint_find(backend, path); @@ -1315,7 +1316,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m, sender = dbus_message_get_sender(m); - if (backend->hsphfpd_service_id && strcmp(sender, backend->hsphfpd_service_id) == 0) { + if (backend->hsphfpd_service_id && spa_streq(sender, backend->hsphfpd_service_id)) { if (dbus_message_is_signal(m, DBUS_INTERFACE_OBJECTMANAGER, "InterfacesAdded")) { DBusMessageIter arg_i; @@ -1351,7 +1352,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m, dbus_message_iter_get_basic(&element_i, &iface); - if (strcmp(iface, HSPHFPD_ENDPOINT_INTERFACE) == 0) { + if (spa_streq(iface, HSPHFPD_ENDPOINT_INTERFACE)) { struct hsphfpd_endpoint *endpoint; struct spa_bt_transport *transport = spa_bt_transport_find(backend->monitor, path); @@ -1384,7 +1385,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m, path = dbus_message_get_path(m); - if (strcmp(iface, HSPHFPD_ENDPOINT_INTERFACE) == 0) { + if (spa_streq(iface, HSPHFPD_ENDPOINT_INTERFACE)) { struct hsphfpd_endpoint *endpoint = endpoint_find(backend, path); if (!endpoint) { spa_log_warn(backend->log, NAME": Properties changed on unknown endpoint %s", path); @@ -1392,7 +1393,7 @@ static DBusHandlerResult hsphfpd_filter_cb(DBusConnection *bus, DBusMessage *m, } spa_log_debug(backend->log, NAME": Properties changed on endpoint %s", path); hsphfpd_parse_endpoint_properties(backend, endpoint, &arg_i); - } else if (strcmp(iface, HSPHFPD_AUDIO_TRANSPORT_INTERFACE) == 0) { + } else if (spa_streq(iface, HSPHFPD_AUDIO_TRANSPORT_INTERFACE)) { struct spa_bt_transport *transport = spa_bt_transport_find_full(backend->monitor, hsphfpd_cmp_transport_path, (const void *)path); @@ -1507,7 +1508,7 @@ struct spa_bt_backend *backend_hsphfpd_new(struct spa_bt_monitor *monitor, backend->main_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Loop); backend->conn = dbus_connection; if (info && (str = spa_dict_lookup(info, "bluez5.msbc-support"))) - backend->msbc_supported = strcmp(str, "true") == 0 || atoi(str) == 1; + backend->msbc_supported = spa_streq(str, "true") || atoi(str) == 1; else backend->msbc_supported = false; diff --git a/spa/plugins/bluez5/backend-native.c b/spa/plugins/bluez5/backend-native.c index d5c3ba3dc..c2a1a8c62 100644 --- a/spa/plugins/bluez5/backend-native.c +++ b/spa/plugins/bluez5/backend-native.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -1056,8 +1057,8 @@ static void sco_listen_event(struct spa_source *source) /* Find transport for local and remote address */ spa_list_for_each_safe(rfcomm, rfcomm_tmp, &backend->rfcomm_list, link) { - if (rfcomm->transport && strcmp(rfcomm->transport->device->address, remote_address) == 0 && - strcmp(rfcomm->transport->device->adapter->address, local_address) == 0) { + if (rfcomm->transport && spa_streq(rfcomm->transport->device->address, remote_address) && + spa_streq(rfcomm->transport->device->adapter->address, local_address)) { t = rfcomm->transport; break; } @@ -1421,15 +1422,15 @@ static DBusHandlerResult profile_new_connection(DBusConnection *conn, DBusMessag handler = dbus_message_get_path(m); #ifdef HAVE_BLUEZ_5_BACKEND_HSP_NATIVE - if (strcmp(handler, PROFILE_HSP_AG) == 0) + if (spa_streq(handler, PROFILE_HSP_AG)) profile = SPA_BT_PROFILE_HSP_HS; - else if (strcmp(handler, PROFILE_HSP_HS) == 0) + else if (spa_streq(handler, PROFILE_HSP_HS)) profile = SPA_BT_PROFILE_HSP_AG; #endif #ifdef HAVE_BLUEZ_5_BACKEND_HFP_NATIVE - if (strcmp(handler, PROFILE_HFP_AG) == 0) + if (spa_streq(handler, PROFILE_HFP_AG)) profile = SPA_BT_PROFILE_HFP_HF; - else if (strcmp(handler, PROFILE_HFP_HF) == 0) + else if (spa_streq(handler, PROFILE_HFP_HF)) profile = SPA_BT_PROFILE_HFP_AG; #endif @@ -1477,7 +1478,7 @@ static DBusHandlerResult profile_new_connection(DBusConnection *conn, DBusMessag spa_list_append(&backend->rfcomm_list, &rfcomm->link); if (d->settings && (str = spa_dict_lookup(d->settings, "bluez5.msbc-support"))) - rfcomm->msbc_support_enabled_in_config = strcmp(str, "true") == 0 || atoi(str) == 1; + rfcomm->msbc_support_enabled_in_config = spa_streq(str, "true") || atoi(str) == 1; else rfcomm->msbc_support_enabled_in_config = false; @@ -1560,15 +1561,15 @@ static DBusHandlerResult profile_request_disconnection(DBusConnection *conn, DBu handler = dbus_message_get_path(m); #ifdef HAVE_BLUEZ_5_BACKEND_HSP_NATIVE - if (strcmp(handler, PROFILE_HSP_AG) == 0) + if (spa_streq(handler, PROFILE_HSP_AG)) profile = SPA_BT_PROFILE_HSP_HS; - else if (strcmp(handler, PROFILE_HSP_HS) == 0) + else if (spa_streq(handler, PROFILE_HSP_HS)) profile = SPA_BT_PROFILE_HSP_AG; #endif #ifdef HAVE_BLUEZ_5_BACKEND_HFP_NATIVE - if (strcmp(handler, PROFILE_HFP_AG) == 0) + if (spa_streq(handler, PROFILE_HFP_AG)) profile = SPA_BT_PROFILE_HFP_HF; - else if (strcmp(handler, PROFILE_HFP_HF) == 0) + else if (spa_streq(handler, PROFILE_HFP_HF)) profile = SPA_BT_PROFILE_HFP_AG; #endif @@ -1692,8 +1693,8 @@ static int register_profile(struct impl *backend, const char *profile, const cha dbus_message_iter_append_basic(&it[0], DBUS_TYPE_STRING, &uuid); dbus_message_iter_open_container(&it[0], DBUS_TYPE_ARRAY, "{sv}", &it[1]); - if (strcmp(uuid, SPA_BT_UUID_HSP_HS) == 0 || - strcmp(uuid, SPA_BT_UUID_HSP_HS_ALT) == 0) { + if (spa_streq(uuid, SPA_BT_UUID_HSP_HS) || + spa_streq(uuid, SPA_BT_UUID_HSP_HS_ALT)) { /* In the headset role, the connection will only be initiated from the remote side */ str = "AutoConnect"; @@ -1723,7 +1724,7 @@ static int register_profile(struct impl *backend, const char *profile, const cha dbus_message_iter_append_basic(&it[3], DBUS_TYPE_UINT16, &version); dbus_message_iter_close_container(&it[2], &it[3]); dbus_message_iter_close_container(&it[1], &it[2]); - } else if (strcmp(uuid, SPA_BT_UUID_HFP_AG) == 0) { + } else if (spa_streq(uuid, SPA_BT_UUID_HFP_AG)) { str = "Features"; /* We announce wideband speech support anyway */ @@ -1744,7 +1745,7 @@ static int register_profile(struct impl *backend, const char *profile, const cha dbus_message_iter_append_basic(&it[3], DBUS_TYPE_UINT16, &version); dbus_message_iter_close_container(&it[2], &it[3]); dbus_message_iter_close_container(&it[1], &it[2]); - } else if (strcmp(uuid, SPA_BT_UUID_HFP_HF) == 0) { + } else if (spa_streq(uuid, SPA_BT_UUID_HFP_HF)) { str = "Features"; /* We announce wideband speech support anyway */ diff --git a/spa/plugins/bluez5/backend-ofono.c b/spa/plugins/bluez5/backend-ofono.c index 4ff40b735..2d2bce1a3 100644 --- a/spa/plugins/bluez5/backend-ofono.c +++ b/spa/plugins/bluez5/backend-ofono.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -321,12 +322,12 @@ static DBusHandlerResult ofono_audio_card_found(struct impl *backend, char *path dbus_message_iter_get_basic(&value_i, &value); - if (strcmp(key, "RemoteAddress") == 0) { + if (spa_streq(key, "RemoteAddress")) { remote_address = value; - } else if (strcmp(key, "LocalAddress") == 0) { + } else if (spa_streq(key, "LocalAddress")) { local_address = value; - } else if (strcmp(key, "Type") == 0) { - if (strcmp(value, "gateway") == 0) + } else if (spa_streq(key, "Type")) { + if (spa_streq(value, "gateway")) profile = SPA_BT_PROFILE_HFP_HF; } @@ -788,7 +789,7 @@ struct spa_bt_backend *backend_ofono_new(struct spa_bt_monitor *monitor, backend->main_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Loop); backend->conn = dbus_connection; if (info && (str = spa_dict_lookup(info, "bluez5.msbc-support"))) - backend->msbc_supported = strcmp(str, "true") == 0 || atoi(str) == 1; + backend->msbc_supported = spa_streq(str, "true") || atoi(str) == 1; else backend->msbc_supported = false; diff --git a/spa/plugins/bluez5/bluez5-dbus.c b/spa/plugins/bluez5/bluez5-dbus.c index 901c8734c..9d654c272 100644 --- a/spa/plugins/bluez5/bluez5-dbus.c +++ b/spa/plugins/bluez5/bluez5-dbus.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include "a2dp-codecs.h" @@ -413,7 +414,7 @@ static const struct a2dp_codec *a2dp_endpoint_to_codec(const char *endpoint) for (i = 0; a2dp_codecs[i]; i++) { const struct a2dp_codec *codec = a2dp_codecs[i]; - if (strcmp(codec->name, codec_name) == 0) + if (spa_streq(codec->name, codec_name)) return codec; } return NULL; @@ -433,7 +434,7 @@ static int a2dp_endpoint_to_profile(const char *endpoint) static bool is_a2dp_codec_enabled(struct spa_bt_monitor *monitor, const struct a2dp_codec *codec) { if (!monitor->enable_sbc_xq && codec->feature_flag != NULL && - strcmp(codec->feature_flag, "sbc-xq") == 0) + spa_streq(codec->feature_flag, "sbc-xq")) return false; return spa_dict_lookup(&monitor->enabled_codecs, codec->name) != NULL; @@ -505,7 +506,7 @@ static struct spa_bt_adapter *adapter_find(struct spa_bt_monitor *monitor, const { struct spa_bt_adapter *d; spa_list_for_each(d, &monitor->adapter_list, link) - if (strcmp(d->path, path) == 0) + if (spa_streq(d->path, path)) return d; return NULL; } @@ -545,15 +546,15 @@ static int adapter_update_props(struct spa_bt_adapter *adapter, spa_log_debug(monitor->log, "adapter %p: %s=%s", adapter, key, value); - if (strcmp(key, "Alias") == 0) { + if (spa_streq(key, "Alias")) { free(adapter->alias); adapter->alias = strdup(value); } - else if (strcmp(key, "Name") == 0) { + else if (spa_streq(key, "Name")) { free(adapter->name); adapter->name = strdup(value); } - else if (strcmp(key, "Address") == 0) { + else if (spa_streq(key, "Address")) { free(adapter->address); adapter->address = strdup(value); } @@ -565,7 +566,7 @@ static int adapter_update_props(struct spa_bt_adapter *adapter, spa_log_debug(monitor->log, "adapter %p: %s=%d", adapter, key, value); - if (strcmp(key, "Class") == 0) + if (spa_streq(key, "Class")) adapter->bluetooth_class = value; } @@ -576,11 +577,11 @@ static int adapter_update_props(struct spa_bt_adapter *adapter, spa_log_debug(monitor->log, "adapter %p: %s=%d", adapter, key, value); - if (strcmp(key, "Powered") == 0) { + if (spa_streq(key, "Powered")) { adapter->powered = value; } } - else if (strcmp(key, "UUIDs") == 0) { + else if (spa_streq(key, "UUIDs")) { DBusMessageIter iter; if (!check_iter_signature(&it[1], "as")) @@ -645,7 +646,7 @@ struct spa_bt_device *spa_bt_device_find(struct spa_bt_monitor *monitor, const c { struct spa_bt_device *d; spa_list_for_each(d, &monitor->device_list, link) - if (strcmp(d->path, path) == 0) + if (spa_streq(d->path, path)) return d; return NULL; } @@ -654,7 +655,7 @@ struct spa_bt_device *spa_bt_device_find_by_address(struct spa_bt_monitor *monit { struct spa_bt_device *d; spa_list_for_each(d, &monitor->device_list, link) - if (strcmp(d->address, remote_address) == 0 && strcmp(d->adapter->address, local_address) == 0) + if (spa_streq(d->address, remote_address) && spa_streq(d->adapter->address, local_address)) return d; return NULL; } @@ -1107,19 +1108,19 @@ static int device_update_props(struct spa_bt_device *device, spa_log_debug(monitor->log, "device %p: %s=%s", device, key, value); - if (strcmp(key, "Alias") == 0) { + if (spa_streq(key, "Alias")) { free(device->alias); device->alias = strdup(value); } - else if (strcmp(key, "Name") == 0) { + else if (spa_streq(key, "Name")) { free(device->name); device->name = strdup(value); } - else if (strcmp(key, "Address") == 0) { + else if (spa_streq(key, "Address")) { free(device->address); device->address = strdup(value); } - else if (strcmp(key, "Adapter") == 0) { + else if (spa_streq(key, "Adapter")) { free(device->adapter_path); device->adapter_path = strdup(value); @@ -1128,7 +1129,7 @@ static int device_update_props(struct spa_bt_device *device, spa_log_warn(monitor->log, "unknown adapter %s", value); } } - else if (strcmp(key, "Icon") == 0) { + else if (spa_streq(key, "Icon")) { free(device->icon); device->icon = strdup(value); } @@ -1140,7 +1141,7 @@ static int device_update_props(struct spa_bt_device *device, spa_log_debug(monitor->log, "device %p: %s=%08x", device, key, value); - if (strcmp(key, "Class") == 0) + if (spa_streq(key, "Class")) device->bluetooth_class = value; } else if (type == DBUS_TYPE_UINT16) { @@ -1150,7 +1151,7 @@ static int device_update_props(struct spa_bt_device *device, spa_log_debug(monitor->log, "device %p: %s=%d", device, key, value); - if (strcmp(key, "Appearance") == 0) + if (spa_streq(key, "Appearance")) device->appearance = value; } else if (type == DBUS_TYPE_INT16) { @@ -1160,7 +1161,7 @@ static int device_update_props(struct spa_bt_device *device, spa_log_debug(monitor->log, "device %p: %s=%d", device, key, value); - if (strcmp(key, "RSSI") == 0) + if (spa_streq(key, "RSSI")) device->RSSI = value; } else if (type == DBUS_TYPE_BOOLEAN) { @@ -1170,24 +1171,24 @@ static int device_update_props(struct spa_bt_device *device, spa_log_debug(monitor->log, "device %p: %s=%d", device, key, value); - if (strcmp(key, "Paired") == 0) { + if (spa_streq(key, "Paired")) { device->paired = value; } - else if (strcmp(key, "Trusted") == 0) { + else if (spa_streq(key, "Trusted")) { device->trusted = value; } - else if (strcmp(key, "Connected") == 0) { + else if (spa_streq(key, "Connected")) { device_set_connected(device, value); } - else if (strcmp(key, "Blocked") == 0) { + else if (spa_streq(key, "Blocked")) { device->blocked = value; } - else if (strcmp(key, "ServicesResolved") == 0) { + else if (spa_streq(key, "ServicesResolved")) { if (value) spa_bt_device_check_profiles(device, false); } } - else if (strcmp(key, "UUIDs") == 0) { + else if (spa_streq(key, "UUIDs")) { DBusMessageIter iter; uint32_t prev_profiles = device->profiles; @@ -1232,7 +1233,7 @@ bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struc if (!device->adapter->application_registered) { /* Codec switching not supported: only plain SBC allowed */ - return (codec->codec_id == A2DP_CODEC_SBC && strcmp(codec->name, "sbc") == 0); + return (codec->codec_id == A2DP_CODEC_SBC && spa_streq(codec->name, "sbc")); } spa_list_for_each(ep, &device->remote_endpoint_list, device_link) { @@ -1285,7 +1286,7 @@ static struct spa_bt_remote_endpoint *device_remote_endpoint_find(struct spa_bt_ { struct spa_bt_remote_endpoint *ep; spa_list_for_each(ep, &device->remote_endpoint_list, device_link) - if (strcmp(ep->path, path) == 0) + if (spa_streq(ep->path, path)) return ep; return NULL; } @@ -1294,7 +1295,7 @@ static struct spa_bt_remote_endpoint *remote_endpoint_find(struct spa_bt_monitor { struct spa_bt_remote_endpoint *ep; spa_list_for_each(ep, &monitor->remote_endpoint_list, link) - if (strcmp(ep->path, path) == 0) + if (spa_streq(ep->path, path)) return ep; return NULL; } @@ -1324,11 +1325,11 @@ static int remote_endpoint_update_props(struct spa_bt_remote_endpoint *remote_en spa_log_debug(monitor->log, "remote_endpoint %p: %s=%s", remote_endpoint, key, value); - if (strcmp(key, "UUID") == 0) { + if (spa_streq(key, "UUID")) { free(remote_endpoint->uuid); remote_endpoint->uuid = strdup(value); } - else if (strcmp(key, "Device") == 0) { + else if (spa_streq(key, "Device")) { struct spa_bt_device *device; device = spa_bt_device_find(monitor, value); if (device == NULL) @@ -1351,7 +1352,7 @@ static int remote_endpoint_update_props(struct spa_bt_remote_endpoint *remote_en spa_log_debug(monitor->log, "remote_endpoint %p: %s=%d", remote_endpoint, key, value); - if (strcmp(key, "DelayReporting") == 0) { + if (spa_streq(key, "DelayReporting")) { remote_endpoint->delay_reporting = value; } } @@ -1362,11 +1363,11 @@ static int remote_endpoint_update_props(struct spa_bt_remote_endpoint *remote_en spa_log_debug(monitor->log, "remote_endpoint %p: %s=%02x", remote_endpoint, key, value); - if (strcmp(key, "Codec") == 0) { + if (spa_streq(key, "Codec")) { remote_endpoint->codec = value; } } - else if (strcmp(key, "Capabilities") == 0) { + else if (spa_streq(key, "Capabilities")) { DBusMessageIter iter; uint8_t *value; int i, len; @@ -1436,7 +1437,7 @@ struct spa_bt_transport *spa_bt_transport_find(struct spa_bt_monitor *monitor, c { struct spa_bt_transport *t; spa_list_for_each(t, &monitor->transport_list, link) - if (strcmp(t->path, path) == 0) + if (spa_streq(t->path, path)) return t; return NULL; } @@ -1816,7 +1817,7 @@ static int transport_update_props(struct spa_bt_transport *transport, spa_log_debug(monitor->log, "transport %p: %s=%s", transport, key, value); - if (strcmp(key, "UUID") == 0) { + if (spa_streq(key, "UUID")) { switch (spa_bt_profile_from_uuid(value)) { case SPA_BT_PROFILE_A2DP_SOURCE: transport->profile = SPA_BT_PROFILE_A2DP_SINK; @@ -1829,16 +1830,16 @@ static int transport_update_props(struct spa_bt_transport *transport, break; } } - else if (strcmp(key, "State") == 0) { + else if (spa_streq(key, "State")) { spa_bt_transport_set_state(transport, spa_bt_transport_state_from_string(value)); } - else if (strcmp(key, "Device") == 0) { + else if (spa_streq(key, "Device")) { transport->device = spa_bt_device_find(monitor, value); if (transport->device == NULL) spa_log_warn(monitor->log, "could not find device %s", value); } } - else if (strcmp(key, "Codec") == 0) { + else if (spa_streq(key, "Codec")) { uint8_t value; if (type != DBUS_TYPE_BYTE) @@ -1849,7 +1850,7 @@ static int transport_update_props(struct spa_bt_transport *transport, transport->codec = value; } - else if (strcmp(key, "Configuration") == 0) { + else if (spa_streq(key, "Configuration")) { DBusMessageIter iter; uint8_t *value; int i, len; @@ -1873,7 +1874,7 @@ static int transport_update_props(struct spa_bt_transport *transport, transport->configuration_len = len; } } - else if (strcmp(key, "Volume") == 0) { + else if (spa_streq(key, "Volume")) { uint16_t value; struct spa_bt_transport_volume * t_volume; @@ -1898,7 +1899,7 @@ static int transport_update_props(struct spa_bt_transport *transport, else spa_bt_transport_volume_changed(transport); } - else if (strcmp(key, "Delay") == 0) { + else if (spa_streq(key, "Delay")) { uint16_t value; if (type != DBUS_TYPE_UINT16) @@ -2011,7 +2012,7 @@ static int transport_acquire(void *data, bool optional) m = NULL; if (r == NULL) { - if (optional && strcmp(err.name, "org.bluez.Error.NotAvailable") == 0) { + if (optional && spa_streq(err.name, "org.bluez.Error.NotAvailable")) { spa_log_info(monitor->log, "Failed optional acquire of unavailable transport %s", transport->path); } @@ -2851,7 +2852,7 @@ static int adapter_register_endpoints(struct spa_bt_adapter *a) if (!is_a2dp_codec_enabled(monitor, codec)) continue; - if (!(codec->codec_id == A2DP_CODEC_SBC && strcmp(codec->name, "sbc") == 0)) + if (!(codec->codec_id == A2DP_CODEC_SBC && spa_streq(codec->name, "sbc"))) continue; if ((err = bluez_register_endpoint(monitor, a->path, @@ -3125,7 +3126,7 @@ static void interface_added(struct spa_bt_monitor *monitor, { spa_log_debug(monitor->log, "Found object %s, interface %s", object_path, interface_name); - if (strcmp(interface_name, BLUEZ_ADAPTER_INTERFACE) == 0) { + if (spa_streq(interface_name, BLUEZ_ADAPTER_INTERFACE)) { struct spa_bt_adapter *a; a = adapter_find(monitor, object_path); @@ -3139,13 +3140,13 @@ static void interface_added(struct spa_bt_monitor *monitor, adapter_update_props(a, props_iter, NULL); adapter_register_application(a); } - else if (strcmp(interface_name, BLUEZ_PROFILE_MANAGER_INTERFACE) == 0) { + else if (spa_streq(interface_name, BLUEZ_PROFILE_MANAGER_INTERFACE)) { if (!monitor->backend_ofono_registered && !monitor->backend_hsphfpd_registered) { spa_bt_backend_register_profiles(monitor->backend_native); monitor->backend_native_registered = true; } } - else if (strcmp(interface_name, BLUEZ_DEVICE_INTERFACE) == 0) { + else if (spa_streq(interface_name, BLUEZ_DEVICE_INTERFACE)) { struct spa_bt_device *d; d = spa_bt_device_find(monitor, object_path); @@ -3171,7 +3172,7 @@ static void interface_added(struct spa_bt_monitor *monitor, d->reconnect_state = BT_DEVICE_RECONNECT_INIT; device_start_timer(d); } - else if (strcmp(interface_name, BLUEZ_MEDIA_ENDPOINT_INTERFACE) == 0) { + else if (spa_streq(interface_name, BLUEZ_MEDIA_ENDPOINT_INTERFACE)) { struct spa_bt_remote_endpoint *ep; struct spa_bt_device *d; @@ -3233,17 +3234,17 @@ static void interfaces_removed(struct spa_bt_monitor *monitor, DBusMessageIter * spa_log_debug(monitor->log, "Found object %s, interface %s", object_path, interface_name); - if (strcmp(interface_name, BLUEZ_DEVICE_INTERFACE) == 0) { + if (spa_streq(interface_name, BLUEZ_DEVICE_INTERFACE)) { struct spa_bt_device *d; d = spa_bt_device_find(monitor, object_path); if (d != NULL) device_free(d); - } else if (strcmp(interface_name, BLUEZ_ADAPTER_INTERFACE) == 0) { + } else if (spa_streq(interface_name, BLUEZ_ADAPTER_INTERFACE)) { struct spa_bt_adapter *a; a = adapter_find(monitor, object_path); if (a != NULL) adapter_free(a); - } else if (strcmp(interface_name, BLUEZ_MEDIA_ENDPOINT_INTERFACE) == 0) { + } else if (spa_streq(interface_name, BLUEZ_MEDIA_ENDPOINT_INTERFACE)) { struct spa_bt_remote_endpoint *ep; ep = remote_endpoint_find(monitor, object_path); if (ep != NULL) { @@ -3339,7 +3340,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us goto fail; } - if (strcmp(name, BLUEZ_SERVICE) == 0) { + if (spa_streq(name, BLUEZ_SERVICE)) { bool has_old_owner = old_owner && *old_owner; bool has_new_owner = new_owner && *new_owner; @@ -3374,7 +3375,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us spa_log_debug(monitor->log, "Bluetooth daemon appeared"); get_managed_objects(monitor); } - } else if (strcmp(name, OFONO_SERVICE) == 0 && monitor->backend_ofono) { + } else if (spa_streq(name, OFONO_SERVICE) && monitor->backend_ofono) { if (old_owner && *old_owner) { spa_log_debug(monitor->log, "oFono daemon disappeared"); monitor->backend_ofono_registered = false; @@ -3395,7 +3396,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us monitor->backend_native_registered = true; } } - } else if (strcmp(name, HSPHFPD_SERVICE) == 0 && monitor->backend_hsphfpd) { + } else if (spa_streq(name, HSPHFPD_SERVICE) && monitor->backend_hsphfpd) { if (old_owner && *old_owner) { spa_log_debug(monitor->log, "hsphfpd daemon disappeared"); spa_bt_backend_unregistered(monitor->backend_hsphfpd); @@ -3464,7 +3465,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us dbus_message_iter_next(&it[0]); dbus_message_iter_recurse(&it[0], &it[1]); - if (strcmp(iface, BLUEZ_ADAPTER_INTERFACE) == 0) { + if (spa_streq(iface, BLUEZ_ADAPTER_INTERFACE)) { struct spa_bt_adapter *a; a = adapter_find(monitor, path); @@ -3477,7 +3478,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us adapter_update_props(a, &it[1], NULL); } - else if (strcmp(iface, BLUEZ_DEVICE_INTERFACE) == 0) { + else if (spa_streq(iface, BLUEZ_DEVICE_INTERFACE)) { struct spa_bt_device *d; d = spa_bt_device_find(monitor, path); @@ -3490,7 +3491,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us device_update_props(d, &it[1], NULL); } - else if (strcmp(iface, BLUEZ_MEDIA_ENDPOINT_INTERFACE) == 0) { + else if (spa_streq(iface, BLUEZ_MEDIA_ENDPOINT_INTERFACE)) { struct spa_bt_remote_endpoint *ep; struct spa_bt_device *d; @@ -3508,7 +3509,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us if (d) spa_bt_device_emit_profiles_changed(d, d->profiles, d->connected_profiles); } - else if (strcmp(iface, BLUEZ_MEDIA_TRANSPORT_INTERFACE) == 0) { + else if (spa_streq(iface, BLUEZ_MEDIA_TRANSPORT_INTERFACE)) { struct spa_bt_transport *transport; transport = spa_bt_transport_find(monitor, path); @@ -3631,7 +3632,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct spa_bt_monitor *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) *interface = &this->device; else return -ENOENT; @@ -3723,17 +3724,17 @@ int spa_bt_profiles_from_json_array(const char *str) return -EINVAL; while (spa_json_get_string(&it_array, role_name, sizeof(role_name)) > 0) { - if (strcmp(role_name, "hsp_hs") == 0) { + if (spa_streq(role_name, "hsp_hs")) { profiles |= SPA_BT_PROFILE_HSP_HS; - } else if (strcmp(role_name, "hsp_ag") == 0) { + } else if (spa_streq(role_name, "hsp_ag")) { profiles |= SPA_BT_PROFILE_HSP_AG; - } else if (strcmp(role_name, "hfp_hf") == 0) { + } else if (spa_streq(role_name, "hfp_hf")) { profiles |= SPA_BT_PROFILE_HFP_HF; - } else if (strcmp(role_name, "hfp_ag") == 0) { + } else if (spa_streq(role_name, "hfp_ag")) { profiles |= SPA_BT_PROFILE_HFP_AG; - } else if (strcmp(role_name, "a2dp_sink") == 0) { + } else if (spa_streq(role_name, "a2dp_sink")) { profiles |= SPA_BT_PROFILE_A2DP_SINK; - } else if (strcmp(role_name, "a2dp_source") == 0) { + } else if (spa_streq(role_name, "a2dp_source")) { profiles |= SPA_BT_PROFILE_A2DP_SOURCE; } } @@ -3875,7 +3876,7 @@ impl_init(const struct spa_handle_factory *factory, uint32_t tmp; if ((str = spa_dict_lookup(info, "api.bluez5.connection-info")) != NULL && - (strcmp(str, "true") == 0 || atoi(str))) + (spa_streq(str, "true") || atoi(str))) this->connection_info_supported = true; if ((str = spa_dict_lookup(info, "bluez5.default.rate")) != NULL && @@ -3887,7 +3888,7 @@ impl_init(const struct spa_handle_factory *factory, this->default_audio_info.channels = tmp; if ((str = spa_dict_lookup(info, "bluez5.sbc-xq-support")) != NULL && - (strcmp(str, "true") == 0 || atoi(str))) + (spa_streq(str, "true") || atoi(str))) this->enable_sbc_xq = true; } diff --git a/spa/plugins/bluez5/bluez5-device.c b/spa/plugins/bluez5/bluez5-device.c index 0b78d4bdf..75c1f235d 100644 --- a/spa/plugins/bluez5/bluez5-device.c +++ b/spa/plugins/bluez5/bluez5-device.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -980,7 +981,7 @@ static void set_initial_profile(struct impl *this) const char *str; if (this->bt_dev->settings != NULL) { str = spa_dict_lookup(this->bt_dev->settings, "device.profile"); - if (str != NULL && strcmp(str, "headset-head-unit") == 0 && find_hsp_hfp_profile(this)) + if (str != NULL && spa_streq(str, "headset-head-unit") && find_hsp_hfp_profile(this)) return; } @@ -1806,7 +1807,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) *interface = &this->device; else return -ENOENT; diff --git a/spa/plugins/bluez5/sco-sink.c b/spa/plugins/bluez5/sco-sink.c index e4b1b93e7..e519a5142 100644 --- a/spa/plugins/bluez5/sco-sink.c +++ b/spa/plugins/bluez5/sco-sink.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -1139,7 +1140,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/bluez5/sco-source.c b/spa/plugins/bluez5/sco-source.c index 6f1d40ccb..517e82415 100644 --- a/spa/plugins/bluez5/sco-source.c +++ b/spa/plugins/bluez5/sco-source.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -1198,7 +1199,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/control/mixer.c b/spa/plugins/control/mixer.c index 4cb0b8f95..7774ab423 100644 --- a/spa/plugins/control/mixer.c +++ b/spa/plugins/control/mixer.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -707,7 +708,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/ffmpeg/ffmpeg-dec.c b/spa/plugins/ffmpeg/ffmpeg-dec.c index 0e4ee3de0..5fd967900 100644 --- a/spa/plugins/ffmpeg/ffmpeg-dec.c +++ b/spa/plugins/ffmpeg/ffmpeg-dec.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -445,7 +446,7 @@ impl_get_interface(struct spa_handle *handle, const char *type, void **interface this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/ffmpeg/ffmpeg-enc.c b/spa/plugins/ffmpeg/ffmpeg-enc.c index 253cb91b3..5c4e45afe 100644 --- a/spa/plugins/ffmpeg/ffmpeg-enc.c +++ b/spa/plugins/ffmpeg/ffmpeg-enc.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -424,7 +425,7 @@ impl_get_interface(struct spa_handle *handle, const char *type, void **interface this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/jack/jack-device.c b/spa/plugins/jack/jack-device.c index 3c56e0a20..d4e14d42f 100644 --- a/spa/plugins/jack/jack-device.c +++ b/spa/plugins/jack/jack-device.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -168,7 +169,7 @@ static int emit_info(struct impl *this, bool full) dinfo.change_mask = SPA_DEVICE_CHANGE_MASK_PROPS; items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_API, "jack"); items[1] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_NICK, "jack"); - if (strcmp(this->props.server, "default") == 0) + if (spa_streq(this->props.server, "default")) snprintf(name, sizeof(name), "JACK Client"); else snprintf(name, sizeof(name), "JACK Client (%s)", this->props.server); @@ -365,7 +366,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) *interface = &this->device; else return -ENOENT; diff --git a/spa/plugins/jack/jack-sink.c b/spa/plugins/jack/jack-sink.c index acebdcb73..36a954ed7 100644 --- a/spa/plugins/jack/jack-sink.c +++ b/spa/plugins/jack/jack-sink.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -804,7 +805,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/jack/jack-source.c b/spa/plugins/jack/jack-source.c index 2d7d619b1..07212452a 100644 --- a/spa/plugins/jack/jack-source.c +++ b/spa/plugins/jack/jack-source.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -826,7 +827,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/libcamera/libcamera-client.c b/spa/plugins/libcamera/libcamera-client.c index e558ce776..5bfd94873 100644 --- a/spa/plugins/libcamera/libcamera-client.c +++ b/spa/plugins/libcamera/libcamera-client.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -146,7 +147,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) *interface = &this->device; else return -ENOENT; diff --git a/spa/plugins/libcamera/libcamera-device.c b/spa/plugins/libcamera/libcamera-device.c index 44f6f1a4d..31e73af9b 100644 --- a/spa/plugins/libcamera/libcamera-device.c +++ b/spa/plugins/libcamera/libcamera-device.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -203,7 +204,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) *interface = &this->device; else return -ENOENT; diff --git a/spa/plugins/libcamera/libcamera-source.c b/spa/plugins/libcamera/libcamera-source.c index cba65b39e..d9e078df6 100644 --- a/spa/plugins/libcamera/libcamera-source.c +++ b/spa/plugins/libcamera/libcamera-source.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -882,7 +883,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/support/cpu.c b/spa/plugins/support/cpu.c index 30273c9d0..21f103588 100644 --- a/spa/plugins/support/cpu.c +++ b/spa/plugins/support/cpu.c @@ -40,6 +40,7 @@ #include #include #include +#include #define NAME "cpu" @@ -205,7 +206,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_CPU) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_CPU)) *interface = &this->cpu; else return -ENOENT; diff --git a/spa/plugins/support/dbus.c b/spa/plugins/support/dbus.c index 68f78a111..c1477baf0 100644 --- a/spa/plugins/support/dbus.c +++ b/spa/plugins/support/dbus.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -437,7 +438,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_DBus) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_DBus)) *interface = &this->dbus; else return -ENOENT; diff --git a/spa/plugins/support/evl-system.c b/spa/plugins/support/evl-system.c index 8d40cb30b..58130a061 100644 --- a/spa/plugins/support/evl-system.c +++ b/spa/plugins/support/evl-system.c @@ -40,6 +40,7 @@ #include #include #include +#include #define NAME "evl-system" @@ -372,7 +373,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void impl = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_System) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_System)) *interface = &impl->system; else return -ENOENT; diff --git a/spa/plugins/support/journal.c b/spa/plugins/support/journal.c index 4c132710f..b0dae43f9 100644 --- a/spa/plugins/support/journal.c +++ b/spa/plugins/support/journal.c @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -135,7 +136,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Log) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Log)) *interface = &this->log; else return -ENOENT; diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index b4ccb3279..79061255c 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -36,6 +36,7 @@ #include #include #include +#include #ifdef __FreeBSD__ #define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC @@ -190,7 +191,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Log) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Log)) *interface = &this->log; else return -ENOENT; @@ -265,11 +266,11 @@ impl_init(const struct spa_handle_factory *factory, } if (info) { if ((str = spa_dict_lookup(info, SPA_KEY_LOG_TIMESTAMP)) != NULL) - this->timestamp = (strcmp(str, "true") == 0 || atoi(str) == 1); + this->timestamp = (spa_streq(str, "true") || atoi(str) == 1); if ((str = spa_dict_lookup(info, SPA_KEY_LOG_LINE)) != NULL) - this->line = (strcmp(str, "true") == 0 || atoi(str) == 1); + this->line = (spa_streq(str, "true") || atoi(str) == 1); if ((str = spa_dict_lookup(info, SPA_KEY_LOG_COLORS)) != NULL) - this->colors = (strcmp(str, "true") == 0 || atoi(str) == 1); + this->colors = (spa_streq(str, "true") || atoi(str) == 1); if ((str = spa_dict_lookup(info, SPA_KEY_LOG_LEVEL)) != NULL) this->log.level = atoi(str); if ((str = spa_dict_lookup(info, SPA_KEY_LOG_FILE)) != NULL) { diff --git a/spa/plugins/support/loop.c b/spa/plugins/support/loop.c index 6ba49c422..e177c37fe 100644 --- a/spa/plugins/support/loop.c +++ b/spa/plugins/support/loop.c @@ -39,6 +39,7 @@ #include #include #include +#include #define NAME "loop" @@ -706,11 +707,11 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void impl = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Loop) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Loop)) *interface = &impl->loop; - else if (strcmp(type, SPA_TYPE_INTERFACE_LoopControl) == 0) + else if (spa_streq(type, SPA_TYPE_INTERFACE_LoopControl)) *interface = &impl->control; - else if (strcmp(type, SPA_TYPE_INTERFACE_LoopUtils) == 0) + else if (spa_streq(type, SPA_TYPE_INTERFACE_LoopUtils)) *interface = &impl->utils; else return -ENOENT; diff --git a/spa/plugins/support/node-driver.c b/spa/plugins/support/node-driver.c index c0b2318ae..041d0771d 100644 --- a/spa/plugins/support/node-driver.c +++ b/spa/plugins/support/node-driver.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -267,7 +268,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; @@ -359,7 +360,7 @@ impl_init(const struct spa_handle_factory *factory, if (info) { if ((str = spa_dict_lookup(info, "node.freewheel")) != NULL) - this->props.freewheel = (strcmp(str, "true") == 0 || atoi(str) == 1); + this->props.freewheel = (spa_streq(str, "true") || atoi(str) == 1); } spa_loop_add_source(this->data_loop, &this->timer_source); diff --git a/spa/plugins/support/null-audio-sink.c b/spa/plugins/support/null-audio-sink.c index efec9a990..11ad57153 100644 --- a/spa/plugins/support/null-audio-sink.c +++ b/spa/plugins/support/null-audio-sink.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -695,7 +696,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; @@ -728,7 +729,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; diff --git a/spa/plugins/support/system.c b/spa/plugins/support/system.c index 758ff1a82..3f7b4a70b 100644 --- a/spa/plugins/support/system.c +++ b/spa/plugins/support/system.c @@ -39,6 +39,7 @@ #include #include #include +#include #define NAME "system" @@ -301,7 +302,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void impl = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_System) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_System)) *interface = &impl->system; else return -ENOENT; diff --git a/spa/plugins/test/fakesink.c b/spa/plugins/test/fakesink.c index 56a18864c..4eec11b43 100644 --- a/spa/plugins/test/fakesink.c +++ b/spa/plugins/test/fakesink.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -688,7 +689,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/test/fakesrc.c b/spa/plugins/test/fakesrc.c index f9ffe3bd8..bc6818e63 100644 --- a/spa/plugins/test/fakesrc.c +++ b/spa/plugins/test/fakesrc.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -721,7 +722,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/v4l2/v4l2-device.c b/spa/plugins/v4l2/v4l2-device.c index c01456e8d..8a9fc9841 100644 --- a/spa/plugins/v4l2/v4l2-device.c +++ b/spa/plugins/v4l2/v4l2-device.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -196,7 +197,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) *interface = &this->device; else return -ENOENT; diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index bb7f01a5a..f435389c6 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -883,7 +884,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/v4l2/v4l2-udev.c b/spa/plugins/v4l2/v4l2-udev.c index cb1ac9b8d..5a5c11433 100644 --- a/spa/plugins/v4l2/v4l2-udev.c +++ b/spa/plugins/v4l2/v4l2-udev.c @@ -500,10 +500,10 @@ static void impl_on_fd_events(struct spa_source *source) start_inotify(this); - if (strcmp(action, "add") == 0 || - strcmp(action, "change") == 0) { + if (spa_streq(action, "add") || + spa_streq(action, "change")) { process_device(this, ACTION_ADD, dev); - } else if (strcmp(action, "remove") == 0) { + } else if (spa_streq(action, "remove")) { process_device(this, ACTION_REMOVE, dev); } udev_device_unref(dev); @@ -653,7 +653,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) *interface = &this->device; else return -ENOENT; diff --git a/spa/plugins/videoconvert/videoadapter.c b/spa/plugins/videoconvert/videoadapter.c index 5d70d02f0..74d123053 100644 --- a/spa/plugins/videoconvert/videoadapter.c +++ b/spa/plugins/videoconvert/videoadapter.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -336,7 +337,7 @@ static void follower_info(void *data, const struct spa_node_info *info) if (info->props) { if ((str = spa_dict_lookup(info->props, SPA_KEY_NODE_DRIVER)) != NULL) - this->driver = strcmp(str, "true") == 0 || atoi(str) == 1; + this->driver = spa_streq(str, "true") || atoi(str) == 1; } } @@ -810,7 +811,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c index ff1df8839..ae6e35fc3 100644 --- a/spa/plugins/videotestsrc/videotestsrc.c +++ b/spa/plugins/videotestsrc/videotestsrc.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -828,7 +829,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c index e9f97ee3e..595386d54 100644 --- a/spa/plugins/volume/volume.c +++ b/spa/plugins/volume/volume.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -746,7 +747,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/plugins/vulkan/vulkan-compute-source.c b/spa/plugins/vulkan/vulkan-compute-source.c index bc3389bf7..90b0575ad 100644 --- a/spa/plugins/vulkan/vulkan-compute-source.c +++ b/spa/plugins/vulkan/vulkan-compute-source.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -844,7 +845,7 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void this = (struct impl *) handle; - if (strcmp(type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(type, SPA_TYPE_INTERFACE_Node)) *interface = &this->node; else return -ENOENT; diff --git a/spa/tests/benchmark-dict.c b/spa/tests/benchmark-dict.c index 94d089f11..9d189b73f 100644 --- a/spa/tests/benchmark-dict.c +++ b/spa/tests/benchmark-dict.c @@ -31,6 +31,7 @@ #include #include +#include #define MAX_COUNT 100000 #define MAX_ITEMS 1000 @@ -74,7 +75,7 @@ static void test_query(const struct spa_dict *dict) for (i = 0; i < MAX_COUNT; i++) { idx = random() % dict->n_items; str = spa_dict_lookup(dict, dict->items[idx].key); - assert(strcmp(str, dict->items[idx].value) == 0); + assert(spa_streq(str, dict->items[idx].value)); } } diff --git a/spa/tests/test-json.c b/spa/tests/test-json.c index 22027df15..238522c1b 100644 --- a/spa/tests/test-json.c +++ b/spa/tests/test-json.c @@ -24,6 +24,7 @@ #include #include +#include static void test_abi(void) { @@ -73,7 +74,7 @@ static void expect_string(struct spa_json *it, const char *str) check_type(TYPE_STRING, value, len); s = alloca(len+1); spa_json_parse_string(value, len, s); - spa_assert(strcmp(s, str) == 0); + spa_assert(spa_streq(s, str)); } static void expect_float(struct spa_json *it, float val) { @@ -156,17 +157,17 @@ static void test_encode(void) char dst6[6]; char result[1024]; spa_assert(spa_json_encode_string(dst, sizeof(dst), "test") == 6); - spa_assert(strcmp(dst, "\"test\"") == 0); + spa_assert(spa_streq(dst, "\"test\"")); spa_assert(spa_json_encode_string(dst4, sizeof(dst4), "test") == 6); spa_assert(strncmp(dst4, "\"tes", 4) == 0); spa_assert(spa_json_encode_string(dst6, sizeof(dst6), "test") == 6); spa_assert(strncmp(dst6, "\"test\"", 6) == 0); spa_assert(spa_json_encode_string(dst, sizeof(dst), "test\"\n\r \t\b\f\'") == 20); - spa_assert(strcmp(dst, "\"test\\\"\\n\\r \\t\\b\\f'\"") == 0); + spa_assert(spa_streq(dst, "\"test\\\"\\n\\r \\t\\b\\f'\"")); spa_assert(spa_json_encode_string(dst, sizeof(dst), "\x04\x05\x1f\x20\x01\x7f\x90") == 29); - spa_assert(strcmp(dst, "\"\\u0004\\u0005\\u001f \\u0001\x7f\x90\"") == 0); + spa_assert(spa_streq(dst, "\"\\u0004\\u0005\\u001f \\u0001\x7f\x90\"")); spa_assert(spa_json_parse_string(dst, sizeof(dst), result) == 1); - spa_assert(strcmp(result, "\x04\x05\x1f\x20\x01\x7f\x90") == 0); + spa_assert(spa_streq(result, "\x04\x05\x1f\x20\x01\x7f\x90")); } static void test_array(char *str, char **vals) @@ -180,7 +181,7 @@ static void test_array(char *str, char **vals) spa_json_init(&it[1], str, strlen(str)); for (i = 0; vals[i]; i++) { spa_assert(spa_json_get_string(&it[1], val, sizeof(val)) > 0); - spa_assert(strcmp(val, vals[i]) == 0); + spa_assert(spa_streq(val, vals[i])); } } @@ -204,9 +205,9 @@ static void test_overflow(void) spa_assert(spa_json_enter_array(&it[0], &it[1]) > 0); spa_assert(spa_json_get_string(&it[1], val, sizeof(val)) > 0); - spa_assert(strcmp(val, "F") == 0); + spa_assert(spa_streq(val, "F")); spa_assert(spa_json_get_string(&it[1], val, sizeof(val)) > 0); - spa_assert(strcmp(val, "FR") == 0); + spa_assert(spa_streq(val, "FR")); spa_assert(spa_json_get_string(&it[1], val, sizeof(val)) < 0); } diff --git a/spa/tests/test-pod.c b/spa/tests/test-pod.c index 6b61373c3..7463051da 100644 --- a/spa/tests/test-pod.c +++ b/spa/tests/test-pod.c @@ -31,6 +31,7 @@ #include #include #include +#include static void test_abi(void) { @@ -288,7 +289,7 @@ static void test_init(void) spa_assert(SPA_POD_BODY_SIZE(&pod) == 9); spa_assert(spa_pod_is_string(&pod.pod.pod)); spa_assert(spa_pod_copy_string(&pod.pod.pod, sizeof(val), val) == 0); - spa_assert(strcmp(pod.str, val) == 0); + spa_assert(spa_streq(pod.str, val)); pod.pod = SPA_POD_INIT_String(6); memcpy(pod.str, "test123456789", 9); @@ -508,7 +509,7 @@ static void test_build(void) spa_assert((pod = spa_pod_next(pod)) != NULL && spa_pod_is_inside(head, len, pod)); spa_assert(spa_pod_is_string(pod)); spa_assert(spa_pod_get_string(pod, &val.s) == 0); - spa_assert(strcmp(val.s, "test") == 0); + spa_assert(spa_streq(val.s, "test")); spa_assert((pod = spa_pod_next(pod)) != NULL && spa_pod_is_inside(head, len, pod)); spa_assert(spa_pod_is_bytes(pod)); spa_assert(spa_pod_get_bytes(pod, &val.y, &yl) == 0); @@ -627,7 +628,7 @@ static void test_build(void) spa_assert(prop->key == 3); spa_assert(SPA_POD_PROP_SIZE(prop) == 24); spa_assert(spa_pod_get_string(&prop->value, &val.s) == 0 && - strcmp(val.s, "test123") == 0); + spa_streq(val.s, "test123")); break; default: spa_assert_not_reached(); @@ -637,7 +638,7 @@ static void test_build(void) spa_assert((prop = spa_pod_find_prop(pod, NULL, 3)) != NULL); spa_assert(prop->key == 3); spa_assert(spa_pod_get_string(&prop->value, &val.s) == 0 && - strcmp(val.s, "test123") == 0); + spa_streq(val.s, "test123")); spa_assert((prop = spa_pod_find_prop(pod, prop, 1)) != NULL); spa_assert(prop->key == 1); spa_assert(spa_pod_get_int(&prop->value, &val.i) == 0 && val.i == 21); @@ -649,7 +650,7 @@ static void test_build(void) spa_assert((prop = spa_pod_find_prop(pod, NULL, 3)) != NULL); spa_assert(prop->key == 3); spa_assert(spa_pod_get_string(&prop->value, &val.s) == 0 && - strcmp(val.s, "test123") == 0); + spa_streq(val.s, "test123")); spa_assert((pod = spa_pod_next(pod)) != NULL && spa_pod_is_inside(head, len, pod)); spa_assert(spa_pod_is_sequence(pod)); @@ -998,7 +999,7 @@ static void test_varargs2(void) spa_assert(prop->key == 7); spa_assert(SPA_POD_PROP_SIZE(prop) == 21); spa_assert(spa_pod_get_string(&prop->value, &val.s) == 0); - spa_assert(strcmp(val.s, "test") == 0); + spa_assert(spa_streq(val.s, "test")); break; case 7: spa_assert(prop->key == 8); @@ -1084,7 +1085,7 @@ static void test_varargs2(void) spa_assert(val.l == 4); spa_assert(val.f == 0.453f); spa_assert(val.d == 0.871); - spa_assert(strcmp(val.s, "test") == 0); + spa_assert(spa_streq(val.s, "test")); spa_assert(val.yl == sizeof(bytes)); spa_assert(memcmp(val.y, bytes, sizeof(bytes)) == 0); spa_assert(memcmp(&val.R, &SPA_RECTANGLE(3, 4), sizeof(struct spa_rectangle)) == 0); @@ -1251,7 +1252,7 @@ static void test_parser(void) spa_assert(val.l == 4); spa_assert(val.f == 0.453f); spa_assert(val.d == 0.871); - spa_assert(strcmp(val.s, "test") == 0); + spa_assert(spa_streq(val.s, "test")); spa_assert(val.yl == sizeof(bytes)); spa_assert(memcmp(val.y, bytes, sizeof(bytes)) == 0); spa_assert(memcmp(&val.R, &SPA_RECTANGLE(3, 4), sizeof(struct spa_rectangle)) == 0); @@ -1370,7 +1371,7 @@ static void test_parser2(void) spa_assert(p.state.offset == 88); spa_assert(spa_pod_parser_get_double(&p, &val.d) == 0 && val.d == 0.871); spa_assert(p.state.offset == 104); - spa_assert(spa_pod_parser_get_string(&p, &val.s) == 0 && strcmp(val.s, "test") == 0); + spa_assert(spa_pod_parser_get_string(&p, &val.s) == 0 && spa_streq(val.s, "test")); spa_assert(p.state.offset == 120); spa_assert(spa_pod_parser_get_bytes(&p, &val.y, &val.yl) == 0); spa_assert(val.yl == sizeof(bytes)); diff --git a/spa/tools/spa-inspect.c b/spa/tools/spa-inspect.c index 831805558..87dd9ff96 100644 --- a/spa/tools/spa-inspect.c +++ b/spa/tools/spa-inspect.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -250,7 +251,7 @@ static void inspect_factory(struct data *data, const struct spa_handle_factory * continue; } - if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) == 0) + if (spa_streq(info->type, SPA_TYPE_INTERFACE_Node)) inspect_node(data, interface); else printf("skipping unknown interface\n"); diff --git a/spa/tools/spa-monitor.c b/spa/tools/spa-monitor.c index be25b74d7..28159f37f 100644 --- a/spa/tools/spa-monitor.c +++ b/spa/tools/spa-monitor.c @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -201,7 +202,7 @@ int main(int argc, char *argv[]) break; } - if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) == 0) { + if (spa_streq(info->type, SPA_TYPE_INTERFACE_Device)) { struct spa_handle *handle; void *interface; diff --git a/src/examples/media-session/access-flatpak.c b/src/examples/media-session/access-flatpak.c index e194ab096..95984a540 100644 --- a/src/examples/media-session/access-flatpak.c +++ b/src/examples/media-session/access-flatpak.c @@ -30,6 +30,8 @@ #include "config.h" +#include + #include "pipewire/pipewire.h" #include "media-session.h" @@ -75,7 +77,7 @@ static void object_update(void *data) return; if ((str = spa_dict_lookup(client->obj->info->props, PW_KEY_MEDIA_CATEGORY)) != NULL && - (strcmp(str, "Manager") == 0)) { + (spa_streq(str, "Manager"))) { /* FIXME, use permission store to check if this app is allowed to * be a manager app */ perms = PW_PERM_ALL; @@ -131,7 +133,7 @@ static void session_create(void *data, struct sm_object *object) pw_log_debug(NAME " %p: create global '%d'", impl, object->id); - if (strcmp(object->type, PW_TYPE_INTERFACE_Client) == 0) + if (spa_streq(object->type, PW_TYPE_INTERFACE_Client)) res = handle_client(impl, object); else res = 0; @@ -145,7 +147,7 @@ static void session_remove(void *data, struct sm_object *object) struct impl *impl = data; pw_log_debug(NAME " %p: remove global '%d'", impl, object->id); - if (strcmp(object->type, PW_TYPE_INTERFACE_Client) == 0) { + if (spa_streq(object->type, PW_TYPE_INTERFACE_Client)) { struct client *client; if ((client = sm_object_get_data(object, SESSION_KEY)) != NULL) diff --git a/src/examples/media-session/access-portal.c b/src/examples/media-session/access-portal.c index 24fac444a..a816fa89a 100644 --- a/src/examples/media-session/access-portal.c +++ b/src/examples/media-session/access-portal.c @@ -32,6 +32,7 @@ #include +#include #include #include @@ -81,7 +82,7 @@ static void client_info_changed(struct client *client, const struct pw_client_in static enum media_role media_role_from_string(const char *media_role_str) { - if (strcmp(media_role_str, "Camera") == 0) + if (spa_streq(media_role_str, "Camera")) return MEDIA_ROLE_CAMERA; else return MEDIA_ROLE_INVALID; @@ -171,7 +172,7 @@ handle_client(struct impl *impl, struct sm_object *object) if (((str = pw_properties_get(client->obj->obj.props, PW_KEY_ACCESS)) != NULL || (str = pw_properties_get(client->obj->obj.props, PW_KEY_CLIENT_ACCESS)) != NULL) && - strcmp(str, "portal") == 0) { + spa_streq(str, "portal")) { client->portal_managed = true; pw_log_info(NAME " %p: portal managed client %d added", impl, client->id); @@ -195,9 +196,9 @@ set_global_permissions(void *data, struct sm_object *object) pw_log_debug(NAME" %p: object %d type:%s", impl, object->id, object->type); - if (strcmp(object->type, PW_TYPE_INTERFACE_Client) == 0) { + if (spa_streq(object->type, PW_TYPE_INTERFACE_Client)) { set_permission = allowed = object->id == client->id; - } else if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0) { + } else if (spa_streq(object->type, PW_TYPE_INTERFACE_Node)) { enum media_role media_role; media_role = media_role_from_properties(props); @@ -239,7 +240,7 @@ static void session_create(void *data, struct sm_object *object) pw_log_debug(NAME " %p: create global '%d'", impl, object->id); - if (strcmp(object->type, PW_TYPE_INTERFACE_Client) == 0) { + if (spa_streq(object->type, PW_TYPE_INTERFACE_Client)) { handle_client(impl, object); } else { struct client *client; @@ -265,7 +266,7 @@ static void session_remove(void *data, struct sm_object *object) struct impl *impl = data; pw_log_debug(NAME " %p: remove global '%d'", impl, object->id); - if (strcmp(object->type, PW_TYPE_INTERFACE_Client) == 0) { + if (spa_streq(object->type, PW_TYPE_INTERFACE_Client)) { struct client *client; if ((client = sm_object_get_data(object, SESSION_KEY)) != NULL) @@ -310,7 +311,7 @@ check_permission_allowed(DBusMessageIter *iter) dbus_message_iter_get_basic(iter, &permission_value); - if (strcmp(permission_value, "yes") == 0) { + if (spa_streq(permission_value, "yes")) { allowed = true; break; } @@ -347,7 +348,7 @@ static void do_permission_store_check(struct client *client) return; } - if (strcmp(client->app_id, "") == 0) { + if (spa_streq(client->app_id, "")) { pw_log_debug("Ignoring portal check for non-sandboxed portal client %p", client); client->allowed_media_roles = MEDIA_ROLE_ALL; @@ -453,7 +454,7 @@ static void client_info_changed(struct client *client, const struct pw_client_in is_portal = spa_dict_lookup(props, "pipewire.access.portal.is_portal"); if (is_portal != NULL && - (strcmp(is_portal, "yes") == 0 || pw_properties_parse_bool(is_portal))) { + (spa_streq(is_portal, "yes") || pw_properties_parse_bool(is_portal))) { pw_log_info(NAME " %p: client %d is the portal itself", impl, client->id); client->is_portal = true; diff --git a/src/examples/media-session/alsa-endpoint.c b/src/examples/media-session/alsa-endpoint.c index fa58ac2fb..5fc7c42ff 100644 --- a/src/examples/media-session/alsa-endpoint.c +++ b/src/examples/media-session/alsa-endpoint.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -707,7 +708,7 @@ static void session_create(void *data, struct sm_object *object) struct impl *impl = data; int res; - if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0) + if (spa_streq(object->type, PW_TYPE_INTERFACE_Device)) res = handle_device(impl, object); else res = 0; @@ -722,7 +723,7 @@ static void session_remove(void *data, struct sm_object *object) { struct impl *impl = data; - if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0) { + if (spa_streq(object->type, PW_TYPE_INTERFACE_Device)) { struct device *device; if ((device = sm_object_get_data(object, SESSION_KEY)) != NULL) destroy_device(impl, device); diff --git a/src/examples/media-session/alsa-monitor.c b/src/examples/media-session/alsa-monitor.c index 9453a847d..ba48678d4 100644 --- a/src/examples/media-session/alsa-monitor.c +++ b/src/examples/media-session/alsa-monitor.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -145,7 +146,7 @@ static struct node *alsa_find_node(struct device *device, uint32_t id, const cha return node; if (name != NULL && (str = pw_properties_get(node->props, PW_KEY_NODE_NAME)) != NULL && - strcmp(name, str) == 0) + spa_streq(name, str)) return node; } return NULL; @@ -208,30 +209,30 @@ static void update_icon_name(struct pw_properties *p, bool is_sink) const char *s, *d = NULL, *bus; if ((s = pw_properties_get(p, PW_KEY_DEVICE_FORM_FACTOR))) { - if (strcmp(s, "microphone") == 0) + if (spa_streq(s, "microphone")) d = "audio-input-microphone"; - else if (strcmp(s, "webcam") == 0) + else if (spa_streq(s, "webcam")) d = "camera-web"; - else if (strcmp(s, "computer") == 0) + else if (spa_streq(s, "computer")) d = "computer"; - else if (strcmp(s, "handset") == 0) + else if (spa_streq(s, "handset")) d = "phone"; - else if (strcmp(s, "portable") == 0) + else if (spa_streq(s, "portable")) d = "multimedia-player"; - else if (strcmp(s, "tv") == 0) + else if (spa_streq(s, "tv")) d = "video-display"; - else if (strcmp(s, "headset") == 0) + else if (spa_streq(s, "headset")) d = "audio-headset"; - else if (strcmp(s, "headphone") == 0) + else if (spa_streq(s, "headphone")) d = "audio-headphones"; - else if (strcmp(s, "speaker") == 0) + else if (spa_streq(s, "speaker")) d = "audio-speakers"; - else if (strcmp(s, "hands-free") == 0) + else if (spa_streq(s, "hands-free")) d = "audio-handsfree"; } if (!d) if ((s = pw_properties_get(p, PW_KEY_DEVICE_CLASS))) - if (strcmp(s, "modem") == 0) + if (spa_streq(s, "modem")) d = "modem"; if (!d) { @@ -524,7 +525,7 @@ static struct device *alsa_find_device(struct impl *impl, uint32_t id, const cha return device; if (name != NULL && (str = pw_properties_get(device->props, PW_KEY_DEVICE_NAME)) != NULL && - strcmp(str, name) == 0) + spa_streq(str, name)) return device; } return NULL; @@ -581,11 +582,11 @@ static int update_device_props(struct device *device) d = NULL; if ((s = pw_properties_get(p, PW_KEY_DEVICE_FORM_FACTOR))) - if (strcmp(s, "internal") == 0) + if (spa_streq(s, "internal")) d = _("Built-in Audio"); if (!d) if ((s = pw_properties_get(p, PW_KEY_DEVICE_CLASS))) - if (strcmp(s, "modem") == 0) + if (spa_streq(s, "modem")) d = _("Modem"); if (!d) d = pw_properties_get(p, PW_KEY_DEVICE_PRODUCT_NAME); @@ -756,7 +757,7 @@ static void reserve_busy(void *data, struct rd_device *d, const char *name, int3 device->sdevice->locked = true; - if (strcmp(name, "jack") == 0) { + if (spa_streq(name, "jack")) { add_jack_timeout(impl); } else { remove_jack_timeout(impl); @@ -775,7 +776,7 @@ static void reserve_available(void *data, struct rd_device *d, const char *name) device->sdevice->locked = false; remove_jack_timeout(impl); - if (strcmp(name, "jack") == 0) { + if (spa_streq(name, "jack")) { set_jack_profile(impl, 0); } } diff --git a/src/examples/media-session/bluez-endpoint.c b/src/examples/media-session/bluez-endpoint.c index 413ea5512..b6b9a99cb 100644 --- a/src/examples/media-session/bluez-endpoint.c +++ b/src/examples/media-session/bluez-endpoint.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -644,7 +645,7 @@ static void session_create(void *data, struct sm_object *object) struct impl *impl = data; int res; - if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0) + if (spa_streq(object->type, PW_TYPE_INTERFACE_Device)) res = handle_device(impl, object); else res = 0; @@ -659,7 +660,7 @@ static void session_remove(void *data, struct sm_object *object) { struct impl *impl = data; - if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0) { + if (spa_streq(object->type, PW_TYPE_INTERFACE_Device)) { struct device *device; if ((device = sm_object_get_data(object, SESSION_KEY)) != NULL) destroy_device(impl, device); diff --git a/src/examples/media-session/bluez-monitor.c b/src/examples/media-session/bluez-monitor.c index a0712bd53..f6a6b23eb 100644 --- a/src/examples/media-session/bluez-monitor.c +++ b/src/examples/media-session/bluez-monitor.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -121,30 +122,30 @@ static void update_icon_name(struct pw_properties *p, bool is_sink) const char *s, *d = NULL, *bus; if ((s = pw_properties_get(p, PW_KEY_DEVICE_FORM_FACTOR))) { - if (strcmp(s, "microphone") == 0) + if (spa_streq(s, "microphone")) d = "audio-input-microphone"; - else if (strcmp(s, "webcam") == 0) + else if (spa_streq(s, "webcam")) d = "camera-web"; - else if (strcmp(s, "computer") == 0) + else if (spa_streq(s, "computer")) d = "computer"; - else if (strcmp(s, "handset") == 0) + else if (spa_streq(s, "handset")) d = "phone"; - else if (strcmp(s, "portable") == 0) + else if (spa_streq(s, "portable")) d = "multimedia-player"; - else if (strcmp(s, "tv") == 0) + else if (spa_streq(s, "tv")) d = "video-display"; - else if (strcmp(s, "headset") == 0) + else if (spa_streq(s, "headset")) d = "audio-headset"; - else if (strcmp(s, "headphone") == 0) + else if (spa_streq(s, "headphone")) d = "audio-headphones"; - else if (strcmp(s, "speaker") == 0) + else if (spa_streq(s, "speaker")) d = "audio-speakers"; - else if (strcmp(s, "hands-free") == 0) + else if (spa_streq(s, "hands-free")) d = "audio-handsfree"; } if (!d) if ((s = pw_properties_get(p, PW_KEY_DEVICE_CLASS))) - if (strcmp(s, "modem") == 0) + if (spa_streq(s, "modem")) d = "modem"; if (!d) { @@ -563,7 +564,7 @@ static void bluez5_update_device(struct impl *impl, struct device *device, update_device_props(device); str = spa_dict_lookup(info->props, SPA_KEY_API_BLUEZ5_CONNECTION); - connected = str != NULL && strcmp(str, "connected") == 0; + connected = str != NULL && spa_streq(str, "connected"); /* Export device after bluez profiles get connected */ if (device->sdevice == NULL && connected) { diff --git a/src/examples/media-session/default-nodes.c b/src/examples/media-session/default-nodes.c index fea8ef6dd..0720f25c0 100644 --- a/src/examples/media-session/default-nodes.c +++ b/src/examples/media-session/default-nodes.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include "pipewire/pipewire.h" @@ -80,7 +81,7 @@ static struct default_node *find_default(struct impl *impl, const char *key) struct default_node *def; /* Check that the item key is a valid default key */ for (def = impl->defaults; def->key != NULL; ++def) - if (strcmp(key, def->key) == 0) + if (spa_streq(key, def->key)) return def; return NULL; } @@ -96,10 +97,10 @@ static int find_name(void *data, struct sm_object *object) struct find_data *d = data; const char *str; - if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0 && + if (spa_streq(object->type, PW_TYPE_INTERFACE_Node) && object->props && (str = pw_properties_get(object->props, PW_KEY_NODE_NAME)) != NULL && - strcmp(str, d->name) == 0) { + spa_streq(str, d->name)) { d->id = object->id; return 1; } @@ -124,7 +125,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; diff --git a/src/examples/media-session/default-profile.c b/src/examples/media-session/default-profile.c index e73a3dfdb..877ad0222 100644 --- a/src/examples/media-session/default-profile.c +++ b/src/examples/media-session/default-profile.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -166,10 +167,10 @@ static int find_best_profile(struct device *dev, struct profile *pr) parse_profile(p, &t) < 0) continue; - if (t.name && strcmp(t.name, "pro-audio") == 0) + if (t.name && spa_streq(t.name, "pro-audio")) continue; - if (t.name && strcmp(t.name, "off") == 0) { + if (t.name && spa_streq(t.name, "off")) { off = t; } else if (t.available == SPA_PARAM_AVAILABILITY_yes) { @@ -209,7 +210,7 @@ static int find_saved_profile(struct device *dev, struct profile *pr) return -EINVAL; while (spa_json_get_string(&it[1], key, sizeof(key)-1) > 0) { - if (strcmp(key, "name") == 0) { + if (spa_streq(key, "name")) { if (spa_json_get_string(&it[1], name, sizeof(name)) <= 0) continue; } else { @@ -224,7 +225,7 @@ static int find_saved_profile(struct device *dev, struct profile *pr) parse_profile(p, pr) < 0) continue; - if (strcmp(pr->name, name) == 0) + if (spa_streq(pr->name, name)) return 0; } return -ENOENT; @@ -262,7 +263,7 @@ static int handle_active_profile(struct device *dev) /* when the active profile is off, always try to restored the saved * profile again */ - if (strcmp(pr.name, "off") == 0) + if (spa_streq(pr.name, "off")) dev->restored = false; if (dev->active_profile == pr.index) { @@ -368,7 +369,7 @@ static void object_update(void *data) if (dev->obj->info && dev->obj->info->props && (str = spa_dict_lookup(dev->obj->info->props, PW_KEY_DEVICE_BUS)) != NULL && - strcmp(str, "bluetooth") == 0) + spa_streq(str, "bluetooth")) return; if (dev->obj->obj.changed & SM_DEVICE_CHANGE_MASK_PARAMS) diff --git a/src/examples/media-session/default-routes.c b/src/examples/media-session/default-routes.c index c132bc287..453381f53 100644 --- a/src/examples/media-session/default-routes.c +++ b/src/examples/media-session/default-routes.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -117,7 +118,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; @@ -345,21 +346,21 @@ static int restore_route_params(struct device *dev, const char *val, struct rout SPA_TYPE_OBJECT_Props, SPA_PARAM_Route); while (spa_json_get_string(&it[1], key, sizeof(key)-1) > 0) { - if (strcmp(key, "volume") == 0) { + if (spa_streq(key, "volume")) { float vol; if (spa_json_get_float(&it[1], &vol) <= 0) continue; spa_pod_builder_prop(&b, SPA_PROP_volume, 0); spa_pod_builder_float(&b, vol); } - else if (strcmp(key, "mute") == 0) { + else if (spa_streq(key, "mute")) { bool mute; if (spa_json_get_bool(&it[1], &mute) <= 0) continue; spa_pod_builder_prop(&b, SPA_PROP_mute, 0); spa_pod_builder_bool(&b, mute); } - else if (strcmp(key, "volumes") == 0) { + else if (spa_streq(key, "volumes")) { uint32_t n_vols; float vols[SPA_AUDIO_MAX_CHANNELS]; @@ -377,7 +378,7 @@ static int restore_route_params(struct device *dev, const char *val, struct rout spa_pod_builder_array(&b, sizeof(float), SPA_TYPE_Float, n_vols, vols); } - else if (strcmp(key, "channels") == 0) { + else if (spa_streq(key, "channels")) { uint32_t n_ch; uint32_t map[SPA_AUDIO_MAX_CHANNELS]; @@ -397,7 +398,7 @@ static int restore_route_params(struct device *dev, const char *val, struct rout spa_pod_builder_array(&b, sizeof(uint32_t), SPA_TYPE_Id, n_ch, map); } - else if (strcmp(key, "latencyOffsetNsec") == 0) { + else if (spa_streq(key, "latencyOffsetNsec")) { float delay; if (spa_json_get_float(&it[1], &delay) <= 0) continue; @@ -689,7 +690,7 @@ static int reconfigure_profile(struct device *dev, struct profile *pr, bool rest NULL) >= 0) { if (key == NULL || val == NULL) break; - if (strcmp(key, "card.profile.devices") == 0) { + if (spa_streq(key, "card.profile.devices")) { uint32_t *devices, n_devices, i; devices = spa_pod_get_array(val, &n_devices); diff --git a/src/examples/media-session/logind.c b/src/examples/media-session/logind.c index a286bdd55..a6fc30efd 100644 --- a/src/examples/media-session/logind.c +++ b/src/examples/media-session/logind.c @@ -35,6 +35,7 @@ #include #include +#include #include "pipewire/pipewire.h" #include "media-session.h" @@ -58,7 +59,7 @@ static void update_seat_active(struct impl *impl) if (sd_uid_get_state(getuid(), &state) < 0) return; - active = strcmp(state, "active") == 0; + active = spa_streq(state, "active"); free(state); sm_media_session_seat_active_changed(impl->session, active); diff --git a/src/examples/media-session/match-rules.c b/src/examples/media-session/match-rules.c index 7e2ab7019..dda9774db 100644 --- a/src/examples/media-session/match-rules.c +++ b/src/examples/media-session/match-rules.c @@ -32,6 +32,7 @@ #include "config.h" #include +#include #include #include "media-session.h" @@ -104,13 +105,13 @@ int sm_media_session_match_rules(const char *rules, size_t size, struct pw_prope bool have_match = false, have_actions = false; while (spa_json_get_string(&it[2], key, sizeof(key)-1) > 0) { - if (strcmp(key, "matches") == 0) { + if (spa_streq(key, "matches")) { if (spa_json_enter_array(&it[2], &it[3]) < 0) break; have_match = find_match(&it[3], props); } - else if (strcmp(key, "actions") == 0) { + else if (spa_streq(key, "actions")) { if (spa_json_enter_object(&it[2], &actions) > 0) have_actions = true; } @@ -123,7 +124,7 @@ int sm_media_session_match_rules(const char *rules, size_t size, struct pw_prope while (spa_json_get_string(&actions, key, sizeof(key)-1) > 0) { int len; pw_log_debug("action %s", key); - if (strcmp(key, "update-props") == 0) { + if (spa_streq(key, "update-props")) { if ((len = spa_json_next(&actions, &val)) <= 0) continue; if (!spa_json_is_object(val, len)) diff --git a/src/examples/media-session/media-session.c b/src/examples/media-session/media-session.c index 2b252c9f6..84eefbc41 100644 --- a/src/examples/media-session/media-session.c +++ b/src/examples/media-session/media-session.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -250,7 +251,7 @@ static struct data *object_find_data(struct sm_object *obj, const char *id) { struct data *d; spa_list_for_each(d, &obj->data, link) { - if (strcmp(d->id, id) == 0) + if (spa_streq(d->id, id)) return d; } return NULL; @@ -740,7 +741,7 @@ static enum spa_audio_channel find_channel(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; @@ -755,12 +756,12 @@ static int port_init(void *object) if (props) { if ((str = pw_properties_get(props, PW_KEY_PORT_DIRECTION)) != NULL) - port->direction = strcmp(str, "out") == 0 ? + port->direction = spa_streq(str, "out") ? PW_DIRECTION_OUTPUT : PW_DIRECTION_INPUT; if ((str = pw_properties_get(props, PW_KEY_FORMAT_DSP)) != NULL) { - if (strcmp(str, "32 bit float mono audio") == 0) + if (spa_streq(str, "32 bit float mono audio")) port->type = SM_PORT_TYPE_DSP_AUDIO; - else if (strcmp(str, "8 bit raw midi") == 0) + else if (spa_streq(str, "8 bit raw midi")) port->type = SM_PORT_TYPE_DSP_MIDI; } if ((str = pw_properties_get(props, PW_KEY_AUDIO_CHANNEL)) != NULL) @@ -1175,29 +1176,29 @@ static const struct object_info *get_object_info(struct impl *impl, const char * { const struct object_info *info; - if (strcmp(type, PW_TYPE_INTERFACE_Core) == 0) + if (spa_streq(type, PW_TYPE_INTERFACE_Core)) info = &core_object_info; - else if (strcmp(type, PW_TYPE_INTERFACE_Module) == 0) + else if (spa_streq(type, PW_TYPE_INTERFACE_Module)) info = &module_info; - else if (strcmp(type, PW_TYPE_INTERFACE_Factory) == 0) + else if (spa_streq(type, PW_TYPE_INTERFACE_Factory)) info = &factory_info; - else if (strcmp(type, PW_TYPE_INTERFACE_Client) == 0) + else if (spa_streq(type, PW_TYPE_INTERFACE_Client)) info = &client_info; - else if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0) + else if (spa_streq(type, SPA_TYPE_INTERFACE_Device)) info = &spa_device_info; - else if (strcmp(type, PW_TYPE_INTERFACE_Device) == 0) + else if (spa_streq(type, PW_TYPE_INTERFACE_Device)) info = &device_info; - else if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) + else if (spa_streq(type, PW_TYPE_INTERFACE_Node)) info = &node_info; - else if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) + else if (spa_streq(type, PW_TYPE_INTERFACE_Port)) info = &port_info; - else if (strcmp(type, PW_TYPE_INTERFACE_Session) == 0) + else if (spa_streq(type, PW_TYPE_INTERFACE_Session)) info = &session_info; - else if (strcmp(type, PW_TYPE_INTERFACE_Endpoint) == 0) + else if (spa_streq(type, PW_TYPE_INTERFACE_Endpoint)) info = &endpoint_info; - else if (strcmp(type, PW_TYPE_INTERFACE_EndpointStream) == 0) + else if (spa_streq(type, PW_TYPE_INTERFACE_EndpointStream)) info = &endpoint_stream_info; - else if (strcmp(type, PW_TYPE_INTERFACE_EndpointLink) == 0) + else if (spa_streq(type, PW_TYPE_INTERFACE_EndpointLink)) info = &endpoint_link_info; else info = NULL; @@ -1251,7 +1252,7 @@ create_object(struct impl *impl, struct pw_proxy *proxy, struct pw_proxy *handle type = pw_proxy_get_type(handle, NULL); - if (strcmp(type, PW_TYPE_INTERFACE_ClientNode) == 0) + if (spa_streq(type, PW_TYPE_INTERFACE_ClientNode)) type = PW_TYPE_INTERFACE_Node; info = get_object_info(impl, type); @@ -1486,7 +1487,7 @@ monitor_registry_global(void *data, uint32_t id, re.proxy = pw_registry_bind(impl->registry, id, type, info->version, 0); if (re.proxy) handle_registry_event(impl, &re); - else + else pw_log_warn(NAME" %p: can't handle global %d: %s", impl, id, spa_strerror(-errno)); registry_event_free(&re); @@ -1839,9 +1840,9 @@ static int link_nodes(struct impl *impl, struct endpoint_link *link, pw_log_debug(NAME" %p: linking %d -> %d", impl, outnode->obj.id, innode->obj.id); if ((str = spa_dict_lookup(outnode->info->props, PW_KEY_NODE_PASSIVE)) != NULL) - passive |= (pw_properties_parse_bool(str) || strcmp(str, "out") == 0); + passive |= (pw_properties_parse_bool(str) || spa_streq(str, "out")); if ((str = spa_dict_lookup(innode->info->props, PW_KEY_NODE_PASSIVE)) != NULL) - passive |= (pw_properties_parse_bool(str) || strcmp(str, "in") == 0); + passive |= (pw_properties_parse_bool(str) || spa_streq(str, "in")); props = pw_properties_new(NULL, NULL); pw_properties_setf(props, PW_KEY_LINK_OUTPUT_NODE, "%d", outnode->obj.id); diff --git a/src/examples/media-session/policy-ep.c b/src/examples/media-session/policy-ep.c index 76d4f3948..c5d1bbb4b 100644 --- a/src/examples/media-session/policy-ep.c +++ b/src/examples/media-session/policy-ep.c @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -161,9 +162,9 @@ handle_endpoint(struct impl *impl, struct sm_object *object) else return 0; - if (strcmp(media_class, "Sink") == 0) + if (spa_streq(media_class, "Sink")) direction = PW_DIRECTION_INPUT; - else if (strcmp(media_class, "Source") == 0) + else if (spa_streq(media_class, "Source")) direction = PW_DIRECTION_OUTPUT; else return 0; @@ -218,9 +219,9 @@ static void session_create(void *data, struct sm_object *object) struct impl *impl = data; int res; - if (strcmp(object->type, PW_TYPE_INTERFACE_Endpoint) == 0) + if (spa_streq(object->type, PW_TYPE_INTERFACE_Endpoint)) res = handle_endpoint(impl, object); - else if (strcmp(object->type, PW_TYPE_INTERFACE_EndpointStream) == 0) + else if (spa_streq(object->type, PW_TYPE_INTERFACE_EndpointStream)) res = handle_stream(impl, object); else res = 0; @@ -237,12 +238,12 @@ static void session_remove(void *data, struct sm_object *object) struct impl *impl = data; pw_log_debug(NAME " %p: remove global '%d'", impl, object->id); - if (strcmp(object->type, PW_TYPE_INTERFACE_Endpoint) == 0) { + if (spa_streq(object->type, PW_TYPE_INTERFACE_Endpoint)) { struct endpoint *ep; if ((ep = sm_object_get_data(object, SESSION_KEY)) != NULL) destroy_endpoint(impl, ep); } - else if (strcmp(object->type, PW_TYPE_INTERFACE_EndpointStream) == 0) { + else if (spa_streq(object->type, PW_TYPE_INTERFACE_EndpointStream)) { struct stream *s; if ((s = sm_object_get_data(object, SESSION_KEY)) != NULL) destroy_stream(impl, s); @@ -429,11 +430,11 @@ static int rescan_endpoint(struct impl *impl, struct endpoint *ep) pw_log_debug(NAME " %p: target:%d", impl, path_id); if ((obj = sm_media_session_find_object(impl->session, path_id)) != NULL) { - if (strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) == 0) { + if (spa_streq(obj->type, PW_TYPE_INTERFACE_Endpoint)) { if ((peer = sm_object_get_data(obj, SESSION_KEY)) != NULL) goto do_link; } - else if (strcmp(obj->type, PW_TYPE_INTERFACE_Node) == 0) { + else if (spa_streq(obj->type, PW_TYPE_INTERFACE_Node)) { node = (struct sm_node*)obj; goto do_link_node; } @@ -454,7 +455,7 @@ static int rescan_endpoint(struct impl *impl, struct endpoint *ep) } obj = sm_media_session_find_object(impl->session, ep->client_id); - if (obj && strcmp(obj->type, PW_TYPE_INTERFACE_Client) == 0) { + if (obj && spa_streq(obj->type, PW_TYPE_INTERFACE_Client)) { pw_client_error((struct pw_client*)obj->proxy, ep->id, -ENOENT, "no endpoint available"); } diff --git a/src/examples/media-session/policy-node.c b/src/examples/media-session/policy-node.c index 841ce7987..52a72f3f8 100644 --- a/src/examples/media-session/policy-node.c +++ b/src/examples/media-session/policy-node.c @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -341,12 +342,12 @@ handle_node(struct impl *impl, struct sm_object *object) else return 0; - if (strcmp(media_class, "Sink") == 0 || - strcmp(media_class, "Duplex") == 0) + if (spa_streq(media_class, "Sink") || + spa_streq(media_class, "Duplex")) direction = PW_DIRECTION_INPUT; - else if (strcmp(media_class, "Source") == 0) + else if (spa_streq(media_class, "Source")) direction = PW_DIRECTION_OUTPUT; - else if (strcmp(media_class, "Source/Virtual") == 0) { + else if (spa_streq(media_class, "Source/Virtual")) { virtual = true; direction = PW_DIRECTION_OUTPUT; } else @@ -412,7 +413,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; @@ -428,7 +429,7 @@ static bool check_node_name(struct node *node, const char *name) { const char *str; if ((str = pw_properties_get(node->obj->obj.props, PW_KEY_NODE_NAME)) != NULL && - name != NULL && strcmp(str, name) == 0) + name != NULL && spa_streq(str, name)) return true; return false; } @@ -466,7 +467,7 @@ static uint32_t find_device_for_name(struct impl *impl, const char *name) return id; if ((str = get_device_name(node)) == NULL) continue; - if (strcmp(str, name) == 0) + if (spa_streq(str, name)) return node->obj->obj.id; } return SPA_ID_INVALID; @@ -479,7 +480,7 @@ static void session_create(void *data, struct sm_object *object) clock_gettime(CLOCK_MONOTONIC, &impl->now); - if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0) + if (spa_streq(object->type, PW_TYPE_INTERFACE_Node)) res = handle_node(impl, object); else res = 0; @@ -495,7 +496,7 @@ static void session_remove(void *data, struct sm_object *object) struct impl *impl = data; pw_log_debug(NAME " %p: remove global '%d'", impl, object->id); - if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0) { + if (spa_streq(object->type, PW_TYPE_INTERFACE_Node)) { struct node *n, *node; if ((node = sm_object_get_data(object, SESSION_KEY)) != NULL) @@ -557,7 +558,7 @@ static int find_node(void *data, struct node *node) priority = node->priority; if (node->media) { - if (strcmp(node->media, "Audio") == 0) { + if (spa_streq(node->media, "Audio")) { if (node->direction == PW_DIRECTION_INPUT) { if (find->direction == PW_DIRECTION_OUTPUT) is_default |= check_node_name(node, @@ -569,7 +570,7 @@ static int find_node(void *data, struct node *node) find->direction == PW_DIRECTION_INPUT) is_default |= check_node_name(node, impl->defaults[DEFAULT_AUDIO_SOURCE].config); - } else if (strcmp(node->media, "Video") == 0) { + } else if (spa_streq(node->media, "Video")) { if (node->direction == PW_DIRECTION_OUTPUT && find->direction == PW_DIRECTION_INPUT) is_default |= check_node_name(node, @@ -614,13 +615,13 @@ static struct node *find_auto_default_node(struct impl *impl, const struct defau find.capture_sink = false; find.exclusive = false; - if (strcmp(def->key, DEFAULT_AUDIO_SINK_KEY) == 0) { + if (spa_streq(def->key, DEFAULT_AUDIO_SINK_KEY)) { find.media = "Audio"; find.direction = PW_DIRECTION_OUTPUT; - } else if (strcmp(def->key, DEFAULT_AUDIO_SOURCE_KEY) == 0) { + } else if (spa_streq(def->key, DEFAULT_AUDIO_SOURCE_KEY)) { find.media = "Audio"; find.direction = PW_DIRECTION_INPUT; - } else if (strcmp(def->key, DEFAULT_VIDEO_SOURCE_KEY) == 0) { + } else if (spa_streq(def->key, DEFAULT_VIDEO_SOURCE_KEY)) { find.media = "Video"; find.direction = PW_DIRECTION_INPUT; } else { @@ -777,7 +778,7 @@ static int rescan_node(struct impl *impl, struct node *n) autoconnect = pw_properties_parse_bool(str); if ((str = spa_dict_lookup(props, PW_KEY_DEVICE_API)) != NULL && - strcmp(str, "bluez5") == 0) + spa_streq(str, "bluez5")) autoconnect = true; if (!autoconnect) { @@ -836,7 +837,7 @@ static int rescan_node(struct impl *impl, struct node *n) if ((obj = sm_media_session_find_object(impl->session, path_id)) != NULL) { pw_log_debug(NAME " %p: found target:%d type:%s", impl, path_id, obj->type); - if (strcmp(obj->type, PW_TYPE_INTERFACE_Node) == 0) { + if (spa_streq(obj->type, PW_TYPE_INTERFACE_Node)) { peer = sm_object_get_data(obj, SESSION_KEY); if (peer == NULL) return -ENOENT; @@ -868,7 +869,7 @@ static int rescan_node(struct impl *impl, struct node *n) pw_log_debug(NAME " %p: client_id:%d object:%p type:%s", impl, n->client_id, obj, obj ? obj->type : "None"); - if (obj && strcmp(obj->type, PW_TYPE_INTERFACE_Client) == 0) { + if (obj && spa_streq(obj->type, PW_TYPE_INTERFACE_Client)) { pw_client_error((struct pw_client*)obj->proxy, n->id, -ENOENT, "no node available"); } @@ -1035,7 +1036,7 @@ static int check_new_target(struct impl *impl, struct node *target) node->id, node->obj->target_node, str); if (node->obj->target_node != NULL && - strcmp(node->obj->target_node , str) == 0) { + spa_streq(node->obj->target_node , str)) { handle_move(impl, node, target); } } @@ -1061,13 +1062,13 @@ static int metadata_property(void *object, uint32_t subject, val = name; } for (def = impl->defaults; def->key != NULL; ++def) { - if (key == NULL || strcmp(key, def->key_config) == 0) { + if (key == NULL || spa_streq(key, def->key_config)) { if (strzcmp(def->config, val) != 0) changed = true; free(def->config); def->config = val ? strdup(val) : NULL; } - if (key == NULL || strcmp(key, def->key) == 0) { + if (key == NULL || spa_streq(key, def->key)) { bool eff_changed = strzcmp(def->value, val) != 0; free(def->value); def->value = val ? strdup(val) : NULL; @@ -1080,7 +1081,7 @@ static int metadata_property(void *object, uint32_t subject, } if (changed) sm_media_session_schedule_rescan(impl->session); - } else if (key != NULL && strcmp(key, "target.node") == 0) { + } else if (key != NULL && spa_streq(key, "target.node")) { if (value != NULL) { struct node *src_node, *dst_node; diff --git a/src/examples/media-session/reserve.c b/src/examples/media-session/reserve.c index 5964c464e..072ead2fa 100644 --- a/src/examples/media-session/reserve.c +++ b/src/examples/media-session/reserve.c @@ -28,6 +28,8 @@ #include "reserve.h" +#include + #define SERVICE_PREFIX "org.freedesktop.ReserveDevice1." #define OBJECT_PREFIX "/org/freedesktop/ReserveDevice1/" @@ -147,10 +149,10 @@ static DBusHandlerResult object_handler(DBusConnection *c, DBusMessage *m, void DBUS_TYPE_INVALID)) goto invalid; - if (strcmp(interface, "org.freedesktop.ReserveDevice1") == 0) { + if (spa_streq(interface, "org.freedesktop.ReserveDevice1")) { const char *empty = ""; - if (strcmp(property, "ApplicationName") == 0 && d->application_name) { + if (spa_streq(property, "ApplicationName") && d->application_name) { if (!(reply = dbus_message_new_method_return(m))) goto oom; @@ -159,7 +161,7 @@ static DBusHandlerResult object_handler(DBusConnection *c, DBusMessage *m, void d->application_name ? (const char**) &d->application_name : &empty)) goto oom; - } else if (strcmp(property, "ApplicationDeviceName") == 0) { + } else if (spa_streq(property, "ApplicationDeviceName")) { if (!(reply = dbus_message_new_method_return(m))) goto oom; @@ -168,7 +170,7 @@ static DBusHandlerResult object_handler(DBusConnection *c, DBusMessage *m, void d->application_device_name ? (const char**) &d->application_device_name : &empty)) goto oom; - } else if (strcmp(property, "Priority") == 0) { + } else if (spa_streq(property, "Priority")) { if (!(reply = dbus_message_new_method_return(m))) goto oom; diff --git a/src/examples/media-session/restore-stream.c b/src/examples/media-session/restore-stream.c index c5c373c9c..7a4022b88 100644 --- a/src/examples/media-session/restore-stream.c +++ b/src/examples/media-session/restore-stream.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -126,7 +127,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; @@ -309,21 +310,21 @@ static int restore_stream(struct stream *str) SPA_TYPE_OBJECT_Props, SPA_PARAM_Props); while (spa_json_get_string(&it[1], key, sizeof(key)-1) > 0) { - if (strcmp(key, "volume") == 0) { + if (spa_streq(key, "volume")) { float vol; if (spa_json_get_float(&it[1], &vol) <= 0) continue; spa_pod_builder_prop(&b, SPA_PROP_volume, 0); spa_pod_builder_float(&b, vol); } - else if (strcmp(key, "mute") == 0) { + else if (spa_streq(key, "mute")) { bool mute; if (spa_json_get_bool(&it[1], &mute) <= 0) continue; spa_pod_builder_prop(&b, SPA_PROP_mute, 0); spa_pod_builder_bool(&b, mute); } - else if (strcmp(key, "volumes") == 0) { + else if (spa_streq(key, "volumes")) { uint32_t n_vols; float vols[SPA_AUDIO_MAX_CHANNELS]; @@ -341,7 +342,7 @@ static int restore_stream(struct stream *str) spa_pod_builder_array(&b, sizeof(float), SPA_TYPE_Float, n_vols, vols); } - else if (strcmp(key, "channels") == 0) { + else if (spa_streq(key, "channels")) { uint32_t n_ch; uint32_t map[SPA_AUDIO_MAX_CHANNELS]; @@ -361,7 +362,7 @@ static int restore_stream(struct stream *str) spa_pod_builder_array(&b, sizeof(uint32_t), SPA_TYPE_Id, n_ch, map); } - else if (strcmp(key, "target-node") == 0) { + else if (spa_streq(key, "target-node")) { char name[1024]; if (spa_json_get_string(&it[1], name, sizeof(name)) <= 0) diff --git a/src/examples/media-session/stream-endpoint.c b/src/examples/media-session/stream-endpoint.c index 7d9147dcd..8d44b03fd 100644 --- a/src/examples/media-session/stream-endpoint.c +++ b/src/examples/media-session/stream-endpoint.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -559,7 +560,7 @@ static void session_create(void *data, struct sm_object *object) struct impl *impl = data; int res; - if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0) + if (spa_streq(object->type, PW_TYPE_INTERFACE_Node)) res = handle_node(impl, object); else res = 0; @@ -574,7 +575,7 @@ static void session_remove(void *data, struct sm_object *object) { struct impl *impl = data; - if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0) { + if (spa_streq(object->type, PW_TYPE_INTERFACE_Node)) { struct node *node; if ((node = sm_object_get_data(object, SESSION_KEY)) != NULL) destroy_node(impl, node); diff --git a/src/examples/media-session/suspend-node.c b/src/examples/media-session/suspend-node.c index 74bd25ff5..2fbe83864 100644 --- a/src/examples/media-session/suspend-node.c +++ b/src/examples/media-session/suspend-node.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -206,7 +207,7 @@ static void session_create(void *data, struct sm_object *object) struct impl *impl = data; int res; - if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0) + if (spa_streq(object->type, PW_TYPE_INTERFACE_Node)) res = handle_node(impl, object); else res = 0; @@ -220,7 +221,7 @@ static void session_remove(void *data, struct sm_object *object) struct impl *impl = data; pw_log_debug(NAME " %p: remove global '%d'", impl, object->id); - if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0) { + if (spa_streq(object->type, PW_TYPE_INTERFACE_Node)) { struct node *node; if ((node = sm_object_get_data(object, SESSION_KEY)) != NULL) destroy_node(impl, node); diff --git a/src/examples/media-session/v4l2-endpoint.c b/src/examples/media-session/v4l2-endpoint.c index b7447ef35..be469ff38 100644 --- a/src/examples/media-session/v4l2-endpoint.c +++ b/src/examples/media-session/v4l2-endpoint.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -591,7 +592,7 @@ static void session_create(void *data, struct sm_object *object) struct impl *impl = data; int res; - if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0) + if (spa_streq(object->type, PW_TYPE_INTERFACE_Device)) res = handle_device(impl, object); else res = 0; @@ -606,7 +607,7 @@ static void session_remove(void *data, struct sm_object *object) { struct impl *impl = data; - if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0) { + if (spa_streq(object->type, PW_TYPE_INTERFACE_Device)) { struct device *device; if ((device = sm_object_get_data(object, SESSION_KEY)) != NULL) destroy_device(impl, device); diff --git a/src/examples/media-session/v4l2-monitor.c b/src/examples/media-session/v4l2-monitor.c index 2b2a92ef3..3dfa9f4d8 100644 --- a/src/examples/media-session/v4l2-monitor.c +++ b/src/examples/media-session/v4l2-monitor.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -104,7 +105,7 @@ static struct node *v4l2_find_node(struct device *dev, uint32_t id, const char * return node; if (name != NULL && (str = pw_properties_get(node->props, PW_KEY_NODE_NAME)) != NULL && - strcmp(name, str) == 0) + spa_streq(name, str)) return node; } return NULL; @@ -274,7 +275,7 @@ static struct device *v4l2_find_device(struct impl *impl, uint32_t id, const cha return dev; if (name != NULL && (str = pw_properties_get(dev->props, PW_KEY_DEVICE_NAME)) != NULL && - strcmp(str, name) == 0) + spa_streq(str, name)) return dev; } return NULL; diff --git a/src/gst/gstpipewiredeviceprovider.c b/src/gst/gstpipewiredeviceprovider.c index 95488ffa0..373004b78 100644 --- a/src/gst/gstpipewiredeviceprovider.c +++ b/src/gst/gstpipewiredeviceprovider.c @@ -29,6 +29,7 @@ #include #include +#include #include @@ -455,7 +456,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, struct node_data *nd; const char *str; - if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) { + if (spa_streq(type, PW_TYPE_INTERFACE_Node)) { struct pw_node *node; node = pw_registry_bind(rd->registry, @@ -482,7 +483,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, pw_proxy_add_listener((struct pw_proxy*)node, &nd->proxy_listener, &proxy_node_events, nd); resync(self); } - else if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) { + else if (spa_streq(type, PW_TYPE_INTERFACE_Port)) { struct pw_port *port; struct port_data *pd; diff --git a/src/modules/module-access.c b/src/modules/module-access.c index 1a87ff016..cc7b06aa0 100644 --- a/src/modules/module-access.c +++ b/src/modules/module-access.c @@ -40,6 +40,7 @@ #endif #include +#include #include #include @@ -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; } diff --git a/src/modules/module-adapter/adapter.c b/src/modules/module-adapter/adapter.c index ee389441d..4c433091b 100644 --- a/src/modules/module-adapter/adapter.c +++ b/src/modules/module-adapter/adapter.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -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; } diff --git a/src/modules/module-echo-cancel.c b/src/modules/module-echo-cancel.c index c4b58d1a3..3be731e03 100644 --- a/src/modules/module-echo-cancel.c +++ b/src/modules/module-echo-cancel.c @@ -33,6 +33,7 @@ #include "config.h" #include +#include #include #include #include @@ -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; diff --git a/src/modules/module-filter-chain.c b/src/modules/module-filter-chain.c index 96b88e4a7..10a6db508 100644 --- a/src/modules/module-filter-chain.c +++ b/src/modules/module-filter-chain.c @@ -36,6 +36,7 @@ #include "module-filter-chain/ladspa.h" #include +#include #include #include #include @@ -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; diff --git a/src/modules/module-link-factory.c b/src/modules/module-link-factory.c index f057dfda1..44382c68c 100644 --- a/src/modules/module-link-factory.c +++ b/src/modules/module-link-factory.c @@ -30,6 +30,7 @@ #include "config.h" #include +#include #include @@ -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: diff --git a/src/modules/module-loopback.c b/src/modules/module-loopback.c index af587ddab..21e8fb810 100644 --- a/src/modules/module-loopback.c +++ b/src/modules/module-loopback.c @@ -33,6 +33,7 @@ #include "config.h" #include +#include #include #include #include @@ -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; diff --git a/src/modules/module-portal.c b/src/modules/module-portal.c index 93ad59b26..c6e632114 100644 --- a/src/modules/module-portal.c +++ b/src/modules/module-portal.c @@ -35,6 +35,7 @@ #include +#include #include #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); diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c index d5aa549ac..23b29e5f0 100644 --- a/src/modules/module-protocol-native.c +++ b/src/modules/module-protocol-native.c @@ -44,6 +44,7 @@ #include #include +#include #ifdef HAVE_SYSTEMD #include @@ -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) diff --git a/src/modules/module-protocol-native/v0/protocol-native.c b/src/modules/module-protocol-native/v0/protocol-native.c index d4d069779..20efcc444 100644 --- a/src/modules/module-protocol-native/v0/protocol-native.c +++ b/src/modules/module-protocol-native/v0/protocol-native.c @@ -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; /* :[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); } diff --git a/src/modules/module-protocol-pulse/collect.c b/src/modules/module-protocol-pulse/collect.c index eca270c83..9bdd4b401 100644 --- a/src/modules/module-protocol-pulse/collect.c +++ b/src/modules/module-protocol-pulse/collect.c @@ -22,6 +22,8 @@ * DEALINGS IN THE SOFTWARE. */ +#include + 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; } diff --git a/src/modules/module-protocol-pulse/ext-stream-restore.c b/src/modules/module-protocol-pulse/ext-stream-restore.c index e7b75f52c..fd5b2cdbc 100644 --- a/src/modules/module-protocol-pulse/ext-stream-restore.c +++ b/src/modules/module-protocol-pulse/ext-stream-restore.c @@ -24,6 +24,8 @@ #define EXT_STREAM_RESTORE_VERSION 1 +#include + 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; } diff --git a/src/modules/module-protocol-pulse/extension.c b/src/modules/module-protocol-pulse/extension.c index 56987e39a..fdcbad081 100644 --- a/src/modules/module-protocol-pulse/extension.c +++ b/src/modules/module-protocol-pulse/extension.c @@ -22,6 +22,8 @@ * DEALINGS IN THE SOFTWARE. */ +#include + 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; diff --git a/src/modules/module-protocol-pulse/format.c b/src/modules/module-protocol-pulse/format.c index 85a7badc3..6145e7bd8 100644 --- a/src/modules/module-protocol-pulse/format.c +++ b/src/modules/module-protocol-pulse/format.c @@ -24,6 +24,8 @@ #include "format.h" +#include + 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, diff --git a/src/modules/module-protocol-pulse/manager.c b/src/modules/module-protocol-pulse/manager.c index c5285f84b..da567f0e5 100644 --- a/src/modules/module-protocol-pulse/manager.c +++ b/src/modules/module-protocol-pulse/manager.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #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); } diff --git a/src/modules/module-protocol-pulse/message-handler.c b/src/modules/module-protocol-pulse/message-handler.c index fedb60762..706d75f47 100644 --- a/src/modules/module-protocol-pulse/message-handler.c +++ b/src/modules/module-protocol-pulse/message-handler.c @@ -1,3 +1,5 @@ +#include + 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); diff --git a/src/modules/module-protocol-pulse/message.c b/src/modules/module-protocol-pulse/message.c index 6626452ff..545b5882a 100644 --- a/src/modules/module-protocol-pulse/message.c +++ b/src/modules/module-protocol-pulse/message.c @@ -22,6 +22,8 @@ * DEALINGS IN THE SOFTWARE. */ +#include + #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); diff --git a/src/modules/module-protocol-pulse/module.c b/src/modules/module-protocol-pulse/module.c index 4de725726..c5dcc7b39 100644 --- a/src/modules/module-protocol-pulse/module.c +++ b/src/modules/module-protocol-pulse/module.c @@ -25,6 +25,8 @@ #include "module.h" +#include + 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; diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index d0f2862ec..75ca51cc8 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -62,6 +62,7 @@ #include #include +#include #include #include #include @@ -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 diff --git a/src/modules/module-protocol-simple.c b/src/modules/module-protocol-simple.c index 568fc5619..d5bdb4ab4 100644 --- a/src/modules/module-protocol-simple.c +++ b/src/modules/module-protocol-simple.c @@ -39,6 +39,7 @@ #include "config.h" #include +#include #include #include #include @@ -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; diff --git a/src/modules/module-pulse-tunnel.c b/src/modules/module-pulse-tunnel.c index 67079005d..c7bceee79 100644 --- a/src/modules/module-pulse-tunnel.c +++ b/src/modules/module-pulse-tunnel.c @@ -37,6 +37,7 @@ #include "config.h" #include +#include #include #include #include @@ -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); diff --git a/src/modules/module-rtkit.c b/src/modules/module-rtkit.c index 9f850048c..addb2dcaf 100644 --- a/src/modules/module-rtkit.c +++ b/src/modules/module-rtkit.c @@ -41,6 +41,7 @@ #include #include +#include #include @@ -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; diff --git a/src/modules/module-zeroconf-discover.c b/src/modules/module-zeroconf-discover.c index 6b965395d..d45d17a89 100644 --- a/src/modules/module-zeroconf-discover.c +++ b/src/modules/module-zeroconf-discover.c @@ -33,6 +33,7 @@ #include "config.h" #include +#include #include #include @@ -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); diff --git a/src/pipewire/conf.c b/src/pipewire/conf.c index c1a8bdeed..50bb65980 100644 --- a/src/pipewire/conf.c +++ b/src/pipewire/conf.c @@ -41,6 +41,7 @@ #endif #include +#include #include #include @@ -356,16 +357,16 @@ static int parse_modules(struct pw_context *context, char *str) if ((len = spa_json_next(&it[2], &val)) <= 0) break; - if (strcmp(key, "name") == 0) { + if (spa_streq(key, "name")) { name = (char*)val; spa_json_parse_string(val, len, name); - } else if (strcmp(key, "args") == 0) { + } else if (spa_streq(key, "args")) { if (spa_json_is_container(val, len)) len = spa_json_container_len(&it[2], val, len); args = (char*)val; spa_json_parse_string(val, len, args); - } else if (strcmp(key, "flags") == 0) { + } else if (spa_streq(key, "flags")) { if (spa_json_is_container(val, len)) len = spa_json_container_len(&it[2], val, len); flags = (char*)val; @@ -438,16 +439,16 @@ static int parse_objects(struct pw_context *context, char *str) if ((len = spa_json_next(&it[2], &val)) <= 0) break; - if (strcmp(key, "factory") == 0) { + if (spa_streq(key, "factory")) { factory = (char*)val; spa_json_parse_string(val, len, factory); - } else if (strcmp(key, "args") == 0) { + } else if (spa_streq(key, "args")) { if (spa_json_is_container(val, len)) len = spa_json_container_len(&it[2], val, len); args = (char*)val; spa_json_parse_string(val, len, args); - } else if (strcmp(key, "flags") == 0) { + } else if (spa_streq(key, "flags")) { if (spa_json_is_container(val, len)) len = spa_json_container_len(&it[2], val, len); @@ -523,10 +524,10 @@ static int parse_exec(struct pw_context *context, char *str) if ((len = spa_json_next(&it[2], &val)) <= 0) break; - if (strcmp(key, "path") == 0) { + if (spa_streq(key, "path")) { path = (char*)val; spa_json_parse_string(val, len, path); - } else if (strcmp(key, "args") == 0) { + } else if (spa_streq(key, "args")) { args = (char*)val; spa_json_parse_string(val, len, args); } @@ -555,13 +556,13 @@ int pw_context_parse_conf_section(struct pw_context *context, s = strdup(str); - if (strcmp(section, "context.spa-libs") == 0) + if (spa_streq(section, "context.spa-libs")) res = parse_spa_libs(context, s); - else if (strcmp(section, "context.modules") == 0) + else if (spa_streq(section, "context.modules")) res = parse_modules(context, s); - else if (strcmp(section, "context.objects") == 0) + else if (spa_streq(section, "context.objects")) res = parse_objects(context, s); - else if (strcmp(section, "context.exec") == 0) + else if (spa_streq(section, "context.exec")) res = parse_exec(context, s); else res = -EINVAL; diff --git a/src/pipewire/context.c b/src/pipewire/context.c index bc82873fd..4619bb437 100644 --- a/src/pipewire/context.c +++ b/src/pipewire/context.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -168,7 +169,7 @@ static int try_load_conf(struct pw_context *this, const char *conf_prefix, if (conf_name == NULL) return -EINVAL; - if (strcmp(conf_name, "null") == 0) + if (spa_streq(conf_name, "null")) return 0; if ((res = pw_conf_load_conf(conf_prefix, conf_name, conf)) < 0) { pw_log_warn(NAME" %p: can't load config %s%s%s: %s", @@ -1178,7 +1179,7 @@ const struct pw_export_type *pw_context_find_export_type(struct pw_context *cont { const struct pw_export_type *t; spa_list_for_each(t, &context->export_list, link) { - if (strcmp(t->type, type) == 0) + if (spa_streq(t->type, type)) return t; } return NULL; @@ -1193,7 +1194,7 @@ static struct object_entry *find_object(struct pw_context *context, const char * { struct object_entry *entry; pw_array_for_each(entry, &context->objects) { - if (strcmp(entry->type, type) == 0) + if (spa_streq(entry->type, type)) return entry; } return NULL; diff --git a/src/pipewire/global.c b/src/pipewire/global.c index 2a0b1d9ac..6a6c7b82d 100644 --- a/src/pipewire/global.c +++ b/src/pipewire/global.c @@ -31,6 +31,7 @@ #include #include +#include #define NAME "global" @@ -192,7 +193,7 @@ const char * pw_global_get_type(struct pw_global *global) SPA_EXPORT bool pw_global_is_type(struct pw_global *global, const char *type) { - return strcmp(global->type, type) == 0; + return spa_streq(global->type, type); } SPA_EXPORT diff --git a/src/pipewire/impl-client.c b/src/pipewire/impl-client.c index 0d9dcc31f..33a51bd22 100644 --- a/src/pipewire/impl-client.c +++ b/src/pipewire/impl-client.c @@ -25,6 +25,8 @@ #include #include +#include + #include "pipewire/impl.h" #include "pipewire/private.h" @@ -137,7 +139,7 @@ static bool has_key(const char *keys[], const char *key) { int i; for (i = 0; keys[i]; i++) { - if (strcmp(keys[i], key) == 0) + if (spa_streq(keys[i], key)) return true; } return false; diff --git a/src/pipewire/impl-device.c b/src/pipewire/impl-device.c index f8bf75538..2d7d13e19 100644 --- a/src/pipewire/impl-device.c +++ b/src/pipewire/impl-device.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "pipewire/impl.h" #include "pipewire/private.h" @@ -798,7 +799,7 @@ static void device_add_object(struct pw_impl_device *device, uint32_t id, if (info->props && props) pw_properties_update(props, info->props); - if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) == 0) { + if (spa_streq(info->type, SPA_TYPE_INTERFACE_Node)) { struct pw_impl_node *node; node = pw_context_create_node(context, props, sizeof(struct object_data)); @@ -807,7 +808,7 @@ static void device_add_object(struct pw_impl_device *device, uint32_t id, od->type = OBJECT_NODE; pw_impl_node_add_listener(node, &od->listener, &node_object_events, od); pw_impl_node_set_implementation(node, iface); - } else if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) == 0) { + } else if (spa_streq(info->type, SPA_TYPE_INTERFACE_Device)) { struct pw_impl_device *dev; dev = pw_context_create_device(context, props, sizeof(struct object_data)); diff --git a/src/pipewire/impl-factory.c b/src/pipewire/impl-factory.c index c5389c5fb..6b911d8de 100644 --- a/src/pipewire/impl-factory.c +++ b/src/pipewire/impl-factory.c @@ -25,6 +25,7 @@ #include #include +#include #include "pipewire/impl.h" #include "pipewire/private.h" @@ -290,7 +291,7 @@ struct pw_impl_factory *pw_context_find_factory(struct pw_context *context, struct pw_impl_factory *factory; spa_list_for_each(factory, &context->factory_list, link) { - if (strcmp(factory->info.name, name) == 0) + if (spa_streq(factory->info.name, name)) return factory; } return NULL; diff --git a/src/pipewire/impl-module.c b/src/pipewire/impl-module.c index ab6d7d96c..c118ffb82 100644 --- a/src/pipewire/impl-module.c +++ b/src/pipewire/impl-module.c @@ -33,6 +33,8 @@ #include #include +#include + #include "pipewire/impl.h" #include "pipewire/private.h" @@ -82,7 +84,7 @@ static char *find_module(const char *path, const char *name) while ((entry = readdir(dir))) { char *newpath; - if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) + if (spa_streq(entry->d_name, ".") || spa_streq(entry->d_name, "..")) continue; newpath = spa_aprintf("%s/%s", path, entry->d_name); diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index b1af8e7ee..57db6f3b2 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "pipewire/impl-node.h" #include "pipewire/private.h" @@ -864,7 +865,7 @@ static void check_properties(struct pw_impl_node *node) if (strcmp(str, node->group) != 0) { pw_log_info(NAME" %p: group '%s'->'%s'", node, node->group, str); snprintf(node->group, sizeof(node->group), "%s", str); - node->freewheel = strcmp(node->group, "pipewire.freewheel") == 0; + node->freewheel = spa_streq(node->group, "pipewire.freewheel"); recalc_reason = "group changed"; } diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c index e81662c1b..16ec120ed 100644 --- a/src/pipewire/pipewire.c +++ b/src/pipewire/pipewire.c @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -186,7 +187,7 @@ static const struct spa_handle_factory *find_factory(struct plugin *plugin, cons factory->version); continue; } - if (strcmp(factory->name, factory_name) == 0) + if (spa_streq(factory->name, factory_name)) return factory; } res = -ENOENT; @@ -451,7 +452,7 @@ static struct spa_log *load_journal_logger(struct support *support) /* look for an existing logger, and * replace it with the journal logger */ for (i = 0; i < support->n_support; i++) { - if (strcmp(support->support[i].type, SPA_TYPE_INTERFACE_Log) == 0) { + if (spa_streq(support->support[i].type, SPA_TYPE_INTERFACE_Log)) { support->support[i].data = iface; break; } @@ -525,7 +526,7 @@ void pw_init(int *argc, char **argv[]) #ifdef HAVE_SYSTEMD if ((str = getenv("PIPEWIRE_LOG_SYSTEMD")) == NULL || - strcmp(str, "true") == 0 || atoi(str) != 0) { + spa_streq(str, "true") || atoi(str) != 0) { log = load_journal_logger(support); if (log) pw_log_set(log); @@ -592,7 +593,7 @@ bool pw_debug_is_category_enabled(const char *name) return false; for (i = 0; global_support.categories[i]; i++) { - if (strcmp(global_support.categories[i], name) == 0) + if (spa_streq(global_support.categories[i], name)) return true; } return false; diff --git a/src/pipewire/properties.c b/src/pipewire/properties.c index f9633c4cc..3fedd3beb 100644 --- a/src/pipewire/properties.c +++ b/src/pipewire/properties.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "pipewire/array.h" #include "pipewire/utils.h" @@ -252,7 +253,7 @@ static bool has_key(const char *keys[], const char *key) { int i; for (i = 0; keys[i]; i++) { - if (strcmp(keys[i], key) == 0) + if (spa_streq(keys[i], key)) return true; } return false; @@ -401,7 +402,7 @@ static int do_replace(struct pw_properties *properties, const char *key, char *v struct spa_dict_item *item = pw_array_get_unchecked(&impl->items, index, struct spa_dict_item); - if (value && strcmp(item->value, value) == 0) + if (value && spa_streq(item->value, value)) goto exit_noupdate; if (value == NULL) { diff --git a/src/pipewire/protocol.c b/src/pipewire/protocol.c index dea427521..5bf8ae3c1 100644 --- a/src/pipewire/protocol.c +++ b/src/pipewire/protocol.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -164,7 +165,7 @@ pw_protocol_get_marshal(struct pw_protocol *protocol, const char *type, uint32_t struct marshal *impl; spa_list_for_each(impl, &protocol->marshal_list, link) { - if (strcmp(impl->marshal->type, type) == 0 && + if (spa_streq(impl->marshal->type, type) && impl->marshal->version == version && (impl->marshal->flags & flags) == flags) return impl->marshal; @@ -180,7 +181,7 @@ struct pw_protocol *pw_context_find_protocol(struct pw_context *context, const c struct pw_protocol *protocol; spa_list_for_each(protocol, &context->protocol_list, link) { - if (strcmp(protocol->name, name) == 0) + if (spa_streq(protocol->name, name)) return protocol; } return NULL; diff --git a/src/tools/midifile.c b/src/tools/midifile.c index 62cbd0ca0..204bd1de2 100644 --- a/src/tools/midifile.c +++ b/src/tools/midifile.c @@ -29,6 +29,8 @@ #include #include +#include + #include "midifile.h" #define DEFAULT_TEMPO 500000 /* 500ms per quarter note (120 BPM) is the default */ @@ -263,10 +265,10 @@ midi_file_open(const char *filename, const char *mode, struct midi_file_info *in if (mf == NULL) return NULL; - if (strcmp(mode, "r") == 0) { + if (spa_streq(mode, "r")) { if ((res = open_read(mf, filename, info)) < 0) goto exit_free; - } else if (strcmp(mode, "w") == 0) { + } else if (spa_streq(mode, "w")) { if ((res = open_write(mf, filename, info)) < 0) goto exit_free; } else { diff --git a/src/tools/pw-cat.c b/src/tools/pw-cat.c index 7d0fcfa71..e0947e226 100644 --- a/src/tools/pw-cat.c +++ b/src/tools/pw-cat.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -495,7 +496,7 @@ static unsigned int find_channel(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; @@ -507,7 +508,7 @@ static int parse_channelmap(const char *channel_map, struct channelmap *map) char **ch; for (i = 0; i < (int) SPA_N_ELEMENTS(maps); i++) { - if (strcmp(maps[i].name, channel_map) == 0) { + if (spa_streq(maps[i].name, channel_map)) { map->n_channels = maps[i].channels; spa_memcpy(map->channels, &maps[i].values, map->n_channels * sizeof(unsigned int)); @@ -659,7 +660,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; @@ -677,13 +678,13 @@ static int metadata_property(void *object, struct data *data = object; if (subject == PW_ID_CORE) { - if (key == NULL || strcmp(key, "default.audio.sink") == 0) { + if (key == NULL || spa_streq(key, "default.audio.sink")) { if (value == NULL || json_object_find(value, "name", data->default_sink, sizeof(data->default_sink)) < 0) data->default_sink[0] = '\0'; } - if (key == NULL || strcmp(key, "default.audio.source") == 0) { + if (key == NULL || spa_streq(key, "default.audio.source")) { if (value == NULL || json_object_find(value, "name", data->default_source, sizeof(data->default_source)) < 0) @@ -717,7 +718,7 @@ static void registry_event_global(void *userdata, uint32_t id, if (!data->list_targets) return; - if (strcmp(type, PW_TYPE_INTERFACE_Metadata) == 0) { + if (spa_streq(type, PW_TYPE_INTERFACE_Metadata)) { if (data->metadata != NULL) return; @@ -729,7 +730,7 @@ static void registry_event_global(void *userdata, uint32_t id, data->sync = pw_core_sync(data->core, 0, data->sync); - } else if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) { + } else if (spa_streq(type, PW_TYPE_INTERFACE_Node)) { name = spa_dict_lookup(props, PW_KEY_NODE_NAME); desc = spa_dict_lookup(props, PW_KEY_NODE_DESCRIPTION); media_class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS); @@ -1714,7 +1715,7 @@ int main(int argc, char *argv[]) target_default = NULL; spa_list_for_each(target, &data.targets, link) { if (target_default == NULL || - strcmp(default_name, target->name) == 0 || + spa_streq(default_name, target->name) || (default_name[0] == '\0' && target->prio > target_default->prio)) target_default = target; diff --git a/src/tools/pw-cli.c b/src/tools/pw-cli.c index 2ccf88ed8..e7e2e455f 100644 --- a/src/tools/pw-cli.c +++ b/src/tools/pw-cli.c @@ -36,6 +36,7 @@ #define spa_debug(...) fprintf(stdout,__VA_ARGS__);fputc('\n', stdout) #include +#include #include #include #include @@ -1129,57 +1130,57 @@ static bool bind_global(struct remote_data *rd, struct global *global, char **er struct proxy_data *pd; struct pw_proxy *proxy; - if (strcmp(global->type, PW_TYPE_INTERFACE_Core) == 0) { + if (spa_streq(global->type, PW_TYPE_INTERFACE_Core)) { events = &core_events; client_version = PW_VERSION_CORE; destroy = (pw_destroy_t) pw_core_info_free; info_func = info_core; - } else if (strcmp(global->type, PW_TYPE_INTERFACE_Module) == 0) { + } else if (spa_streq(global->type, PW_TYPE_INTERFACE_Module)) { events = &module_events; client_version = PW_VERSION_MODULE; destroy = (pw_destroy_t) pw_module_info_free; info_func = info_module; - } else if (strcmp(global->type, PW_TYPE_INTERFACE_Device) == 0) { + } else if (spa_streq(global->type, PW_TYPE_INTERFACE_Device)) { events = &device_events; client_version = PW_VERSION_DEVICE; destroy = (pw_destroy_t) pw_device_info_free; info_func = info_device; - } else if (strcmp(global->type, PW_TYPE_INTERFACE_Node) == 0) { + } else if (spa_streq(global->type, PW_TYPE_INTERFACE_Node)) { events = &node_events; client_version = PW_VERSION_NODE; destroy = (pw_destroy_t) pw_node_info_free; info_func = info_node; - } else if (strcmp(global->type, PW_TYPE_INTERFACE_Port) == 0) { + } else if (spa_streq(global->type, PW_TYPE_INTERFACE_Port)) { events = &port_events; client_version = PW_VERSION_PORT; destroy = (pw_destroy_t) pw_port_info_free; info_func = info_port; - } else if (strcmp(global->type, PW_TYPE_INTERFACE_Factory) == 0) { + } else if (spa_streq(global->type, PW_TYPE_INTERFACE_Factory)) { events = &factory_events; client_version = PW_VERSION_FACTORY; destroy = (pw_destroy_t) pw_factory_info_free; info_func = info_factory; - } else if (strcmp(global->type, PW_TYPE_INTERFACE_Client) == 0) { + } else if (spa_streq(global->type, PW_TYPE_INTERFACE_Client)) { events = &client_events; client_version = PW_VERSION_CLIENT; destroy = (pw_destroy_t) pw_client_info_free; info_func = info_client; - } else if (strcmp(global->type, PW_TYPE_INTERFACE_Link) == 0) { + } else if (spa_streq(global->type, PW_TYPE_INTERFACE_Link)) { events = &link_events; client_version = PW_VERSION_LINK; destroy = (pw_destroy_t) pw_link_info_free; info_func = info_link; - } else if (strcmp(global->type, PW_TYPE_INTERFACE_Session) == 0) { + } else if (spa_streq(global->type, PW_TYPE_INTERFACE_Session)) { events = &session_events; client_version = PW_VERSION_SESSION; destroy = (pw_destroy_t) session_info_free; info_func = info_session; - } else if (strcmp(global->type, PW_TYPE_INTERFACE_Endpoint) == 0) { + } else if (spa_streq(global->type, PW_TYPE_INTERFACE_Endpoint)) { events = &endpoint_events; client_version = PW_VERSION_ENDPOINT; destroy = (pw_destroy_t) endpoint_info_free; info_func = info_endpoint; - } else if (strcmp(global->type, PW_TYPE_INTERFACE_EndpointStream) == 0) { + } else if (spa_streq(global->type, PW_TYPE_INTERFACE_EndpointStream)) { events = &endpoint_stream_events; client_version = PW_VERSION_ENDPOINT_STREAM; destroy = (pw_destroy_t) endpoint_stream_info_free; @@ -1255,7 +1256,7 @@ static bool do_info(struct data *data, const char *cmd, char *args, char **error *error = spa_aprintf("%s |all", cmd); return false; } - if (strcmp(a[0], "all") == 0) { + if (spa_streq(a[0], "all")) { pw_map_for_each(&rd->globals, do_global_info_all, NULL); } else { @@ -1469,9 +1470,9 @@ static bool do_export_node(struct data *data, const char *cmd, char *args, char static const struct spa_type_info *find_type_info(const struct spa_type_info *info, const char *name) { while (info && info->name) { - if (strcmp(info->name, name) == 0) + if (spa_streq(info->name, name)) return info; - if (strcmp(spa_debug_type_short_name(info->name), name) == 0) + if (spa_streq(spa_debug_type_short_name(info->name), name)) return info; if (info->type != 0 && info->type == (uint32_t)atoi(name)) return info; @@ -1513,16 +1514,16 @@ static bool do_enum_params(struct data *data, const char *cmd, char *args, char return false; } - if (strcmp(global->type, PW_TYPE_INTERFACE_Node) == 0) + if (spa_streq(global->type, PW_TYPE_INTERFACE_Node)) pw_node_enum_params((struct pw_node*)global->proxy, 0, param_id, 0, 0, NULL); - else if (strcmp(global->type, PW_TYPE_INTERFACE_Port) == 0) + else if (spa_streq(global->type, PW_TYPE_INTERFACE_Port)) pw_port_enum_params((struct pw_port*)global->proxy, 0, param_id, 0, 0, NULL); - else if (strcmp(global->type, PW_TYPE_INTERFACE_Device) == 0) + else if (spa_streq(global->type, PW_TYPE_INTERFACE_Device)) pw_device_enum_params((struct pw_device*)global->proxy, 0, param_id, 0, 0, NULL); - else if (strcmp(global->type, PW_TYPE_INTERFACE_Endpoint) == 0) + else if (spa_streq(global->type, PW_TYPE_INTERFACE_Endpoint)) pw_endpoint_enum_params((struct pw_endpoint*)global->proxy, 0, param_id, 0, 0, NULL); else { @@ -1696,13 +1697,13 @@ static bool do_set_param(struct data *data, const char *cmd, char *args, char ** } spa_debug_pod(0, NULL, pod); - if (strcmp(global->type, PW_TYPE_INTERFACE_Node) == 0) + if (spa_streq(global->type, PW_TYPE_INTERFACE_Node)) pw_node_set_param((struct pw_node*)global->proxy, param_id, 0, pod); - else if (strcmp(global->type, PW_TYPE_INTERFACE_Device) == 0) + else if (spa_streq(global->type, PW_TYPE_INTERFACE_Device)) pw_device_set_param((struct pw_device*)global->proxy, param_id, 0, pod); - else if (strcmp(global->type, PW_TYPE_INTERFACE_Endpoint) == 0) + else if (spa_streq(global->type, PW_TYPE_INTERFACE_Endpoint)) pw_endpoint_set_param((struct pw_endpoint*)global->proxy, param_id, 0, pod); else { diff --git a/src/tools/pw-dot.c b/src/tools/pw-dot.c index ec1a81f28..95d75e3cb 100644 --- a/src/tools/pw-dot.c +++ b/src/tools/pw-dot.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -505,7 +506,7 @@ static int draw_graph(struct data *d, const char *path) /* draw the footer */ dot_str_add(&d->dot_str, "}\n"); - if (strcmp(path, "-") == 0) { + if (spa_streq(path, "-")) { /* wire the dot graph into to stdout */ fputs(d->dot_str, stdout); } else { @@ -634,7 +635,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, draw_t draw; struct global *g; - if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) { + if (spa_streq(type, PW_TYPE_INTERFACE_Port)) { events = &port_events; info_destroy = (pw_destroy_t)pw_port_info_free; info_update = (info_update_t)pw_port_info_update; @@ -642,7 +643,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, client_version = PW_VERSION_PORT; object_type = INTERFACE_Port; } - else if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) { + else if (spa_streq(type, PW_TYPE_INTERFACE_Node)) { events = &node_events; info_destroy = (pw_destroy_t)pw_node_info_free; info_update = (info_update_t)pw_node_info_update; @@ -650,7 +651,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, client_version = PW_VERSION_NODE; object_type = INTERFACE_Node; } - else if (strcmp(type, PW_TYPE_INTERFACE_Link) == 0) { + else if (spa_streq(type, PW_TYPE_INTERFACE_Link)) { events = &link_events; info_destroy = (pw_destroy_t)pw_link_info_free; info_update = (info_update_t)pw_link_info_update; @@ -658,7 +659,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, client_version = PW_VERSION_LINK; object_type = INTERFACE_Link; } - else if (strcmp(type, PW_TYPE_INTERFACE_Client) == 0) { + else if (spa_streq(type, PW_TYPE_INTERFACE_Client)) { events = &client_events; info_destroy = (pw_destroy_t)pw_client_info_free; info_update = (info_update_t)pw_client_info_update; @@ -666,7 +667,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, client_version = PW_VERSION_CLIENT; object_type = INTERFACE_Client; } - else if (strcmp(type, PW_TYPE_INTERFACE_Device) == 0) { + else if (spa_streq(type, PW_TYPE_INTERFACE_Device)) { events = &device_events; info_destroy = (pw_destroy_t)pw_device_info_free; info_update = (info_update_t)pw_device_info_update; @@ -674,7 +675,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, client_version = PW_VERSION_DEVICE; object_type = INTERFACE_Device; } - else if (strcmp(type, PW_TYPE_INTERFACE_Factory) == 0) { + else if (spa_streq(type, PW_TYPE_INTERFACE_Factory)) { events = &factory_events; info_destroy = (pw_destroy_t)pw_factory_info_free; info_update = (info_update_t)pw_factory_info_update; @@ -682,7 +683,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, client_version = PW_VERSION_FACTORY; object_type = INTERFACE_Factory; } - else if (strcmp(type, PW_TYPE_INTERFACE_Module) == 0) { + else if (spa_streq(type, PW_TYPE_INTERFACE_Module)) { events = &module_events; info_destroy = (pw_destroy_t)pw_module_info_free; info_update = (info_update_t)pw_module_info_update; @@ -690,7 +691,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, client_version = PW_VERSION_MODULE; object_type = INTERFACE_Module; } - else if (strcmp(type, PW_TYPE_INTERFACE_Core) == 0) { + else if (spa_streq(type, PW_TYPE_INTERFACE_Core)) { /* sync to notify we are done with globals */ pw_core_sync(d->core, 0, 0); return; diff --git a/src/tools/pw-dump.c b/src/tools/pw-dump.c index c0ac81523..d33baf992 100644 --- a/src/tools/pw-dump.c +++ b/src/tools/pw-dump.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -280,8 +281,8 @@ static void put_value(struct data *d, const char *key, const char *val) if (val == NULL) put_literal(d, key, "null"); - else if (strcmp(val, "true") == 0 || - strcmp(val, "false") == 0) + else if (spa_streq(val, "true") || + spa_streq(val, "false")) put_literal(d, key, val); else if ((li = strtol(val, &end, 10)) != LONG_MIN && errno != -ERANGE && *end == '\0') @@ -1109,7 +1110,7 @@ static void metadata_dump(struct object *o) put_int(d, "subject", e->subject); put_value(d, "key", e->key); put_value(d, "type", e->type); - if (e->type != NULL && strcmp(e->type, "Spa:String:JSON") == 0) + if (e->type != NULL && spa_streq(e->type, "Spa:String:JSON")) json_dump(d, "value", e->value); else put_value(d, "value", e->value); @@ -1124,7 +1125,7 @@ static struct metadata_entry *metadata_find(struct object *o, uint32_t subject, struct metadata_entry *e; spa_list_for_each(e, &o->data_list, link) { if ((e->subject == subject) && - (key == NULL || strcmp(e->key, key) == 0)) + (key == NULL || spa_streq(e->key, key))) return e; } return NULL; @@ -1208,7 +1209,7 @@ static const struct class *find_class(const char *type, uint32_t version) { size_t i; for (i = 0; i < SPA_N_ELEMENTS(classes); i++) { - if (strcmp(classes[i]->type, type) == 0 && + if (spa_streq(classes[i]->type, type) && classes[i]->version <= version) return classes[i]; } diff --git a/src/tools/pw-link.c b/src/tools/pw-link.c index 73f4cfddb..b1a4bf20f 100644 --- a/src/tools/pw-link.c +++ b/src/tools/pw-link.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -245,11 +246,11 @@ static int port_matches(struct data *data, struct object *n, struct object *p, c uint32_t id = atoi(name); if (p->id == id) return 1; - if (strcmp(port_name(buffer, sizeof(buffer), n, p), name) == 0) + if (spa_streq(port_name(buffer, sizeof(buffer), n, p), name)) return 1; - if (strcmp(port_path(buffer, sizeof(buffer), n, p), name) == 0) + if (spa_streq(port_path(buffer, sizeof(buffer), n, p), name)) return 1; - if (strcmp(port_alias(buffer, sizeof(buffer), n, p), name) == 0) + if (spa_streq(port_alias(buffer, sizeof(buffer), n, p), name)) return 1; return 0; } @@ -444,22 +445,22 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, return; spa_zero(extra); - if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) { + if (spa_streq(type, PW_TYPE_INTERFACE_Node)) { t = OBJECT_NODE; - } else if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) { + } else if (spa_streq(type, PW_TYPE_INTERFACE_Port)) { t = OBJECT_PORT; if ((str = spa_dict_lookup(props, PW_KEY_PORT_DIRECTION)) == NULL) return; - if (strcmp(str, "in") == 0) + if (spa_streq(str, "in")) extra[0] = PW_DIRECTION_INPUT; - else if (strcmp(str, "out") == 0) + else if (spa_streq(str, "out")) extra[0] = PW_DIRECTION_OUTPUT; else return; if ((str = spa_dict_lookup(props, PW_KEY_NODE_ID)) == NULL) return; extra[1] = atoi(str); - } else if (strcmp(type, PW_TYPE_INTERFACE_Link) == 0) { + } else if (spa_streq(type, PW_TYPE_INTERFACE_Link)) { t = OBJECT_LINK; if ((str = spa_dict_lookup(props, PW_KEY_LINK_OUTPUT_PORT)) == NULL) return; diff --git a/src/tools/pw-metadata.c b/src/tools/pw-metadata.c index 562958b32..89f42d414 100644 --- a/src/tools/pw-metadata.c +++ b/src/tools/pw-metadata.c @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -67,7 +68,7 @@ static int metadata_property(void *data, uint32_t id, struct data *d = data; if ((d->opt_id == SPA_ID_INVALID || d->opt_id == id) && - (d->opt_key == NULL || strcmp(d->opt_key, key) == 0)) { + (d->opt_key == NULL || spa_streq(d->opt_key, key))) { if (key == NULL) { fprintf(stdout, "remove: id:%u all keys\n", id); } else if (value == NULL) { diff --git a/src/tools/pw-mon.c b/src/tools/pw-mon.c index 7a21b4f87..eb557a75e 100644 --- a/src/tools/pw-mon.c +++ b/src/tools/pw-mon.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -576,34 +577,34 @@ static void registry_event_global(void *data, uint32_t id, pw_destroy_t destroy; print_func_t print_func = NULL; - if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) { + if (spa_streq(type, PW_TYPE_INTERFACE_Node)) { events = &node_events; client_version = PW_VERSION_NODE; destroy = (pw_destroy_t) pw_node_info_free; print_func = print_node; - } else if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) { + } else if (spa_streq(type, PW_TYPE_INTERFACE_Port)) { events = &port_events; client_version = PW_VERSION_PORT; destroy = (pw_destroy_t) pw_port_info_free; print_func = print_port; - } else if (strcmp(type, PW_TYPE_INTERFACE_Module) == 0) { + } else if (spa_streq(type, PW_TYPE_INTERFACE_Module)) { events = &module_events; client_version = PW_VERSION_MODULE; destroy = (pw_destroy_t) pw_module_info_free; - } else if (strcmp(type, PW_TYPE_INTERFACE_Device) == 0) { + } else if (spa_streq(type, PW_TYPE_INTERFACE_Device)) { events = &device_events; client_version = PW_VERSION_DEVICE; destroy = (pw_destroy_t) pw_device_info_free; print_func = print_device; - } else if (strcmp(type, PW_TYPE_INTERFACE_Factory) == 0) { + } else if (spa_streq(type, PW_TYPE_INTERFACE_Factory)) { events = &factory_events; client_version = PW_VERSION_FACTORY; destroy = (pw_destroy_t) pw_factory_info_free; - } else if (strcmp(type, PW_TYPE_INTERFACE_Client) == 0) { + } else if (spa_streq(type, PW_TYPE_INTERFACE_Client)) { events = &client_events; client_version = PW_VERSION_CLIENT; destroy = (pw_destroy_t) pw_client_info_free; - } else if (strcmp(type, PW_TYPE_INTERFACE_Link) == 0) { + } else if (spa_streq(type, PW_TYPE_INTERFACE_Link)) { events = &link_events; client_version = PW_VERSION_LINK; destroy = (pw_destroy_t) pw_link_info_free; diff --git a/src/tools/pw-profiler.c b/src/tools/pw-profiler.c index 5dd3e787b..338741edf 100644 --- a/src/tools/pw-profiler.c +++ b/src/tools/pw-profiler.c @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -143,7 +144,7 @@ static int find_follower(struct data *d, uint32_t id, const char *name) { int i; for (i = 0; i < d->n_followers; i++) { - if (d->followers[i].id == id && strcmp(d->followers[i].name, name) == 0) + if (d->followers[i].id == id && spa_streq(d->followers[i].name, name)) return i; } return -1; diff --git a/src/tools/pw-top.c b/src/tools/pw-top.c index a230e3b05..f38f1cc41 100644 --- a/src/tools/pw-top.c +++ b/src/tools/pw-top.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -360,7 +361,7 @@ static void registry_event_global(void *data, uint32_t id, struct data *d = data; struct pw_proxy *proxy; - if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) { + if (spa_streq(type, PW_TYPE_INTERFACE_Node)) { struct node *n; const char *str; @@ -372,7 +373,7 @@ static void registry_event_global(void *data, uint32_t id, if ((n = add_node(d, id, str)) == NULL) { pw_log_warn("can add node %u: %m", id); } - } else if (strcmp(type, PW_TYPE_INTERFACE_Profiler) == 0) { + } else if (spa_streq(type, PW_TYPE_INTERFACE_Profiler)) { if (d->profiler != NULL) { fprintf(stderr, "Ignoring profiler %d: already attached\n", id); return;