mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
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:
parent
7697ed0757
commit
95a84e797a
28 changed files with 239 additions and 221 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue