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

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

View file

@ -26,6 +26,7 @@
#include <alsa/control_external.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/json.h>
#include <spa/param/props.h>
#include <spa/param/audio/format-utils.h>
@ -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;

View file

@ -41,6 +41,7 @@
#include <spa/debug/types.h>
#include <spa/param/props.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <pipewire/pipewire.h>
@ -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)

View file

@ -30,6 +30,8 @@
#include <unistd.h>
#include <sys/mman.h>
#include <spa/utils/string.h>
#include <jack/metadata.h>
#include <jack/uuid.h>
@ -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;

View file

@ -45,6 +45,7 @@
#include <spa/debug/types.h>
#include <spa/debug/pod.h>
#include <spa/utils/json.h>
#include <spa/utils/string.h>
#include <pipewire/pipewire.h>
#include <pipewire/private.h>
@ -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;

View file

@ -26,6 +26,8 @@
#include "alsa-mixer.h"
#include "alsa-ucm.h"
#include <spa/utils/string.h>
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)

View file

@ -36,6 +36,7 @@
#include <spa/node/node.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/support/loop.h>
#include <spa/support/plugin.h>
#include <spa/support/i18n.h>
@ -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)

View file

@ -36,6 +36,7 @@
#include <spa/node/node.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/support/loop.h>
#include <spa/support/plugin.h>
#include <spa/monitor/device.h>
@ -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;

View file

@ -32,6 +32,7 @@
#include <spa/monitor/device.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/param/audio/format.h>
#include <spa/pod/filter.h>
#include <spa/debug/pod.h>
@ -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;

View file

@ -32,6 +32,7 @@
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/list.h>
#include <spa/utils/string.h>
#include <spa/monitor/device.h>
#include <spa/param/audio/format.h>
#include <spa/pod/filter.h>
@ -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;

View file

@ -32,6 +32,7 @@
#include <spa/node/keys.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/utils/list.h>
#include <spa/monitor/device.h>
#include <spa/param/audio/format.h>
@ -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;

View file

@ -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;

View file

@ -32,6 +32,7 @@
#include <spa/node/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/buffer/alloc.h>
#include <spa/pod/parser.h>
#include <spa/pod/filter.h>
@ -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;

View file

@ -32,6 +32,7 @@
#include <spa/utils/result.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/buffer/alloc.h>
#include <spa/node/io.h>
@ -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;

View file

@ -32,6 +32,7 @@
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/json.h>
#include <spa/utils/string.h>
#include <spa/node/keys.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
@ -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;

View file

@ -32,6 +32,7 @@
#include <spa/support/cpu.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/node/utils.h>
@ -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;

View file

@ -33,6 +33,7 @@
#include <spa/utils/result.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/node/utils.h>
@ -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(

View file

@ -30,6 +30,7 @@
#include <spa/support/log.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/node/utils.h>
@ -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;

View file

@ -32,6 +32,7 @@
#include <spa/support/log.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -30,6 +30,7 @@
#include <time.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/support/plugin.h>
#include <spa/param/param.h>
#include <spa/param/audio/format.h>
@ -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;

View file

@ -30,6 +30,7 @@
#include <time.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/support/plugin.h>
#include <spa/param/param.h>
#include <spa/param/audio/format.h>
@ -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;

View file

@ -31,6 +31,7 @@
#include <spa/support/cpu.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
#include <spa/node/utils.h>
@ -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;

View file

@ -31,6 +31,7 @@
#include <spa/support/cpu.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -31,6 +31,7 @@
#include <spa/support/cpu.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -34,6 +34,7 @@
#include <spa/support/loop.h>
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -28,6 +28,7 @@
#include <arpa/inet.h>
#include <spa/param/audio/format.h>
#include <spa/utils/string.h>
#include <sbc/sbc.h>
@ -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);

View file

@ -36,6 +36,7 @@
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
@ -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;

View file

@ -39,6 +39,7 @@
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
@ -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) {

View file

@ -33,6 +33,7 @@
#include <spa/support/loop.h>
#include <spa/support/dbus.h>
#include <spa/support/plugin.h>
#include <spa/utils/string.h>
#include <spa/utils/type.h>
#include <spa/param/audio/raw.h>
@ -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;

View file

@ -37,6 +37,7 @@
#include <spa/support/loop.h>
#include <spa/support/dbus.h>
#include <spa/support/plugin.h>
#include <spa/utils/string.h>
#include <spa/utils/type.h>
#include <spa/utils/json.h>
#include <spa/param/audio/raw.h>
@ -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 */

View file

@ -36,6 +36,7 @@
#include <spa/support/loop.h>
#include <spa/support/dbus.h>
#include <spa/support/plugin.h>
#include <spa/utils/string.h>
#include <spa/utils/type.h>
#include <spa/param/audio/raw.h>
@ -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;

View file

@ -46,6 +46,7 @@
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/json.h>
#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;
}

View file

@ -34,6 +34,7 @@
#include <spa/utils/type.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/support/loop.h>
#include <spa/support/plugin.h>
@ -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;

View file

@ -35,6 +35,7 @@
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
@ -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;

View file

@ -37,6 +37,7 @@
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
@ -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;

View file

@ -31,6 +31,7 @@
#include <spa/support/cpu.h>
#include <spa/utils/list.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -28,6 +28,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <spa/utils/string.h>
#include <spa/support/plugin.h>
#include <spa/support/log.h>
#include <spa/node/node.h>
@ -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;

View file

@ -28,6 +28,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <spa/utils/string.h>
#include <spa/support/plugin.h>
#include <spa/support/log.h>
#include <spa/node/node.h>
@ -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;

View file

@ -34,6 +34,7 @@
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/support/loop.h>
#include <spa/support/plugin.h>
@ -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;

View file

@ -36,6 +36,7 @@
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -36,6 +36,7 @@
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -38,6 +38,7 @@
#include <spa/utils/type.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/monitor/device.h>
#include <spa/monitor/utils.h>
@ -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;

View file

@ -37,6 +37,7 @@
#include <spa/support/loop.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/pod/builder.h>
#include <spa/monitor/device.h>
@ -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;

View file

@ -36,6 +36,7 @@
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
@ -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;

View file

@ -40,6 +40,7 @@
#include <spa/utils/type.h>
#include <spa/utils/hook.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#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;

View file

@ -35,6 +35,7 @@
#include <spa/utils/result.h>
#include <spa/utils/type.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/support/log.h>
#include <spa/support/plugin.h>
#include <spa/support/dbus.h>
@ -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;

View file

@ -40,6 +40,7 @@
#include <spa/support/plugin.h>
#include <spa/utils/type.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#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;

View file

@ -35,6 +35,7 @@
#include <spa/support/plugin.h>
#include <spa/utils/type.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <systemd/sd-journal.h>
@ -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;

View file

@ -36,6 +36,7 @@
#include <spa/utils/ringbuffer.h>
#include <spa/utils/type.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#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) {

View file

@ -39,6 +39,7 @@
#include <spa/utils/result.h>
#include <spa/utils/type.h>
#include <spa/utils/ringbuffer.h>
#include <spa/utils/string.h>
#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;

View file

@ -32,6 +32,7 @@
#include <spa/support/log.h>
#include <spa/support/loop.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/keys.h>
#include <spa/node/io.h>
@ -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);

View file

@ -35,6 +35,7 @@
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/json.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -39,6 +39,7 @@
#include <spa/support/plugin.h>
#include <spa/utils/type.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#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;

View file

@ -32,6 +32,7 @@
#include <spa/support/log.h>
#include <spa/support/loop.h>
#include <spa/utils/list.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -32,6 +32,7 @@
#include <spa/support/log.h>
#include <spa/support/loop.h>
#include <spa/utils/list.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -34,6 +34,7 @@
#include <spa/support/loop.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/pod/builder.h>
#include <spa/monitor/device.h>
@ -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;

View file

@ -35,6 +35,7 @@
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/monitor/device.h>
#include <spa/node/node.h>
#include <spa/node/io.h>
@ -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;

View file

@ -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;

View file

@ -31,6 +31,7 @@
#include <spa/node/keys.h>
#include <spa/utils/result.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/buffer/alloc.h>
#include <spa/pod/parser.h>
#include <spa/pod/filter.h>
@ -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;

View file

@ -33,6 +33,7 @@
#include <spa/support/loop.h>
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -29,6 +29,7 @@
#include <spa/support/plugin.h>
#include <spa/support/log.h>
#include <spa/utils/list.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -34,6 +34,7 @@
#include <spa/utils/list.h>
#include <spa/utils/keys.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/node/io.h>
@ -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;

View file

@ -31,6 +31,7 @@
#include <assert.h>
#include <spa/utils/dict.h>
#include <spa/utils/string.h>
#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));
}
}

View file

@ -24,6 +24,7 @@
#include <spa/utils/defs.h>
#include <spa/utils/json.h>
#include <spa/utils/string.h>
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);
}

View file

@ -31,6 +31,7 @@
#include <spa/debug/pod.h>
#include <spa/param/format.h>
#include <spa/param/video/raw.h>
#include <spa/utils/string.h>
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));

View file

@ -32,6 +32,7 @@
#include <spa/support/log-impl.h>
#include <spa/support/loop.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/node/node.h>
#include <spa/node/utils.h>
#include <spa/pod/parser.h>
@ -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");

View file

@ -30,6 +30,7 @@
#include <errno.h>
#include <poll.h>
#include <spa/utils/string.h>
#include <spa/support/log-impl.h>
#include <spa/support/loop.h>
#include <spa/support/plugin.h>
@ -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;

View file

@ -30,6 +30,8 @@
#include "config.h"
#include <spa/utils/string.h>
#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)

View file

@ -32,6 +32,7 @@
#include <dbus/dbus.h>
#include <spa/utils/string.h>
#include <spa/support/dbus.h>
#include <spa/debug/dict.h>
@ -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;

View file

@ -38,6 +38,7 @@
#include <spa/utils/result.h>
#include <spa/utils/names.h>
#include <spa/utils/keys.h>
#include <spa/utils/string.h>
#include <spa/param/audio/format-utils.h>
#include <spa/param/props.h>
#include <spa/debug/dict.h>
@ -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);

View file

@ -42,6 +42,7 @@
#include <spa/utils/names.h>
#include <spa/utils/keys.h>
#include <spa/utils/json.h>
#include <spa/utils/string.h>
#include <spa/param/props.h>
#include <spa/pod/builder.h>
#include <spa/pod/parser.h>
@ -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);
}
}

View file

@ -35,6 +35,7 @@
#include <spa/utils/result.h>
#include <spa/utils/names.h>
#include <spa/utils/keys.h>
#include <spa/utils/string.h>
#include <spa/param/audio/format-utils.h>
#include <spa/param/props.h>
#include <spa/debug/dict.h>
@ -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);

View file

@ -37,6 +37,7 @@
#include <spa/utils/result.h>
#include <spa/utils/names.h>
#include <spa/utils/keys.h>
#include <spa/utils/string.h>
#include <spa/pod/builder.h>
#include <spa/pod/parser.h>
#include <spa/param/props.h>
@ -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) {

View file

@ -35,6 +35,7 @@
#include <spa/utils/hook.h>
#include <spa/utils/result.h>
#include <spa/utils/json.h>
#include <spa/utils/string.h>
#include <spa/debug/pod.h>
#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;

View file

@ -35,6 +35,7 @@
#include <spa/utils/hook.h>
#include <spa/utils/result.h>
#include <spa/utils/json.h>
#include <spa/utils/string.h>
#include <spa/pod/parser.h>
#include <spa/pod/builder.h>
#include <spa/debug/pod.h>
@ -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)

View file

@ -35,6 +35,7 @@
#include <spa/utils/hook.h>
#include <spa/utils/result.h>
#include <spa/utils/json.h>
#include <spa/utils/string.h>
#include <spa/pod/parser.h>
#include <spa/pod/builder.h>
#include <spa/debug/pod.h>
@ -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);

View file

@ -35,6 +35,7 @@
#include <systemd/sd-login.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#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);

View file

@ -32,6 +32,7 @@
#include "config.h"
#include <spa/utils/json.h>
#include <spa/utils/string.h>
#include <pipewire/pipewire.h>
#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))

View file

@ -45,6 +45,7 @@
#include <spa/utils/hook.h>
#include <spa/utils/result.h>
#include <spa/utils/json.h>
#include <spa/utils/string.h>
#include <spa/param/audio/format-utils.h>
#include <spa/param/props.h>
#include <spa/debug/pod.h>
@ -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);

View file

@ -32,6 +32,7 @@
#include <spa/node/node.h>
#include <spa/utils/hook.h>
#include <spa/utils/string.h>
#include <spa/param/audio/format-utils.h>
#include <spa/param/props.h>
#include <spa/debug/pod.h>
@ -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");
}

View file

@ -32,6 +32,7 @@
#include <spa/node/node.h>
#include <spa/utils/hook.h>
#include <spa/utils/string.h>
#include <spa/param/audio/format-utils.h>
#include <spa/param/props.h>
#include <spa/debug/pod.h>
@ -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;

View file

@ -28,6 +28,8 @@
#include "reserve.h"
#include <spa/utils/string.h>
#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;

View file

@ -35,6 +35,7 @@
#include <spa/utils/hook.h>
#include <spa/utils/result.h>
#include <spa/utils/json.h>
#include <spa/utils/string.h>
#include <spa/pod/parser.h>
#include <spa/pod/builder.h>
#include <spa/debug/pod.h>
@ -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)

View file

@ -33,6 +33,7 @@
#include <spa/node/node.h>
#include <spa/utils/hook.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/param/audio/format-utils.h>
#include <spa/param/props.h>
#include <spa/debug/pod.h>
@ -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);

View file

@ -32,6 +32,7 @@
#include <spa/node/node.h>
#include <spa/utils/hook.h>
#include <spa/utils/string.h>
#include <spa/param/props.h>
#include <spa/debug/pod.h>
@ -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);

View file

@ -35,6 +35,7 @@
#include <spa/utils/result.h>
#include <spa/utils/names.h>
#include <spa/utils/keys.h>
#include <spa/utils/string.h>
#include <spa/param/video/format-utils.h>
#include <spa/param/props.h>
#include <spa/debug/dict.h>
@ -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);

View file

@ -35,6 +35,7 @@
#include <spa/utils/hook.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/param/props.h>
#include <spa/debug/dict.h>
#include <spa/pod/builder.h>
@ -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;

View file

@ -29,6 +29,7 @@
#include <string.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <gst/gst.h>
@ -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;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

Some files were not shown because too many files have changed in this diff Show more