treewide: replace !strcmp() 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:40:50 +10:00
parent 7697ed0757
commit 95a84e797a
28 changed files with 239 additions and 221 deletions

View file

@ -1273,7 +1273,7 @@ SND_CTL_PLUGIN_DEFINE_FUNC(pipewire)
if (str != NULL && str[0] != '\0')
server = str;
if (fallback_name && name && !strcmp(name, fallback_name))
if (fallback_name && name && spa_streq(name, fallback_name))
fallback_name = NULL; /* no fallback for the same name */
ctl = calloc(1, sizeof(*ctl));

View file

@ -555,7 +555,7 @@ static struct object *find_node(struct client *c, const char *name)
struct object *o;
spa_list_for_each(o, &c->context.nodes, link) {
if (!strcmp(o->node.name, name))
if (spa_streq(o->node.name, name))
return o;
}
return NULL;
@ -2036,13 +2036,13 @@ static const struct pw_client_node_events client_node_events = {
static jack_port_type_id_t string_to_type(const char *port_type)
{
if (!strcmp(JACK_DEFAULT_AUDIO_TYPE, port_type))
if (spa_streq(JACK_DEFAULT_AUDIO_TYPE, port_type))
return TYPE_ID_AUDIO;
else if (!strcmp(JACK_DEFAULT_MIDI_TYPE, port_type))
else if (spa_streq(JACK_DEFAULT_MIDI_TYPE, port_type))
return TYPE_ID_MIDI;
else if (!strcmp(JACK_DEFAULT_VIDEO_TYPE, port_type))
else if (spa_streq(JACK_DEFAULT_VIDEO_TYPE, port_type))
return TYPE_ID_VIDEO;
else if (!strcmp("other", port_type))
else if (spa_streq("other", port_type))
return TYPE_ID_OTHER;
else
return SPA_ID_INVALID;
@ -2265,25 +2265,25 @@ static void registry_event_global(void *data, uint32_t id,
goto exit;
spa_dict_for_each(item, props) {
if (!strcmp(item->key, PW_KEY_PORT_DIRECTION)) {
if (spa_streq(item->key, PW_KEY_PORT_DIRECTION)) {
if (spa_streq(item->value, "in"))
flags |= JackPortIsInput;
else if (spa_streq(item->value, "out"))
flags |= JackPortIsOutput;
}
else if (!strcmp(item->key, PW_KEY_PORT_PHYSICAL)) {
else if (spa_streq(item->key, PW_KEY_PORT_PHYSICAL)) {
if (pw_properties_parse_bool(item->value))
flags |= JackPortIsPhysical;
}
else if (!strcmp(item->key, PW_KEY_PORT_TERMINAL)) {
else if (spa_streq(item->key, PW_KEY_PORT_TERMINAL)) {
if (pw_properties_parse_bool(item->value))
flags |= JackPortIsTerminal;
}
else if (!strcmp(item->key, PW_KEY_PORT_CONTROL)) {
else if (spa_streq(item->key, PW_KEY_PORT_CONTROL)) {
if (pw_properties_parse_bool(item->value))
type_id = TYPE_ID_MIDI;
}
else if (!strcmp(item->key, PW_KEY_PORT_MONITOR)) {
else if (spa_streq(item->key, PW_KEY_PORT_MONITOR)) {
is_monitor = pw_properties_parse_bool(item->value);
}
}
@ -4310,11 +4310,11 @@ size_t jack_port_type_get_buffer_size (jack_client_t *client, const char *port_t
spa_return_val_if_fail(client != NULL, 0);
spa_return_val_if_fail(port_type != NULL, 0);
if (!strcmp(JACK_DEFAULT_AUDIO_TYPE, port_type))
if (spa_streq(JACK_DEFAULT_AUDIO_TYPE, port_type))
return jack_get_buffer_size(client) * sizeof(float);
else if (!strcmp(JACK_DEFAULT_MIDI_TYPE, port_type))
else if (spa_streq(JACK_DEFAULT_MIDI_TYPE, port_type))
return MAX_BUFFER_FRAMES * sizeof(float);
else if (!strcmp(JACK_DEFAULT_VIDEO_TYPE, port_type))
else if (spa_streq(JACK_DEFAULT_VIDEO_TYPE, port_type))
return 320 * 240 * 4 * sizeof(float);
else
return 0;

View file

@ -31,6 +31,8 @@
#include <stdbool.h>
#include <getopt.h>
#include <spa/utils/string.h>
#include <acp/acp.h>
#define WHITESPACE "\n\r\t "
@ -277,7 +279,7 @@ static int cmd_list(struct data *data, const struct command *cmd, int argc, char
uint32_t i;
int level = 0;
if (!strcmp(cmd->name, "list-verbose"))
if (spa_streq(cmd->name, "list-verbose"))
level = 2;
print_card(data, card, 0, level);
@ -530,8 +532,8 @@ static const struct command *find_command(struct data *data, const char *cmd)
{
size_t i;
for (i = 0; i < N_COMMANDS; i++) {
if (!strcmp(command_list[i].name, cmd) ||
!strcmp(command_list[i].alias, cmd))
if (spa_streq(command_list[i].name, cmd) ||
spa_streq(command_list[i].alias, cmd))
return &command_list[i];
}
return NULL;

View file

@ -791,27 +791,27 @@ impl_init(const struct spa_handle_factory *factory,
for (i = 0; info && i < info->n_items; i++) {
const char *k = info->items[i].key;
const char *s = info->items[i].value;
if (!strcmp(k, SPA_KEY_API_ALSA_PATH)) {
if (spa_streq(k, SPA_KEY_API_ALSA_PATH)) {
snprintf(this->props.device, 63, "%s", s);
} else if (!strcmp(k, SPA_KEY_AUDIO_CHANNELS)) {
} else if (spa_streq(k, SPA_KEY_AUDIO_CHANNELS)) {
this->default_channels = atoi(s);
} else if (!strcmp(k, SPA_KEY_AUDIO_RATE)) {
} else if (spa_streq(k, SPA_KEY_AUDIO_RATE)) {
this->default_rate = atoi(s);
} else if (!strcmp(k, SPA_KEY_AUDIO_FORMAT)) {
} else if (spa_streq(k, SPA_KEY_AUDIO_FORMAT)) {
this->default_format = spa_alsa_format_from_name(s, strlen(s));
} else if (!strcmp(k, SPA_KEY_AUDIO_POSITION)) {
} else if (spa_streq(k, SPA_KEY_AUDIO_POSITION)) {
spa_alsa_parse_position(&this->default_pos, s, strlen(s));
} else if (!strcmp(k, "api.alsa.period-size")) {
} else if (spa_streq(k, "api.alsa.period-size")) {
this->default_period_size = atoi(s);
} else if (!strcmp(k, "api.alsa.headroom")) {
} else if (spa_streq(k, "api.alsa.headroom")) {
this->default_headroom = atoi(s);
} else if (!strcmp(k, "api.alsa.start-delay")) {
} else if (spa_streq(k, "api.alsa.start-delay")) {
this->default_start_delay = atoi(s);
} else if (!strcmp(k, "api.alsa.disable-mmap")) {
} else if (spa_streq(k, "api.alsa.disable-mmap")) {
this->disable_mmap = (spa_streq(s, "true") || atoi(s) == 1);
} else if (!strcmp(k, "api.alsa.disable-batch")) {
} else if (spa_streq(k, "api.alsa.disable-batch")) {
this->disable_batch = (spa_streq(s, "true") || atoi(s) == 1);
} else if (!strcmp(k, "api.alsa.use-chmap")) {
} else if (spa_streq(k, "api.alsa.use-chmap")) {
this->props.use_chmap = (spa_streq(s, "true") || atoi(s) == 1);
}
}

View file

@ -811,25 +811,25 @@ impl_init(const struct spa_handle_factory *factory,
for (i = 0; info && i < info->n_items; i++) {
const char *k = info->items[i].key;
const char *s = info->items[i].value;
if (!strcmp(k, SPA_KEY_API_ALSA_PATH)) {
if (spa_streq(k, SPA_KEY_API_ALSA_PATH)) {
snprintf(this->props.device, 63, "%s", s);
} else if (!strcmp(k, SPA_KEY_AUDIO_CHANNELS)) {
} else if (spa_streq(k, SPA_KEY_AUDIO_CHANNELS)) {
this->default_channels = atoi(s);
} else if (!strcmp(k, SPA_KEY_AUDIO_RATE)) {
} else if (spa_streq(k, SPA_KEY_AUDIO_RATE)) {
this->default_rate = atoi(s);
} else if (!strcmp(k, SPA_KEY_AUDIO_FORMAT)) {
} else if (spa_streq(k, SPA_KEY_AUDIO_FORMAT)) {
this->default_format = spa_alsa_format_from_name(s, strlen(s));
} else if (!strcmp(k, SPA_KEY_AUDIO_POSITION)) {
} else if (spa_streq(k, SPA_KEY_AUDIO_POSITION)) {
spa_alsa_parse_position(&this->default_pos, s, strlen(s));
} else if (!strcmp(k, "api.alsa.period-size")) {
} else if (spa_streq(k, "api.alsa.period-size")) {
this->default_period_size = atoi(s);
} else if (!strcmp(k, "api.alsa.headroom")) {
} else if (spa_streq(k, "api.alsa.headroom")) {
this->default_headroom = atoi(s);
} else if (!strcmp(k, "api.alsa.disable-mmap")) {
} else if (spa_streq(k, "api.alsa.disable-mmap")) {
this->disable_mmap = (spa_streq(s, "true") || atoi(s) == 1);
} else if (!strcmp(k, "api.alsa.disable-batch")) {
} else if (spa_streq(k, "api.alsa.disable-batch")) {
this->disable_batch = (spa_streq(s, "true") || atoi(s) == 1);
} else if (!strcmp(k, "api.alsa.use-chmap")) {
} else if (spa_streq(k, "api.alsa.use-chmap")) {
this->props.use_chmap = (spa_streq(s, "true") || atoi(s) == 1);
}
}

View file

@ -878,7 +878,7 @@ impl_init(const struct spa_handle_factory *factory,
reset_props(&this->props);
for (i = 0; info && i < info->n_items; i++) {
if (!strcmp(info->items[i].key, SPA_KEY_API_ALSA_PATH)) {
if (spa_streq(info->items[i].key, SPA_KEY_API_ALSA_PATH)) {
snprintf(this->props.device, 63, "%s", info->items[i].value);
}
}

View file

@ -32,6 +32,7 @@
#include <spa/support/log-impl.h>
#include <spa/debug/mem.h>
#include <spa/utils/string.h>
#include <sndfile.h>
@ -96,17 +97,17 @@ sf_str_to_fmt(const char *str)
{
if (!str)
return -1;
if (!strcmp(str, "s8"))
if (spa_streq(str, "s8"))
return SF_FORMAT_PCM_S8;
if (!strcmp(str, "s16"))
if (spa_streq(str, "s16"))
return SF_FORMAT_PCM_16;
if (!strcmp(str, "s24"))
if (spa_streq(str, "s24"))
return SF_FORMAT_PCM_24;
if (!strcmp(str, "s32"))
if (spa_streq(str, "s32"))
return SF_FORMAT_PCM_32;
if (!strcmp(str, "f32"))
if (spa_streq(str, "f32"))
return SF_FORMAT_FLOAT;
if (!strcmp(str, "f64"))
if (spa_streq(str, "f64"))
return SF_FORMAT_DOUBLE;
return -1;
}

View file

@ -27,6 +27,7 @@
#include <errno.h>
#include <arpa/inet.h>
#include <spa/utils/string.h>
#include <spa/pod/parser.h>
#include <spa/param/props.h>
#include <spa/param/audio/format.h>
@ -270,13 +271,13 @@ static int codec_get_block_size(void *data)
static int string_to_eqmid(const char * eqmid)
{
if (!strcmp("auto", eqmid))
if (spa_streq("auto", eqmid))
return LDACBT_EQMID_AUTO;
else if (!strcmp("hq", eqmid))
else if (spa_streq("hq", eqmid))
return LDACBT_EQMID_HQ;
else if (!strcmp("sq", eqmid))
else if (spa_streq("sq", eqmid))
return LDACBT_EQMID_SQ;
else if (!strcmp("mq", eqmid))
else if (spa_streq("mq", eqmid))
return LDACBT_EQMID_MQ;
else
return LDACBT_EQMID_AUTO;

View file

@ -26,6 +26,8 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <spa/utils/string.h>
#define MAX_BUFFER 4096
static char *get_cpuinfo_line(char *cpuinfo, const char *tag)
@ -98,16 +100,16 @@ arm_init(struct impl *impl)
do {
#if defined (__aarch64__)
if (!strcmp(current, "asimd"))
if (spa_streq(current, "asimd"))
flags |= SPA_CPU_FLAG_NEON;
else if (!strcmp(current, "fp"))
else if (spa_streq(current, "fp"))
flags |= SPA_CPU_FLAG_VFPV3 | SPA_CPU_FLAG_VFP;
#else
if (!strcmp(current, "vfp"))
if (spa_streq(current, "vfp"))
flags |= SPA_CPU_FLAG_VFP;
else if (!strcmp(current, "neon"))
else if (spa_streq(current, "neon"))
flags |= SPA_CPU_FLAG_NEON;
else if (!strcmp(current, "vfpv3"))
else if (spa_streq(current, "vfpv3"))
flags |= SPA_CPU_FLAG_VFPV3;
#endif
} while ((current = strtok_r(NULL, " ", &state)));

View file

@ -829,11 +829,11 @@ impl_init(const struct spa_handle_factory *factory,
for (i = 0; info && i < info->n_items; i++) {
const char *k = info->items[i].key;
const char *s = info->items[i].value;
if (!strcmp(k, SPA_KEY_AUDIO_CHANNELS)) {
if (spa_streq(k, SPA_KEY_AUDIO_CHANNELS)) {
this->props.channels = atoi(s);
} else if (!strcmp(k, SPA_KEY_AUDIO_RATE)) {
} else if (spa_streq(k, SPA_KEY_AUDIO_RATE)) {
this->props.rate = atoi(s);
} else if (!strcmp(k, SPA_KEY_AUDIO_POSITION)) {
} else if (spa_streq(k, SPA_KEY_AUDIO_POSITION)) {
parse_position(this, s, strlen(s));
}
}

View file

@ -184,11 +184,11 @@ static void test_dict(void)
int i = 0;
spa_assert(dict.n_items == 5);
spa_assert(!strcmp(spa_dict_lookup(&dict, "pipe"), "wire"));
spa_assert(!strcmp(spa_dict_lookup(&dict, "123"), ""));
spa_assert(!strcmp(spa_dict_lookup(&dict, "key"), "value"));
spa_assert(!strcmp(spa_dict_lookup(&dict, "SPA"), "Simple Plugin API"));
spa_assert(!strcmp(spa_dict_lookup(&dict, "test"), "Works!"));
spa_assert(spa_streq(spa_dict_lookup(&dict, "pipe"), "wire"));
spa_assert(spa_streq(spa_dict_lookup(&dict, "123"), ""));
spa_assert(spa_streq(spa_dict_lookup(&dict, "key"), "value"));
spa_assert(spa_streq(spa_dict_lookup(&dict, "SPA"), "Simple Plugin API"));
spa_assert(spa_streq(spa_dict_lookup(&dict, "test"), "Works!"));
spa_assert(spa_dict_lookup(&dict, "nonexistent") == NULL);
spa_assert(spa_dict_lookup_item(&dict, "123") == &items[3]);
@ -238,13 +238,13 @@ static void test_list(void)
spa_list_for_each(e, head, node) {
switch (i++) {
case 0:
spa_assert(!strcmp(e->string, "First element"));
spa_assert(spa_streq(e->string, "First element"));
break;
case 1:
spa_assert(!strcmp(e->string, "test"));
spa_assert(spa_streq(e->string, "test"));
break;
case 2:
spa_assert(!strcmp(e->string, "pipewire!"));
spa_assert(spa_streq(e->string, "pipewire!"));
break;
default:
spa_assert_not_reached();

View file

@ -304,7 +304,7 @@ static struct node *alsa_create_node(struct device *device, uint32_t id,
profile = "unknown";
profile_desc = pw_properties_get(node->props, "device.profile.description");
if (!strcmp(stream, "capture"))
if (spa_streq(stream, "capture"))
node->direction = PW_DIRECTION_OUTPUT;
else
node->direction = PW_DIRECTION_INPUT;

View file

@ -25,6 +25,8 @@
#include "pipewire/pipewire.h"
#include "pipewire/array.h"
#include <spa/utils/string.h>
#include <extensions/metadata.h>
#include "media-session.h"
@ -139,7 +141,7 @@ static struct item *find_item(struct metadata *this, uint32_t subject, const cha
struct item *item;
pw_array_for_each(item, &this->metadata) {
if (item->subject == subject && (key == NULL || !strcmp(item->key, key)))
if (item->subject == subject && (key == NULL || spa_streq(item->key, key)))
return item;
}
return NULL;

View file

@ -291,7 +291,7 @@ handle_node(struct impl *impl, struct sm_object *object)
spa_list_append(&impl->node_list, &node->link);
impl->node_list_changed = true;
if (role && !strcmp(role, "DSP"))
if (role && spa_streq(role, "DSP"))
node->active = node->configured = true;
if (strstr(media_class, "Stream/") == media_class) {

View file

@ -69,10 +69,10 @@ gst_pipewire_device_reconfigure_element (GstDevice * device, GstElement * elemen
GstPipeWireDevice *pipewire_dev = GST_PIPEWIRE_DEVICE (device);
gchar *str;
if (!strcmp (pipewire_dev->element, "pipewiresrc")) {
if (spa_streq(pipewire_dev->element, "pipewiresrc")) {
if (!GST_IS_PIPEWIRE_SRC (element))
return FALSE;
} else if (!strcmp (pipewire_dev->element, "pipewiresink")) {
} else if (spa_streq(pipewire_dev->element, "pipewiresink")) {
if (!GST_IS_PIPEWIRE_SINK (element))
return FALSE;
} else {

View file

@ -28,6 +28,7 @@
#include <gst/video/video.h>
#include <gst/audio/audio.h>
#include <spa/utils/string.h>
#include <spa/utils/type.h>
#include <spa/param/video/format-utils.h>
#include <spa/param/audio/format-utils.h>
@ -188,7 +189,7 @@ find_media_types (const char *name)
{
int i;
for (i = 0; media_type_map[i].name; i++) {
if (!strcmp (media_type_map[i].name, name))
if (spa_streq(media_type_map[i].name, name))
return &media_type_map[i];
}
return NULL;
@ -478,9 +479,9 @@ handle_audio_fields (ConvertData *d)
for (i = 0; (v = get_nth_string (value, i)); i++) {
enum spa_audio_layout layout;
if (!strcmp (v, "interleaved"))
if (spa_streq(v, "interleaved"))
layout = SPA_AUDIO_LAYOUT_INTERLEAVED;
else if (!strcmp (v, "non-interleaved"))
else if (spa_streq(v, "non-interleaved"))
layout = SPA_AUDIO_LAYOUT_NON_INTERLEAVED;
else
break;

View file

@ -1052,9 +1052,9 @@ impl_new_client(struct pw_protocol *protocol,
pw_log_debug(NAME" %p: connect %s", protocol, str);
if (!strcmp(str, "screencast"))
if (spa_streq(str, "screencast"))
this->connect = pw_protocol_native_connect_portal_screencast;
else if (!strcmp(str, "internal"))
else if (spa_streq(str, "internal"))
this->connect = pw_protocol_native_connect_internal;
else
this->connect = pw_protocol_native_connect_local_socket;

View file

@ -51,7 +51,7 @@ uint32_t pw_protocol_native0_find_type(struct pw_impl_client *client, const char
{
uint32_t i;
for (i = 0; i < SPA_N_ELEMENTS(type_map); i++) {
if (!strcmp(type_map[i].type, type))
if (spa_streq(type_map[i].type, type))
return i;
}
return SPA_ID_INVALID;
@ -361,7 +361,7 @@ uint32_t pw_protocol_native0_name_to_v2(struct pw_impl_client *client, const cha
uint32_t i;
/* match name to type table and return index */
for (i = 0; i < SPA_N_ELEMENTS(type_map); i++) {
if (type_map[i].name != NULL && !strcmp(type_map[i].name, name))
if (type_map[i].name != NULL && spa_streq(type_map[i].name, name))
return i;
}
return SPA_ID_INVALID;

View file

@ -3780,7 +3780,7 @@ static int fill_card_info(struct client *client, struct message *m,
module_id = (uint32_t)atoi(str);
drv_name = spa_dict_lookup(info->props, PW_KEY_DEVICE_API);
if (drv_name && !strcmp("bluez5", drv_name))
if (drv_name && spa_streq("bluez5", drv_name))
drv_name = "module-bluez5-device.c"; /* blueman needs this */
message_put(m,

View file

@ -33,6 +33,7 @@
#include <spa/node/io.h>
#include <spa/node/utils.h>
#include <spa/utils/ringbuffer.h>
#include <spa/utils/string.h>
#include <spa/pod/filter.h>
#include <spa/debug/format.h>
#include <spa/debug/types.h>
@ -1433,12 +1434,12 @@ void *pw_filter_add_port(struct pw_filter *filter,
/* first configure default params */
add_port_params(impl, p);
if ((str = pw_properties_get(props, PW_KEY_FORMAT_DSP)) != NULL) {
if (!strcmp(str, "32 bit float mono audio"))
if (spa_streq(str, "32 bit float mono audio"))
add_audio_dsp_port_params(impl, p);
else if (!strcmp(str, "32 bit float RGBA video"))
else if (spa_streq(str, "32 bit float RGBA video"))
add_video_dsp_port_params(impl, p);
else if (!strcmp(str, "8 bit raw midi") ||
!strcmp(str, "8 bit raw control"))
else if (spa_streq(str, "8 bit raw midi") ||
spa_streq(str, "8 bit raw control"))
add_control_dsp_port_params(impl, p);
}
/* then override with user provided if any */

View file

@ -94,7 +94,7 @@ find_plugin(struct registry *registry, const char *filename)
{
struct plugin *p;
spa_list_for_each(p, &registry->plugins, link) {
if (!strcmp(p->filename, filename))
if (spa_streq(p->filename, filename))
return p;
}
return NULL;

View file

@ -22,6 +22,7 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <spa/utils/string.h>
#include <spa/support/dbus.h>
#include <spa/support/cpu.h>
@ -181,8 +182,8 @@ static void test_properties(void)
props = pw_context_get_properties(context);
spa_assert(props != NULL);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "biz"), "fuzz"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "biz"), "fuzz"));
spa_assert(pw_properties_get(props, "buzz") == NULL);
/* remove foo */
@ -195,8 +196,8 @@ static void test_properties(void)
spa_assert(props == pw_context_get_properties(context));
spa_assert(pw_properties_get(props, "foo") == NULL);
spa_assert(!strcmp(pw_properties_get(props, "biz"), "buzz"));
spa_assert(!strcmp(pw_properties_get(props, "buzz"), "frizz"));
spa_assert(spa_streq(pw_properties_get(props, "biz"), "buzz"));
spa_assert(spa_streq(pw_properties_get(props, "buzz"), "frizz"));
spa_hook_remove(&listener);
pw_context_destroy(context);

View file

@ -28,6 +28,7 @@
#include <pipewire/pipewire.h>
#include <extensions/session-manager.h>
#include <spa/utils/string.h>
#include <spa/pod/builder.h>
#include <spa/pod/parser.h>
#include <spa/pod/filter.h>
@ -274,8 +275,8 @@ endpoint_event_info(void *object, const struct pw_endpoint_info *info)
spa_assert(info->id == pw_proxy_get_bound_id(d->bound_proxy));
spa_assert(info->id == pw_proxy_get_bound_id(d->export_proxy));
spa_assert(info->change_mask == PW_ENDPOINT_CHANGE_MASK_ALL);
spa_assert(!strcmp(info->name, "test-endpoint"));
spa_assert(!strcmp(info->media_class, "Audio/Sink"));
spa_assert(spa_streq(info->name, "test-endpoint"));
spa_assert(spa_streq(info->media_class, "Audio/Sink"));
spa_assert(info->direction == PW_DIRECTION_OUTPUT);
spa_assert(info->n_streams == 0);
spa_assert(info->session_id == SPA_ID_INVALID);
@ -287,9 +288,9 @@ endpoint_event_info(void *object, const struct pw_endpoint_info *info)
spa_assert(info->params[1].flags == param_info[1].flags);
spa_assert(info->props != NULL);
val = spa_dict_lookup(info->props, PW_KEY_ENDPOINT_NAME);
spa_assert(val && !strcmp(val, "test-endpoint"));
spa_assert(val && spa_streq(val, "test-endpoint"));
val = spa_dict_lookup(info->props, PW_KEY_MEDIA_CLASS);
spa_assert(val && !strcmp(val, "Audio/Sink"));
spa_assert(val && spa_streq(val, "Audio/Sink"));
d->info_received = true;
pw_main_loop_quit(d->loop);
@ -352,9 +353,9 @@ test_endpoint_global(void *object, uint32_t id,
spa_assert(props != NULL);
val = spa_dict_lookup(props, PW_KEY_ENDPOINT_NAME);
spa_assert(val && !strcmp(val, "test-endpoint"));
spa_assert(val && spa_streq(val, "test-endpoint"));
val = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS);
spa_assert(val && !strcmp(val, "Audio/Sink"));
spa_assert(val && spa_streq(val, "Audio/Sink"));
pw_endpoint_add_listener(d->bound_proxy, &d->object_listener,
&endpoint_events, d);

View file

@ -24,6 +24,8 @@
#include <pipewire/properties.h>
#include <spa/utils/string.h>
static void test_abi(void)
{
#if defined(__x86_64__) && defined(__LP64__)
@ -79,19 +81,19 @@ static void test_set(void)
spa_assert(pw_properties_set(props, "foo", "bar") == 1);
spa_assert(props->dict.n_items == 1);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(pw_properties_set(props, "foo", "bar") == 0);
spa_assert(props->dict.n_items == 1);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(pw_properties_set(props, "foo", "fuz") == 1);
spa_assert(props->dict.n_items == 1);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "fuz"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "fuz"));
spa_assert(pw_properties_set(props, "bar", "foo") == 1);
spa_assert(props->dict.n_items == 2);
spa_assert(!strcmp(pw_properties_get(props, "bar"), "foo"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "foo"));
spa_assert(pw_properties_set(props, "him", "too") == 1);
spa_assert(props->dict.n_items == 3);
spa_assert(!strcmp(pw_properties_get(props, "him"), "too"));
spa_assert(spa_streq(pw_properties_get(props, "him"), "too"));
spa_assert(pw_properties_set(props, "him", NULL) == 1);
spa_assert(props->dict.n_items == 2);
spa_assert(pw_properties_get(props, "him") == NULL);
@ -103,9 +105,9 @@ static void test_set(void)
spa_assert(pw_properties_set(props, NULL, "invalid") == 0);
str = pw_properties_iterate(props, &state);
spa_assert(str != NULL && (!strcmp(str, "foo") || !strcmp(str, "bar")));
spa_assert(str != NULL && (spa_streq(str, "foo") || spa_streq(str, "bar")));
str = pw_properties_iterate(props, &state);
spa_assert(str != NULL && (!strcmp(str, "foo") || !strcmp(str, "bar")));
spa_assert(str != NULL && (spa_streq(str, "foo") || spa_streq(str, "bar")));
str = pw_properties_iterate(props, &state);
spa_assert(str == NULL);
@ -119,9 +121,9 @@ static void test_set(void)
spa_assert(pw_properties_set(props, "him", "too") == 1);
spa_assert(props->dict.n_items == 3);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "bar"), "foo"));
spa_assert(!strcmp(pw_properties_get(props, "him"), "too"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "foo"));
spa_assert(spa_streq(pw_properties_get(props, "him"), "too"));
pw_properties_clear(props);
spa_assert(props->dict.n_items == 0);
@ -134,19 +136,19 @@ static void test_set(void)
copy = pw_properties_copy(props);
spa_assert(copy != NULL);
spa_assert(copy->dict.n_items == 3);
spa_assert(!strcmp(pw_properties_get(copy, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(copy, "bar"), "foo"));
spa_assert(!strcmp(pw_properties_get(copy, "him"), "too"));
spa_assert(spa_streq(pw_properties_get(copy, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(copy, "bar"), "foo"));
spa_assert(spa_streq(pw_properties_get(copy, "him"), "too"));
spa_assert(pw_properties_set(copy, "bar", NULL) == 1);
spa_assert(pw_properties_set(copy, "foo", NULL) == 1);
spa_assert(copy->dict.n_items == 1);
spa_assert(!strcmp(pw_properties_get(copy, "him"), "too"));
spa_assert(spa_streq(pw_properties_get(copy, "him"), "too"));
spa_assert(props->dict.n_items == 3);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "bar"), "foo"));
spa_assert(!strcmp(pw_properties_get(props, "him"), "too"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "foo"));
spa_assert(spa_streq(pw_properties_get(props, "him"), "too"));
pw_properties_free(props);
pw_properties_free(copy);
@ -159,7 +161,7 @@ static void test_setf(void)
props = pw_properties_new(NULL, NULL);
spa_assert(pw_properties_setf(props, "foo", "%d.%08x", 657, 0x89342) == 1);
spa_assert(props->dict.n_items == 1);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "657.00089342"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "657.00089342"));
spa_assert(pw_properties_setf(props, "", "%f", 189.45f) == 0);
spa_assert(pw_properties_setf(props, NULL, "%f", 189.45f) == 0);
@ -177,9 +179,9 @@ static void test_new(void)
spa_assert(props->flags == 0);
spa_assert(props->dict.n_items == 3);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "bar"), "baz"));
spa_assert(!strcmp(pw_properties_get(props, "him"), "too"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "baz"));
spa_assert(spa_streq(pw_properties_get(props, "him"), "too"));
pw_properties_free(props);
}
@ -200,9 +202,9 @@ static void test_new_dict(void)
spa_assert(props->flags == 0);
spa_assert(props->dict.n_items == 3);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "bar"), "baz"));
spa_assert(!strcmp(pw_properties_get(props, "him"), "too"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "baz"));
spa_assert(spa_streq(pw_properties_get(props, "him"), "too"));
pw_properties_free(props);
}
@ -216,10 +218,10 @@ static void test_new_string(void)
spa_assert(props->flags == 0);
spa_assert(props->dict.n_items == 4);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "bar"), "baz"));
spa_assert(!strcmp(pw_properties_get(props, "him"), "too"));
spa_assert(!strcmp(pw_properties_get(props, "empty"), ""));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "baz"));
spa_assert(spa_streq(pw_properties_get(props, "him"), "too"));
spa_assert(spa_streq(pw_properties_get(props, "empty"), ""));
pw_properties_free(props);
@ -228,8 +230,8 @@ static void test_new_string(void)
spa_assert(props->flags == 0);
spa_assert(props->dict.n_items == 2);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "bar"), "baz"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "baz"));
pw_properties_free(props);
@ -238,8 +240,8 @@ static void test_new_string(void)
spa_assert(props->flags == 0);
spa_assert(props->dict.n_items == 2);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "bar"), "baz"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "baz"));
pw_properties_free(props);
}
@ -262,32 +264,32 @@ static void test_update(void)
spa_assert(pw_properties_update(props, &SPA_DICT_INIT_ARRAY(items)) == 3);
spa_assert(props->dict.n_items == 3);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "bar"), "baz"));
spa_assert(!strcmp(pw_properties_get(props, "him"), "too"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "baz"));
spa_assert(spa_streq(pw_properties_get(props, "him"), "too"));
items[0] = SPA_DICT_ITEM_INIT("foo", "bar");
items[1] = SPA_DICT_ITEM_INIT("bar", "baz");
spa_assert(pw_properties_update(props, &SPA_DICT_INIT(items, 2)) == 0);
spa_assert(props->dict.n_items == 3);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "bar"), "baz"));
spa_assert(!strcmp(pw_properties_get(props, "him"), "too"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "baz"));
spa_assert(spa_streq(pw_properties_get(props, "him"), "too"));
items[0] = SPA_DICT_ITEM_INIT("bar", "bear");
items[1] = SPA_DICT_ITEM_INIT("him", "too");
spa_assert(pw_properties_update(props, &SPA_DICT_INIT(items, 2)) == 1);
spa_assert(props->dict.n_items == 3);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "bar"), "bear"));
spa_assert(!strcmp(pw_properties_get(props, "him"), "too"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "bear"));
spa_assert(spa_streq(pw_properties_get(props, "him"), "too"));
items[0] = SPA_DICT_ITEM_INIT("bar", "bear");
items[1] = SPA_DICT_ITEM_INIT("him", NULL);
spa_assert(pw_properties_update(props, &SPA_DICT_INIT(items, 2)) == 1);
spa_assert(props->dict.n_items == 2);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "bar"), "bear"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "bear"));
spa_assert(pw_properties_get(props, "him") == NULL);
items[0] = SPA_DICT_ITEM_INIT("foo", NULL);
@ -296,8 +298,8 @@ static void test_update(void)
spa_assert(pw_properties_update(props, &SPA_DICT_INIT(items, 3)) == 3);
spa_assert(props->dict.n_items == 2);
spa_assert(pw_properties_get(props, "foo") == NULL);
spa_assert(!strcmp(pw_properties_get(props, "bar"), "beer"));
spa_assert(!strcmp(pw_properties_get(props, "him"), "her"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "beer"));
spa_assert(spa_streq(pw_properties_get(props, "him"), "her"));
pw_properties_free(props);
}
@ -339,10 +341,10 @@ static void test_new_json(void)
spa_assert(props->flags == 0);
spa_assert(props->dict.n_items == 3);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar\n\t"));
spa_assert(!strcmp(pw_properties_get(props, "bar"), "1.8"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar\n\t"));
spa_assert(spa_streq(pw_properties_get(props, "bar"), "1.8"));
fprintf(stderr, "'%s'\n", pw_properties_get(props, "empty"));
spa_assert(!strcmp(pw_properties_get(props, "empty"), "[ \"foo\", \"bar\" ]"));
spa_assert(spa_streq(pw_properties_get(props, "empty"), "[ \"foo\", \"bar\" ]"));
pw_properties_free(props);
}

View file

@ -26,6 +26,8 @@
#include <pipewire/main-loop.h>
#include <pipewire/stream.h>
#include <spa/utils/string.h>
#define TEST_FUNC(a,b,func) \
do { \
a.func = b.func; \
@ -159,7 +161,7 @@ static void test_create(void)
spa_assert(pw_stream_get_state(stream, &error) == PW_STREAM_STATE_UNCONNECTED);
spa_assert(error == NULL);
/* check name */
spa_assert(!strcmp(pw_stream_get_name(stream), "test"));
spa_assert(spa_streq(pw_stream_get_name(stream), "test"));
/* check id, only when connected */
spa_assert(pw_stream_get_node_id(stream) == SPA_ID_INVALID);
@ -209,8 +211,8 @@ static void test_properties(void)
props = pw_stream_get_properties(stream);
spa_assert(props != NULL);
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar"));
spa_assert(!strcmp(pw_properties_get(props, "biz"), "fuzz"));
spa_assert(spa_streq(pw_properties_get(props, "foo"), "bar"));
spa_assert(spa_streq(pw_properties_get(props, "biz"), "fuzz"));
spa_assert(pw_properties_get(props, "buzz") == NULL);
/* remove foo */
@ -223,8 +225,8 @@ static void test_properties(void)
spa_assert(props == pw_stream_get_properties(stream));
spa_assert(pw_properties_get(props, "foo") == NULL);
spa_assert(!strcmp(pw_properties_get(props, "biz"), "buzz"));
spa_assert(!strcmp(pw_properties_get(props, "buzz"), "frizz"));
spa_assert(spa_streq(pw_properties_get(props, "biz"), "buzz"));
spa_assert(spa_streq(pw_properties_get(props, "buzz"), "frizz"));
/* check destroy */
destroy_count = 0;

View file

@ -26,6 +26,8 @@
#include <pipewire/utils.h>
#include <spa/utils/string.h>
static void test_destroy(void *object)
{
spa_assert_not_reached();
@ -59,17 +61,17 @@ static void test_split(void)
res = pw_split_strv(test1, del, INT_MAX, &n_tokens);
spa_assert(res != NULL);
spa_assert(n_tokens == 3);
spa_assert(!strcmp(res[0], "a"));
spa_assert(!strcmp(res[1], "test"));
spa_assert(!strcmp(res[2], "string"));
spa_assert(spa_streq(res[0], "a"));
spa_assert(spa_streq(res[1], "test"));
spa_assert(spa_streq(res[2], "string"));
spa_assert(res[3] == NULL);
pw_free_strv(res);
res = pw_split_strv(test1, del, 2, &n_tokens);
spa_assert(res != NULL);
spa_assert(n_tokens == 2);
spa_assert(!strcmp(res[0], "a"));
spa_assert(!strcmp(res[1], "test string \n \r "));
spa_assert(spa_streq(res[0], "a"));
spa_assert(spa_streq(res[1], "test string \n \r "));
spa_assert(res[2] == NULL);
pw_free_strv(res);
}
@ -79,9 +81,9 @@ static void test_strip(void)
char test1[] = " \n\r \n a test string \n \r ";
char test2[] = " \n\r \n \n \r ";
char test3[] = "a test string";
spa_assert(!strcmp(pw_strip(test1, "\n\r "), "a test string"));
spa_assert(!strcmp(pw_strip(test2, "\n\r "), ""));
spa_assert(!strcmp(pw_strip(test3, "\n\r "), "a test string"));
spa_assert(spa_streq(pw_strip(test1, "\n\r "), "a test string"));
spa_assert(spa_streq(pw_strip(test2, "\n\r "), ""));
spa_assert(spa_streq(pw_strip(test3, "\n\r "), "a test string"));
}
int main(int argc, char *argv[])

View file

@ -167,17 +167,17 @@ sf_str_to_fmt(const char *str)
if (!str)
return -1;
if (!strcmp(str, "s8"))
if (spa_streq(str, "s8"))
return SF_FORMAT_PCM_S8;
if (!strcmp(str, "s16"))
if (spa_streq(str, "s16"))
return SF_FORMAT_PCM_16;
if (!strcmp(str, "s24"))
if (spa_streq(str, "s24"))
return SF_FORMAT_PCM_24;
if (!strcmp(str, "s32"))
if (spa_streq(str, "s32"))
return SF_FORMAT_PCM_32;
if (!strcmp(str, "f32"))
if (spa_streq(str, "f32"))
return SF_FORMAT_FLOAT;
if (!strcmp(str, "f64"))
if (spa_streq(str, "f64"))
return SF_FORMAT_DOUBLE;
return -1;
@ -742,9 +742,9 @@ static void registry_event_global(void *userdata, uint32_t id,
/* get allowed mode from the media class */
/* TODO extend to something else besides Audio/Source|Sink */
if (!strcmp(media_class, "Audio/Source"))
if (spa_streq(media_class, "Audio/Source"))
mode = mode_record;
else if (!strcmp(media_class, "Audio/Sink"))
else if (spa_streq(media_class, "Audio/Sink"))
mode = mode_playback;
/* modes must match */
@ -1029,7 +1029,7 @@ static void show_usage(const char *name, bool is_error)
DEFAULT_VOLUME,
DEFAULT_QUALITY);
if (!strcmp(name, "pw-cat")) {
if (spa_streq(name, "pw-cat")) {
fputs(
_(" -p, --playback Playback mode\n"
" -r, --record Recording mode\n"
@ -1292,15 +1292,15 @@ static int setup_sndfile(struct data *data)
s++;
if (!*s)
data->latency_unit = unit_samples;
else if (!strcmp(s, "none"))
else if (spa_streq(s, "none"))
data->latency_unit = unit_none;
else if (!strcmp(s, "s") || !strcmp(s, "sec") || !strcmp(s, "secs"))
else if (spa_streq(s, "s") || spa_streq(s, "sec") || spa_streq(s, "secs"))
data->latency_unit = unit_sec;
else if (!strcmp(s, "ms") || !strcmp(s, "msec") || !strcmp(s, "msecs"))
else if (spa_streq(s, "ms") || spa_streq(s, "msec") || spa_streq(s, "msecs"))
data->latency_unit = unit_msec;
else if (!strcmp(s, "us") || !strcmp(s, "usec") || !strcmp(s, "usecs"))
else if (spa_streq(s, "us") || spa_streq(s, "usec") || spa_streq(s, "usecs"))
data->latency_unit = unit_usec;
else if (!strcmp(s, "ns") || !strcmp(s, "nsec") || !strcmp(s, "nsecs"))
else if (spa_streq(s, "ns") || spa_streq(s, "nsec") || spa_streq(s, "nsecs"))
data->latency_unit = unit_nsec;
else {
fprintf(stderr, "error: bad latency value %s (bad unit)\n", data->latency);
@ -1370,14 +1370,14 @@ int main(int argc, char *argv[])
prog = argv[0];
/* prime the mode from the program name */
if (!strcmp(prog, "pw-play"))
if (spa_streq(prog, "pw-play"))
data.mode = mode_playback;
else if (!strcmp(prog, "pw-record"))
else if (spa_streq(prog, "pw-record"))
data.mode = mode_record;
else if (!strcmp(prog, "pw-midiplay")) {
else if (spa_streq(prog, "pw-midiplay")) {
data.mode = mode_playback;
data.is_midi = true;
} else if (!strcmp(prog, "pw-midirecord")) {
} else if (spa_streq(prog, "pw-midirecord")) {
data.mode = mode_record;
data.is_midi = true;
} else
@ -1445,7 +1445,7 @@ int main(int argc, char *argv[])
case OPT_TARGET:
data.target = optarg;
if (!strcmp(optarg, "auto")) {
if (spa_streq(optarg, "auto")) {
data.target_id = PW_ID_ANY;
break;
}

View file

@ -1835,27 +1835,27 @@ global_props(struct global *global)
if (!pd || !pd->info)
return NULL;
if (!strcmp(global->type, PW_TYPE_INTERFACE_Core))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Core))
return ((struct pw_core_info *)pd->info)->props;
if (!strcmp(global->type, PW_TYPE_INTERFACE_Module))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Module))
return ((struct pw_module_info *)pd->info)->props;
if (!strcmp(global->type, PW_TYPE_INTERFACE_Device))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Device))
return ((struct pw_device_info *)pd->info)->props;
if (!strcmp(global->type, PW_TYPE_INTERFACE_Node))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Node))
return ((struct pw_node_info *)pd->info)->props;
if (!strcmp(global->type, PW_TYPE_INTERFACE_Port))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Port))
return ((struct pw_port_info *)pd->info)->props;
if (!strcmp(global->type, PW_TYPE_INTERFACE_Factory))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Factory))
return ((struct pw_factory_info *)pd->info)->props;
if (!strcmp(global->type, PW_TYPE_INTERFACE_Client))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Client))
return ((struct pw_client_info *)pd->info)->props;
if (!strcmp(global->type, PW_TYPE_INTERFACE_Link))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Link))
return ((struct pw_link_info *)pd->info)->props;
if (!strcmp(global->type, PW_TYPE_INTERFACE_Session))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Session))
return ((struct pw_session_info *)pd->info)->props;
if (!strcmp(global->type, PW_TYPE_INTERFACE_Endpoint))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Endpoint))
return ((struct pw_endpoint_info *)pd->info)->props;
if (!strcmp(global->type, PW_TYPE_INTERFACE_EndpointStream))
if (spa_streq(global->type, PW_TYPE_INTERFACE_EndpointStream))
return ((struct pw_endpoint_stream_info *)pd->info)->props;
return NULL;
@ -1922,20 +1922,20 @@ children_of(struct remote_data *rd, uint32_t parent_id,
return -1;
/* supported combinations */
if (!strcmp(parent_type, PW_TYPE_INTERFACE_Device) &&
!strcmp(child_type, PW_TYPE_INTERFACE_Node)) {
if (spa_streq(parent_type, PW_TYPE_INTERFACE_Device) &&
spa_streq(child_type, PW_TYPE_INTERFACE_Node)) {
parent_key = PW_KEY_OBJECT_ID;
child_key = PW_KEY_DEVICE_ID;
} else if (!strcmp(parent_type, PW_TYPE_INTERFACE_Node) &&
!strcmp(child_type, PW_TYPE_INTERFACE_Port)) {
} else if (spa_streq(parent_type, PW_TYPE_INTERFACE_Node) &&
spa_streq(child_type, PW_TYPE_INTERFACE_Port)) {
parent_key = PW_KEY_OBJECT_ID;
child_key = PW_KEY_NODE_ID;
} else if (!strcmp(parent_type, PW_TYPE_INTERFACE_Module) &&
!strcmp(child_type, PW_TYPE_INTERFACE_Factory)) {
} else if (spa_streq(parent_type, PW_TYPE_INTERFACE_Module) &&
spa_streq(child_type, PW_TYPE_INTERFACE_Factory)) {
parent_key = PW_KEY_OBJECT_ID;
child_key = PW_KEY_MODULE_ID;
} else if (!strcmp(parent_type, PW_TYPE_INTERFACE_Factory) &&
!strcmp(child_type, PW_TYPE_INTERFACE_Device)) {
} else if (spa_streq(parent_type, PW_TYPE_INTERFACE_Factory) &&
spa_streq(child_type, PW_TYPE_INTERFACE_Device)) {
parent_key = PW_KEY_OBJECT_ID;
child_key = PW_KEY_FACTORY_ID;
} else
@ -2029,7 +2029,7 @@ int dump_type_index(const char *type)
return -1;
for (i = 0; i < SPA_N_ELEMENTS(dump_types); i++) {
if (!strcmp(dump_types[i], type))
if (spa_streq(dump_types[i], type))
return (int)i;
}
@ -2094,19 +2094,19 @@ dump_properties(struct data *data, struct global *global,
extra = NULL;
id = -1;
if (!strcmp(global->type, PW_TYPE_INTERFACE_Port) && !strcmp(item->key, PW_KEY_NODE_ID)) {
if (spa_streq(global->type, PW_TYPE_INTERFACE_Port) && spa_streq(item->key, PW_KEY_NODE_ID)) {
id = atoi(item->value);
if (id >= 0)
extra = obj_lookup(rd, id, PW_KEY_NODE_NAME);
} else if (!strcmp(global->type, PW_TYPE_INTERFACE_Factory) && !strcmp(item->key, PW_KEY_MODULE_ID)) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_Factory) && spa_streq(item->key, PW_KEY_MODULE_ID)) {
id = atoi(item->value);
if (id >= 0)
extra = obj_lookup(rd, id, PW_KEY_MODULE_NAME);
} else if (!strcmp(global->type, PW_TYPE_INTERFACE_Device) && !strcmp(item->key, PW_KEY_FACTORY_ID)) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_Device) && spa_streq(item->key, PW_KEY_FACTORY_ID)) {
id = atoi(item->value);
if (id >= 0)
extra = obj_lookup(rd, id, PW_KEY_FACTORY_NAME);
} else if (!strcmp(global->type, PW_TYPE_INTERFACE_Device) && !strcmp(item->key, PW_KEY_CLIENT_ID)) {
} else if (spa_streq(global->type, PW_TYPE_INTERFACE_Device) && spa_streq(item->key, PW_KEY_CLIENT_ID)) {
id = atoi(item->value);
if (id >= 0)
extra = obj_lookup(rd, id, PW_KEY_CLIENT_NAME);
@ -2303,8 +2303,8 @@ dump_device(struct data *data, struct global *global,
api ? api : "",
api ? "\"" : "");
if (media_class && !strcmp(media_class, "Audio/Device") &&
api && !strcmp(api, "alsa:pcm")) {
if (media_class && spa_streq(media_class, "Audio/Device") &&
api && spa_streq(api, "alsa:pcm")) {
alsa_path = spa_dict_lookup(info->props, SPA_KEY_API_ALSA_PATH);
alsa_card_id = spa_dict_lookup(info->props, SPA_KEY_API_ALSA_CARD_ID);
@ -2731,37 +2731,37 @@ dump(struct data *data, struct global *global,
if (!global)
return;
if (!strcmp(global->type, PW_TYPE_INTERFACE_Core))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Core))
dump_core(data, global, flags, level);
if (!strcmp(global->type, PW_TYPE_INTERFACE_Module))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Module))
dump_module(data, global, flags, level);
if (!strcmp(global->type, PW_TYPE_INTERFACE_Device))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Device))
dump_device(data, global, flags, level);
if (!strcmp(global->type, PW_TYPE_INTERFACE_Node))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Node))
dump_node(data, global, flags, level);
if (!strcmp(global->type, PW_TYPE_INTERFACE_Port))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Port))
dump_port(data, global, flags, level);
if (!strcmp(global->type, PW_TYPE_INTERFACE_Factory))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Factory))
dump_factory(data, global, flags, level);
if (!strcmp(global->type, PW_TYPE_INTERFACE_Client))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Client))
dump_client(data, global, flags, level);
if (!strcmp(global->type, PW_TYPE_INTERFACE_Link))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Link))
dump_link(data, global, flags, level);
if (!strcmp(global->type, PW_TYPE_INTERFACE_Session))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Session))
dump_session(data, global, flags, level);
if (!strcmp(global->type, PW_TYPE_INTERFACE_Endpoint))
if (spa_streq(global->type, PW_TYPE_INTERFACE_Endpoint))
dump_endpoint(data, global, flags, level);
if (!strcmp(global->type, PW_TYPE_INTERFACE_EndpointStream))
if (spa_streq(global->type, PW_TYPE_INTERFACE_EndpointStream))
dump_endpoint_stream(data, global, flags, level);
}
@ -2783,17 +2783,17 @@ static bool do_dump(struct data *data, const char *cmd, char *args, char **error
a = aa;
while (n > 0 &&
(!strcmp(a[0], "short") ||
!strcmp(a[0], "deep") ||
!strcmp(a[0], "resolve") ||
!strcmp(a[0], "notype"))) {
if (!strcmp(a[0], "short"))
(spa_streq(a[0], "short") ||
spa_streq(a[0], "deep") ||
spa_streq(a[0], "resolve") ||
spa_streq(a[0], "notype"))) {
if (spa_streq(a[0], "short"))
flags |= is_short;
else if (!strcmp(a[0], "deep"))
else if (spa_streq(a[0], "deep"))
flags |= is_deep;
else if (!strcmp(a[0], "resolve"))
else if (spa_streq(a[0], "resolve"))
flags |= is_resolve;
else if (!strcmp(a[0], "notype"))
else if (spa_streq(a[0], "notype"))
flags |= is_notype;
n--;
a++;
@ -2816,7 +2816,7 @@ static bool do_dump(struct data *data, const char *cmd, char *args, char **error
a++;
}
if (n == 0 || !strcmp(a[0], "all")) {
if (n == 0 || spa_streq(a[0], "all")) {
type_mask = (1U << dump_type_count()) - 1;
flags &= ~is_notype;
} else {
@ -2900,8 +2900,8 @@ static bool parse(struct data *data, char *buf, size_t size, char **error)
args = n > 1 ? a[1] : "";
for (i = 0; i < SPA_N_ELEMENTS(command_list); i++) {
if (!strcmp(command_list[i].name, cmd) ||
!strcmp(command_list[i].alias, cmd)) {
if (spa_streq(command_list[i].name, cmd) ||
spa_streq(command_list[i].alias, cmd)) {
return command_list[i].func(data, cmd, args, error);
}
}