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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -41,6 +41,7 @@
#endif
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/json.h>
#include <pipewire/impl.h>
@ -356,16 +357,16 @@ static int parse_modules(struct pw_context *context, char *str)
if ((len = spa_json_next(&it[2], &val)) <= 0)
break;
if (strcmp(key, "name") == 0) {
if (spa_streq(key, "name")) {
name = (char*)val;
spa_json_parse_string(val, len, name);
} else if (strcmp(key, "args") == 0) {
} else if (spa_streq(key, "args")) {
if (spa_json_is_container(val, len))
len = spa_json_container_len(&it[2], val, len);
args = (char*)val;
spa_json_parse_string(val, len, args);
} else if (strcmp(key, "flags") == 0) {
} else if (spa_streq(key, "flags")) {
if (spa_json_is_container(val, len))
len = spa_json_container_len(&it[2], val, len);
flags = (char*)val;
@ -438,16 +439,16 @@ static int parse_objects(struct pw_context *context, char *str)
if ((len = spa_json_next(&it[2], &val)) <= 0)
break;
if (strcmp(key, "factory") == 0) {
if (spa_streq(key, "factory")) {
factory = (char*)val;
spa_json_parse_string(val, len, factory);
} else if (strcmp(key, "args") == 0) {
} else if (spa_streq(key, "args")) {
if (spa_json_is_container(val, len))
len = spa_json_container_len(&it[2], val, len);
args = (char*)val;
spa_json_parse_string(val, len, args);
} else if (strcmp(key, "flags") == 0) {
} else if (spa_streq(key, "flags")) {
if (spa_json_is_container(val, len))
len = spa_json_container_len(&it[2], val, len);
@ -523,10 +524,10 @@ static int parse_exec(struct pw_context *context, char *str)
if ((len = spa_json_next(&it[2], &val)) <= 0)
break;
if (strcmp(key, "path") == 0) {
if (spa_streq(key, "path")) {
path = (char*)val;
spa_json_parse_string(val, len, path);
} else if (strcmp(key, "args") == 0) {
} else if (spa_streq(key, "args")) {
args = (char*)val;
spa_json_parse_string(val, len, args);
}
@ -555,13 +556,13 @@ int pw_context_parse_conf_section(struct pw_context *context,
s = strdup(str);
if (strcmp(section, "context.spa-libs") == 0)
if (spa_streq(section, "context.spa-libs"))
res = parse_spa_libs(context, s);
else if (strcmp(section, "context.modules") == 0)
else if (spa_streq(section, "context.modules"))
res = parse_modules(context, s);
else if (strcmp(section, "context.objects") == 0)
else if (spa_streq(section, "context.objects"))
res = parse_objects(context, s);
else if (strcmp(section, "context.exec") == 0)
else if (spa_streq(section, "context.exec"))
res = parse_exec(context, s);
else
res = -EINVAL;

View file

@ -35,6 +35,7 @@
#include <spa/support/dbus.h>
#include <spa/node/utils.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/debug/format.h>
#include <spa/debug/types.h>
@ -168,7 +169,7 @@ static int try_load_conf(struct pw_context *this, const char *conf_prefix,
if (conf_name == NULL)
return -EINVAL;
if (strcmp(conf_name, "null") == 0)
if (spa_streq(conf_name, "null"))
return 0;
if ((res = pw_conf_load_conf(conf_prefix, conf_name, conf)) < 0) {
pw_log_warn(NAME" %p: can't load config %s%s%s: %s",
@ -1178,7 +1179,7 @@ const struct pw_export_type *pw_context_find_export_type(struct pw_context *cont
{
const struct pw_export_type *t;
spa_list_for_each(t, &context->export_list, link) {
if (strcmp(t->type, type) == 0)
if (spa_streq(t->type, type))
return t;
}
return NULL;
@ -1193,7 +1194,7 @@ static struct object_entry *find_object(struct pw_context *context, const char *
{
struct object_entry *entry;
pw_array_for_each(entry, &context->objects) {
if (strcmp(entry->type, type) == 0)
if (spa_streq(entry->type, type))
return entry;
}
return NULL;

View file

@ -31,6 +31,7 @@
#include <pipewire/private.h>
#include <spa/debug/types.h>
#include <spa/utils/string.h>
#define NAME "global"
@ -192,7 +193,7 @@ const char * pw_global_get_type(struct pw_global *global)
SPA_EXPORT
bool pw_global_is_type(struct pw_global *global, const char *type)
{
return strcmp(global->type, type) == 0;
return spa_streq(global->type, type);
}
SPA_EXPORT

View file

@ -25,6 +25,8 @@
#include <errno.h>
#include <string.h>
#include <spa/utils/string.h>
#include "pipewire/impl.h"
#include "pipewire/private.h"
@ -137,7 +139,7 @@ static bool has_key(const char *keys[], const char *key)
{
int i;
for (i = 0; keys[i]; i++) {
if (strcmp(keys[i], key) == 0)
if (spa_streq(keys[i], key))
return true;
}
return false;

View file

@ -27,6 +27,7 @@
#include <spa/debug/types.h>
#include <spa/monitor/utils.h>
#include <spa/pod/filter.h>
#include <spa/utils/string.h>
#include "pipewire/impl.h"
#include "pipewire/private.h"
@ -798,7 +799,7 @@ static void device_add_object(struct pw_impl_device *device, uint32_t id,
if (info->props && props)
pw_properties_update(props, info->props);
if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) == 0) {
if (spa_streq(info->type, SPA_TYPE_INTERFACE_Node)) {
struct pw_impl_node *node;
node = pw_context_create_node(context, props, sizeof(struct object_data));
@ -807,7 +808,7 @@ static void device_add_object(struct pw_impl_device *device, uint32_t id,
od->type = OBJECT_NODE;
pw_impl_node_add_listener(node, &od->listener, &node_object_events, od);
pw_impl_node_set_implementation(node, iface);
} else if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) == 0) {
} else if (spa_streq(info->type, SPA_TYPE_INTERFACE_Device)) {
struct pw_impl_device *dev;
dev = pw_context_create_device(context, props, sizeof(struct object_data));

View file

@ -25,6 +25,7 @@
#include <errno.h>
#include <spa/debug/types.h>
#include <spa/utils/string.h>
#include "pipewire/impl.h"
#include "pipewire/private.h"
@ -290,7 +291,7 @@ struct pw_impl_factory *pw_context_find_factory(struct pw_context *context,
struct pw_impl_factory *factory;
spa_list_for_each(factory, &context->factory_list, link) {
if (strcmp(factory->info.name, name) == 0)
if (spa_streq(factory->info.name, name))
return factory;
}
return NULL;

View file

@ -33,6 +33,8 @@
#include <sys/stat.h>
#include <errno.h>
#include <spa/utils/string.h>
#include "pipewire/impl.h"
#include "pipewire/private.h"
@ -82,7 +84,7 @@ static char *find_module(const char *path, const char *name)
while ((entry = readdir(dir))) {
char *newpath;
if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
if (spa_streq(entry->d_name, ".") || spa_streq(entry->d_name, ".."))
continue;
newpath = spa_aprintf("%s/%s", path, entry->d_name);

View file

@ -34,6 +34,7 @@
#include <spa/pod/filter.h>
#include <spa/node/utils.h>
#include <spa/debug/types.h>
#include <spa/utils/string.h>
#include "pipewire/impl-node.h"
#include "pipewire/private.h"
@ -864,7 +865,7 @@ static void check_properties(struct pw_impl_node *node)
if (strcmp(str, node->group) != 0) {
pw_log_info(NAME" %p: group '%s'->'%s'", node, node->group, str);
snprintf(node->group, sizeof(node->group), "%s", str);
node->freewheel = strcmp(node->group, "pipewire.freewheel") == 0;
node->freewheel = spa_streq(node->group, "pipewire.freewheel");
recalc_reason = "group changed";
}

View file

@ -40,6 +40,7 @@
#include <libintl.h>
#include <spa/utils/names.h>
#include <spa/utils/string.h>
#include <spa/support/cpu.h>
#include <spa/support/i18n.h>
@ -186,7 +187,7 @@ static const struct spa_handle_factory *find_factory(struct plugin *plugin, cons
factory->version);
continue;
}
if (strcmp(factory->name, factory_name) == 0)
if (spa_streq(factory->name, factory_name))
return factory;
}
res = -ENOENT;
@ -451,7 +452,7 @@ static struct spa_log *load_journal_logger(struct support *support)
/* look for an existing logger, and
* replace it with the journal logger */
for (i = 0; i < support->n_support; i++) {
if (strcmp(support->support[i].type, SPA_TYPE_INTERFACE_Log) == 0) {
if (spa_streq(support->support[i].type, SPA_TYPE_INTERFACE_Log)) {
support->support[i].data = iface;
break;
}
@ -525,7 +526,7 @@ void pw_init(int *argc, char **argv[])
#ifdef HAVE_SYSTEMD
if ((str = getenv("PIPEWIRE_LOG_SYSTEMD")) == NULL ||
strcmp(str, "true") == 0 || atoi(str) != 0) {
spa_streq(str, "true") || atoi(str) != 0) {
log = load_journal_logger(support);
if (log)
pw_log_set(log);
@ -592,7 +593,7 @@ bool pw_debug_is_category_enabled(const char *name)
return false;
for (i = 0; global_support.categories[i]; i++) {
if (strcmp(global_support.categories[i], name) == 0)
if (spa_streq(global_support.categories[i], name))
return true;
}
return false;

View file

@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <spa/utils/json.h>
#include <spa/utils/string.h>
#include "pipewire/array.h"
#include "pipewire/utils.h"
@ -252,7 +253,7 @@ static bool has_key(const char *keys[], const char *key)
{
int i;
for (i = 0; keys[i]; i++) {
if (strcmp(keys[i], key) == 0)
if (spa_streq(keys[i], key))
return true;
}
return false;
@ -401,7 +402,7 @@ static int do_replace(struct pw_properties *properties, const char *key, char *v
struct spa_dict_item *item =
pw_array_get_unchecked(&impl->items, index, struct spa_dict_item);
if (value && strcmp(item->value, value) == 0)
if (value && spa_streq(item->value, value))
goto exit_noupdate;
if (value == NULL) {

View file

@ -25,6 +25,7 @@
#include <errno.h>
#include <spa/debug/types.h>
#include <spa/utils/string.h>
#include <pipewire/protocol.h>
#include <pipewire/private.h>
@ -164,7 +165,7 @@ pw_protocol_get_marshal(struct pw_protocol *protocol, const char *type, uint32_t
struct marshal *impl;
spa_list_for_each(impl, &protocol->marshal_list, link) {
if (strcmp(impl->marshal->type, type) == 0 &&
if (spa_streq(impl->marshal->type, type) &&
impl->marshal->version == version &&
(impl->marshal->flags & flags) == flags)
return impl->marshal;
@ -180,7 +181,7 @@ struct pw_protocol *pw_context_find_protocol(struct pw_context *context, const c
struct pw_protocol *protocol;
spa_list_for_each(protocol, &context->protocol_list, link) {
if (strcmp(protocol->name, name) == 0)
if (spa_streq(protocol->name, name))
return protocol;
}
return NULL;

View file

@ -29,6 +29,8 @@
#include <fcntl.h>
#include <math.h>
#include <spa/utils/string.h>
#include "midifile.h"
#define DEFAULT_TEMPO 500000 /* 500ms per quarter note (120 BPM) is the default */
@ -263,10 +265,10 @@ midi_file_open(const char *filename, const char *mode, struct midi_file_info *in
if (mf == NULL)
return NULL;
if (strcmp(mode, "r") == 0) {
if (spa_streq(mode, "r")) {
if ((res = open_read(mf, filename, info)) < 0)
goto exit_free;
} else if (strcmp(mode, "w") == 0) {
} else if (spa_streq(mode, "w")) {
if ((res = open_write(mf, filename, info)) < 0)
goto exit_free;
} else {

View file

@ -42,6 +42,7 @@
#include <spa/param/audio/type-info.h>
#include <spa/param/props.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/json.h>
#include <spa/debug/types.h>
@ -495,7 +496,7 @@ static unsigned int find_channel(const char *name)
int i;
for (i = 0; spa_type_audio_channel[i].name; i++) {
if (strcmp(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)) == 0)
if (spa_streq(name, spa_debug_type_short_name(spa_type_audio_channel[i].name)))
return spa_type_audio_channel[i].type;
}
return SPA_AUDIO_CHANNEL_UNKNOWN;
@ -507,7 +508,7 @@ static int parse_channelmap(const char *channel_map, struct channelmap *map)
char **ch;
for (i = 0; i < (int) SPA_N_ELEMENTS(maps); i++) {
if (strcmp(maps[i].name, channel_map) == 0) {
if (spa_streq(maps[i].name, channel_map)) {
map->n_channels = maps[i].channels;
spa_memcpy(map->channels, &maps[i].values,
map->n_channels * sizeof(unsigned int));
@ -659,7 +660,7 @@ static int json_object_find(const char *obj, const char *key, char *value, size_
return -EINVAL;
while (spa_json_get_string(&it[1], k, sizeof(k)-1) > 0) {
if (strcmp(k, key) == 0) {
if (spa_streq(k, key)) {
if (spa_json_get_string(&it[1], value, len) <= 0)
continue;
return 0;
@ -677,13 +678,13 @@ static int metadata_property(void *object,
struct data *data = object;
if (subject == PW_ID_CORE) {
if (key == NULL || strcmp(key, "default.audio.sink") == 0) {
if (key == NULL || spa_streq(key, "default.audio.sink")) {
if (value == NULL ||
json_object_find(value, "name",
data->default_sink, sizeof(data->default_sink)) < 0)
data->default_sink[0] = '\0';
}
if (key == NULL || strcmp(key, "default.audio.source") == 0) {
if (key == NULL || spa_streq(key, "default.audio.source")) {
if (value == NULL ||
json_object_find(value, "name",
data->default_source, sizeof(data->default_source)) < 0)
@ -717,7 +718,7 @@ static void registry_event_global(void *userdata, uint32_t id,
if (!data->list_targets)
return;
if (strcmp(type, PW_TYPE_INTERFACE_Metadata) == 0) {
if (spa_streq(type, PW_TYPE_INTERFACE_Metadata)) {
if (data->metadata != NULL)
return;
@ -729,7 +730,7 @@ static void registry_event_global(void *userdata, uint32_t id,
data->sync = pw_core_sync(data->core, 0, data->sync);
} else if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) {
} else if (spa_streq(type, PW_TYPE_INTERFACE_Node)) {
name = spa_dict_lookup(props, PW_KEY_NODE_NAME);
desc = spa_dict_lookup(props, PW_KEY_NODE_DESCRIPTION);
media_class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS);
@ -1714,7 +1715,7 @@ int main(int argc, char *argv[])
target_default = NULL;
spa_list_for_each(target, &data.targets, link) {
if (target_default == NULL ||
strcmp(default_name, target->name) == 0 ||
spa_streq(default_name, target->name) ||
(default_name[0] == '\0' &&
target->prio > target_default->prio))
target_default = target;

View file

@ -36,6 +36,7 @@
#define spa_debug(...) fprintf(stdout,__VA_ARGS__);fputc('\n', stdout)
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/debug/pod.h>
#include <spa/utils/keys.h>
#include <spa/utils/json.h>
@ -1129,57 +1130,57 @@ static bool bind_global(struct remote_data *rd, struct global *global, char **er
struct proxy_data *pd;
struct pw_proxy *proxy;
if (strcmp(global->type, PW_TYPE_INTERFACE_Core) == 0) {
if (spa_streq(global->type, PW_TYPE_INTERFACE_Core)) {
events = &core_events;
client_version = PW_VERSION_CORE;
destroy = (pw_destroy_t) pw_core_info_free;
info_func = info_core;
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Module) == 0) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_Module)) {
events = &module_events;
client_version = PW_VERSION_MODULE;
destroy = (pw_destroy_t) pw_module_info_free;
info_func = info_module;
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Device) == 0) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_Device)) {
events = &device_events;
client_version = PW_VERSION_DEVICE;
destroy = (pw_destroy_t) pw_device_info_free;
info_func = info_device;
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Node) == 0) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_Node)) {
events = &node_events;
client_version = PW_VERSION_NODE;
destroy = (pw_destroy_t) pw_node_info_free;
info_func = info_node;
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Port) == 0) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_Port)) {
events = &port_events;
client_version = PW_VERSION_PORT;
destroy = (pw_destroy_t) pw_port_info_free;
info_func = info_port;
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Factory) == 0) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_Factory)) {
events = &factory_events;
client_version = PW_VERSION_FACTORY;
destroy = (pw_destroy_t) pw_factory_info_free;
info_func = info_factory;
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Client) == 0) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_Client)) {
events = &client_events;
client_version = PW_VERSION_CLIENT;
destroy = (pw_destroy_t) pw_client_info_free;
info_func = info_client;
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Link) == 0) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_Link)) {
events = &link_events;
client_version = PW_VERSION_LINK;
destroy = (pw_destroy_t) pw_link_info_free;
info_func = info_link;
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Session) == 0) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_Session)) {
events = &session_events;
client_version = PW_VERSION_SESSION;
destroy = (pw_destroy_t) session_info_free;
info_func = info_session;
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Endpoint) == 0) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_Endpoint)) {
events = &endpoint_events;
client_version = PW_VERSION_ENDPOINT;
destroy = (pw_destroy_t) endpoint_info_free;
info_func = info_endpoint;
} else if (strcmp(global->type, PW_TYPE_INTERFACE_EndpointStream) == 0) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_EndpointStream)) {
events = &endpoint_stream_events;
client_version = PW_VERSION_ENDPOINT_STREAM;
destroy = (pw_destroy_t) endpoint_stream_info_free;
@ -1255,7 +1256,7 @@ static bool do_info(struct data *data, const char *cmd, char *args, char **error
*error = spa_aprintf("%s <object-id>|all", cmd);
return false;
}
if (strcmp(a[0], "all") == 0) {
if (spa_streq(a[0], "all")) {
pw_map_for_each(&rd->globals, do_global_info_all, NULL);
}
else {
@ -1469,9 +1470,9 @@ static bool do_export_node(struct data *data, const char *cmd, char *args, char
static const struct spa_type_info *find_type_info(const struct spa_type_info *info, const char *name)
{
while (info && info->name) {
if (strcmp(info->name, name) == 0)
if (spa_streq(info->name, name))
return info;
if (strcmp(spa_debug_type_short_name(info->name), name) == 0)
if (spa_streq(spa_debug_type_short_name(info->name), name))
return info;
if (info->type != 0 && info->type == (uint32_t)atoi(name))
return info;
@ -1513,16 +1514,16 @@ static bool do_enum_params(struct data *data, const char *cmd, char *args, char
return false;
}
if (strcmp(global->type, PW_TYPE_INTERFACE_Node) == 0)
if (spa_streq(global->type, PW_TYPE_INTERFACE_Node))
pw_node_enum_params((struct pw_node*)global->proxy, 0,
param_id, 0, 0, NULL);
else if (strcmp(global->type, PW_TYPE_INTERFACE_Port) == 0)
else if (spa_streq(global->type, PW_TYPE_INTERFACE_Port))
pw_port_enum_params((struct pw_port*)global->proxy, 0,
param_id, 0, 0, NULL);
else if (strcmp(global->type, PW_TYPE_INTERFACE_Device) == 0)
else if (spa_streq(global->type, PW_TYPE_INTERFACE_Device))
pw_device_enum_params((struct pw_device*)global->proxy, 0,
param_id, 0, 0, NULL);
else if (strcmp(global->type, PW_TYPE_INTERFACE_Endpoint) == 0)
else if (spa_streq(global->type, PW_TYPE_INTERFACE_Endpoint))
pw_endpoint_enum_params((struct pw_endpoint*)global->proxy, 0,
param_id, 0, 0, NULL);
else {
@ -1696,13 +1697,13 @@ static bool do_set_param(struct data *data, const char *cmd, char *args, char **
}
spa_debug_pod(0, NULL, pod);
if (strcmp(global->type, PW_TYPE_INTERFACE_Node) == 0)
if (spa_streq(global->type, PW_TYPE_INTERFACE_Node))
pw_node_set_param((struct pw_node*)global->proxy,
param_id, 0, pod);
else if (strcmp(global->type, PW_TYPE_INTERFACE_Device) == 0)
else if (spa_streq(global->type, PW_TYPE_INTERFACE_Device))
pw_device_set_param((struct pw_device*)global->proxy,
param_id, 0, pod);
else if (strcmp(global->type, PW_TYPE_INTERFACE_Endpoint) == 0)
else if (spa_streq(global->type, PW_TYPE_INTERFACE_Endpoint))
pw_endpoint_set_param((struct pw_endpoint*)global->proxy,
param_id, 0, pod);
else {

View file

@ -27,6 +27,7 @@
#include <getopt.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/debug/pod.h>
#include <spa/debug/format.h>
#include <spa/debug/types.h>
@ -505,7 +506,7 @@ static int draw_graph(struct data *d, const char *path)
/* draw the footer */
dot_str_add(&d->dot_str, "}\n");
if (strcmp(path, "-") == 0) {
if (spa_streq(path, "-")) {
/* wire the dot graph into to stdout */
fputs(d->dot_str, stdout);
} else {
@ -634,7 +635,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
draw_t draw;
struct global *g;
if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) {
if (spa_streq(type, PW_TYPE_INTERFACE_Port)) {
events = &port_events;
info_destroy = (pw_destroy_t)pw_port_info_free;
info_update = (info_update_t)pw_port_info_update;
@ -642,7 +643,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
client_version = PW_VERSION_PORT;
object_type = INTERFACE_Port;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) {
else if (spa_streq(type, PW_TYPE_INTERFACE_Node)) {
events = &node_events;
info_destroy = (pw_destroy_t)pw_node_info_free;
info_update = (info_update_t)pw_node_info_update;
@ -650,7 +651,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
client_version = PW_VERSION_NODE;
object_type = INTERFACE_Node;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Link) == 0) {
else if (spa_streq(type, PW_TYPE_INTERFACE_Link)) {
events = &link_events;
info_destroy = (pw_destroy_t)pw_link_info_free;
info_update = (info_update_t)pw_link_info_update;
@ -658,7 +659,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
client_version = PW_VERSION_LINK;
object_type = INTERFACE_Link;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Client) == 0) {
else if (spa_streq(type, PW_TYPE_INTERFACE_Client)) {
events = &client_events;
info_destroy = (pw_destroy_t)pw_client_info_free;
info_update = (info_update_t)pw_client_info_update;
@ -666,7 +667,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
client_version = PW_VERSION_CLIENT;
object_type = INTERFACE_Client;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Device) == 0) {
else if (spa_streq(type, PW_TYPE_INTERFACE_Device)) {
events = &device_events;
info_destroy = (pw_destroy_t)pw_device_info_free;
info_update = (info_update_t)pw_device_info_update;
@ -674,7 +675,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
client_version = PW_VERSION_DEVICE;
object_type = INTERFACE_Device;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Factory) == 0) {
else if (spa_streq(type, PW_TYPE_INTERFACE_Factory)) {
events = &factory_events;
info_destroy = (pw_destroy_t)pw_factory_info_free;
info_update = (info_update_t)pw_factory_info_update;
@ -682,7 +683,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
client_version = PW_VERSION_FACTORY;
object_type = INTERFACE_Factory;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Module) == 0) {
else if (spa_streq(type, PW_TYPE_INTERFACE_Module)) {
events = &module_events;
info_destroy = (pw_destroy_t)pw_module_info_free;
info_update = (info_update_t)pw_module_info_update;
@ -690,7 +691,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
client_version = PW_VERSION_MODULE;
object_type = INTERFACE_Module;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Core) == 0) {
else if (spa_streq(type, PW_TYPE_INTERFACE_Core)) {
/* sync to notify we are done with globals */
pw_core_sync(d->core, 0, 0);
return;

View file

@ -31,6 +31,7 @@
#include <math.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/pod/iter.h>
#include <spa/debug/types.h>
#include <spa/utils/json.h>
@ -280,8 +281,8 @@ static void put_value(struct data *d, const char *key, const char *val)
if (val == NULL)
put_literal(d, key, "null");
else if (strcmp(val, "true") == 0 ||
strcmp(val, "false") == 0)
else if (spa_streq(val, "true") ||
spa_streq(val, "false"))
put_literal(d, key, val);
else if ((li = strtol(val, &end, 10)) != LONG_MIN &&
errno != -ERANGE && *end == '\0')
@ -1109,7 +1110,7 @@ static void metadata_dump(struct object *o)
put_int(d, "subject", e->subject);
put_value(d, "key", e->key);
put_value(d, "type", e->type);
if (e->type != NULL && strcmp(e->type, "Spa:String:JSON") == 0)
if (e->type != NULL && spa_streq(e->type, "Spa:String:JSON"))
json_dump(d, "value", e->value);
else
put_value(d, "value", e->value);
@ -1124,7 +1125,7 @@ static struct metadata_entry *metadata_find(struct object *o, uint32_t subject,
struct metadata_entry *e;
spa_list_for_each(e, &o->data_list, link) {
if ((e->subject == subject) &&
(key == NULL || strcmp(e->key, key) == 0))
(key == NULL || spa_streq(e->key, key)))
return e;
}
return NULL;
@ -1208,7 +1209,7 @@ static const struct class *find_class(const char *type, uint32_t version)
{
size_t i;
for (i = 0; i < SPA_N_ELEMENTS(classes); i++) {
if (strcmp(classes[i]->type, type) == 0 &&
if (spa_streq(classes[i]->type, type) &&
classes[i]->version <= version)
return classes[i];
}

View file

@ -29,6 +29,7 @@
#include <regex.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/defs.h>
#include <pipewire/pipewire.h>
@ -245,11 +246,11 @@ static int port_matches(struct data *data, struct object *n, struct object *p, c
uint32_t id = atoi(name);
if (p->id == id)
return 1;
if (strcmp(port_name(buffer, sizeof(buffer), n, p), name) == 0)
if (spa_streq(port_name(buffer, sizeof(buffer), n, p), name))
return 1;
if (strcmp(port_path(buffer, sizeof(buffer), n, p), name) == 0)
if (spa_streq(port_path(buffer, sizeof(buffer), n, p), name))
return 1;
if (strcmp(port_alias(buffer, sizeof(buffer), n, p), name) == 0)
if (spa_streq(port_alias(buffer, sizeof(buffer), n, p), name))
return 1;
return 0;
}
@ -444,22 +445,22 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
return;
spa_zero(extra);
if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) {
if (spa_streq(type, PW_TYPE_INTERFACE_Node)) {
t = OBJECT_NODE;
} else if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) {
} else if (spa_streq(type, PW_TYPE_INTERFACE_Port)) {
t = OBJECT_PORT;
if ((str = spa_dict_lookup(props, PW_KEY_PORT_DIRECTION)) == NULL)
return;
if (strcmp(str, "in") == 0)
if (spa_streq(str, "in"))
extra[0] = PW_DIRECTION_INPUT;
else if (strcmp(str, "out") == 0)
else if (spa_streq(str, "out"))
extra[0] = PW_DIRECTION_OUTPUT;
else
return;
if ((str = spa_dict_lookup(props, PW_KEY_NODE_ID)) == NULL)
return;
extra[1] = atoi(str);
} else if (strcmp(type, PW_TYPE_INTERFACE_Link) == 0) {
} else if (spa_streq(type, PW_TYPE_INTERFACE_Link)) {
t = OBJECT_LINK;
if ((str = spa_dict_lookup(props, PW_KEY_LINK_OUTPUT_PORT)) == NULL)
return;

View file

@ -28,6 +28,7 @@
#include <getopt.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/utils/defs.h>
#include <pipewire/pipewire.h>
@ -67,7 +68,7 @@ static int metadata_property(void *data, uint32_t id,
struct data *d = data;
if ((d->opt_id == SPA_ID_INVALID || d->opt_id == id) &&
(d->opt_key == NULL || strcmp(d->opt_key, key) == 0)) {
(d->opt_key == NULL || spa_streq(d->opt_key, key))) {
if (key == NULL) {
fprintf(stdout, "remove: id:%u all keys\n", id);
} else if (value == NULL) {

View file

@ -27,6 +27,7 @@
#include <getopt.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/debug/pod.h>
#include <spa/debug/format.h>
#include <spa/debug/types.h>
@ -576,34 +577,34 @@ static void registry_event_global(void *data, uint32_t id,
pw_destroy_t destroy;
print_func_t print_func = NULL;
if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) {
if (spa_streq(type, PW_TYPE_INTERFACE_Node)) {
events = &node_events;
client_version = PW_VERSION_NODE;
destroy = (pw_destroy_t) pw_node_info_free;
print_func = print_node;
} else if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) {
} else if (spa_streq(type, PW_TYPE_INTERFACE_Port)) {
events = &port_events;
client_version = PW_VERSION_PORT;
destroy = (pw_destroy_t) pw_port_info_free;
print_func = print_port;
} else if (strcmp(type, PW_TYPE_INTERFACE_Module) == 0) {
} else if (spa_streq(type, PW_TYPE_INTERFACE_Module)) {
events = &module_events;
client_version = PW_VERSION_MODULE;
destroy = (pw_destroy_t) pw_module_info_free;
} else if (strcmp(type, PW_TYPE_INTERFACE_Device) == 0) {
} else if (spa_streq(type, PW_TYPE_INTERFACE_Device)) {
events = &device_events;
client_version = PW_VERSION_DEVICE;
destroy = (pw_destroy_t) pw_device_info_free;
print_func = print_device;
} else if (strcmp(type, PW_TYPE_INTERFACE_Factory) == 0) {
} else if (spa_streq(type, PW_TYPE_INTERFACE_Factory)) {
events = &factory_events;
client_version = PW_VERSION_FACTORY;
destroy = (pw_destroy_t) pw_factory_info_free;
} else if (strcmp(type, PW_TYPE_INTERFACE_Client) == 0) {
} else if (spa_streq(type, PW_TYPE_INTERFACE_Client)) {
events = &client_events;
client_version = PW_VERSION_CLIENT;
destroy = (pw_destroy_t) pw_client_info_free;
} else if (strcmp(type, PW_TYPE_INTERFACE_Link) == 0) {
} else if (spa_streq(type, PW_TYPE_INTERFACE_Link)) {
events = &link_events;
client_version = PW_VERSION_LINK;
destroy = (pw_destroy_t) pw_link_info_free;

View file

@ -27,6 +27,7 @@
#include <getopt.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/pod/parser.h>
#include <spa/debug/pod.h>
@ -143,7 +144,7 @@ static int find_follower(struct data *d, uint32_t id, const char *name)
{
int i;
for (i = 0; i < d->n_followers; i++) {
if (d->followers[i].id == id && strcmp(d->followers[i].name, name) == 0)
if (d->followers[i].id == id && spa_streq(d->followers[i].name, name))
return i;
}
return -1;

View file

@ -29,6 +29,7 @@
#include <ncurses.h>
#include <spa/utils/result.h>
#include <spa/utils/string.h>
#include <spa/pod/parser.h>
#include <spa/debug/pod.h>
@ -360,7 +361,7 @@ static void registry_event_global(void *data, uint32_t id,
struct data *d = data;
struct pw_proxy *proxy;
if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) {
if (spa_streq(type, PW_TYPE_INTERFACE_Node)) {
struct node *n;
const char *str;
@ -372,7 +373,7 @@ static void registry_event_global(void *data, uint32_t id,
if ((n = add_node(d, id, str)) == NULL) {
pw_log_warn("can add node %u: %m", id);
}
} else if (strcmp(type, PW_TYPE_INTERFACE_Profiler) == 0) {
} else if (spa_streq(type, PW_TYPE_INTERFACE_Profiler)) {
if (d->profiler != NULL) {
fprintf(stderr, "Ignoring profiler %d: already attached\n", id);
return;