mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
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:
parent
d8a9534a9a
commit
7697ed0757
130 changed files with 817 additions and 675 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue