modules: Use pa_streq instead of strcmp.

This commit is contained in:
Arti Trivedi Bora 2012-06-06 01:28:13 +05:30 committed by Tanu Kaskinen
parent e0c16af551
commit e5954aca8e
19 changed files with 45 additions and 45 deletions

View file

@ -2207,22 +2207,22 @@ static int jack_parse_state(
return -1;
}
if (!strcmp(rvalue,"yes"))
if (pa_streq(rvalue, "yes"))
pa = PA_PORT_AVAILABLE_YES;
else if (!strcmp(rvalue,"no"))
else if (pa_streq(rvalue, "no"))
pa = PA_PORT_AVAILABLE_NO;
else if (!strcmp(rvalue,"unknown"))
else if (pa_streq(rvalue, "unknown"))
pa = PA_PORT_AVAILABLE_UNKNOWN;
else {
pa_log("[%s:%u] state must be 'yes','no' or 'unknown' in '%s'", filename, line, section);
return -1;
}
if (!strcmp(lvalue, "state.unplugged"))
if (pa_streq(lvalue, "state.unplugged"))
j->state_unplugged = pa;
else {
j->state_plugged = pa;
pa_assert(!strcmp(lvalue, "state.plugged"));
pa_assert(pa_streq(lvalue, "state.plugged"));
}
return 0;
@ -3183,7 +3183,7 @@ static void path_set_condense(pa_alsa_path_set *ps, snd_mixer_t *m) {
continue;
PA_LLIST_FOREACH(jb, p2->jacks) {
if (jb->has_control && !strcmp(jb->alsa_name, ja->alsa_name) &&
if (jb->has_control && pa_streq(jb->alsa_name, ja->alsa_name) &&
(ja->state_plugged == jb->state_plugged) &&
(ja->state_unplugged == jb->state_unplugged)) {
exists = TRUE;

View file

@ -228,7 +228,7 @@ static struct bonding* bonding_new(struct userdata *u, const char *a) {
goto fail;
}
if (strcmp(class, "phone")) {
if (!pa_streq(class, "phone")) {
pa_log_info("Found device '%s' of class '%s', ignoring.", a, class);
goto fail;
}

View file

@ -491,13 +491,13 @@ static int get_access_arg(pa_modargs *ma, pa_bool_t *local_access, pa_bool_t *re
if (!(value = pa_modargs_get_value(ma, "access", NULL)))
return 0;
if (!strcmp(value, "local")) {
if (pa_streq(value, "local")) {
*local_access = TRUE;
*remote_access = FALSE;
} else if (!strcmp(value, "remote")) {
} else if (pa_streq(value, "remote")) {
*local_access = FALSE;
*remote_access = TRUE;
} else if (!strcmp(value, "local,remote")) {
} else if (pa_streq(value, "local,remote")) {
*local_access = TRUE;
*remote_access = TRUE;
} else

View file

@ -173,8 +173,8 @@ static void load_module(
if (!is_new) {
if (m->items[i].index != PA_INVALID_INDEX &&
strcmp(m->items[i].name, name) == 0 &&
strcmp(m->items[i].args, args) == 0)
pa_streq(m->items[i].name, name) &&
pa_streq(m->items[i].args, args))
return;
unload_one_module(u, m, i);

View file

@ -186,7 +186,7 @@ static DBusHandlerResult dbus_filter_handler(DBusConnection *c, DBusMessage *s,
DBUS_TYPE_STRING, &new,
DBUS_TYPE_INVALID))
goto finish;
if (strcmp(name, JACK_SERVICE_NAME))
if (!pa_streq(name, JACK_SERVICE_NAME))
goto finish;
ensure_ports_stopped(u);

View file

@ -85,7 +85,7 @@ static int ca_device_added(struct pa_module *m, AudioObjectID id) {
size = sizeof(tmp);
err = AudioObjectGetPropertyData(id, &property_address, 0, NULL, &size, tmp);
if (!err && strcmp(tmp, "pulseaudio.org") == 0)
if (!err && pa_streq(tmp, "pulseaudio.org"))
return 0;
if (u->ioproc_frames)

View file

@ -183,8 +183,8 @@ static void update_rule(struct rule *r) {
if ((desktopfiles_dir = opendir(DESKTOPFILEDIR))) {
while ((dir = readdir(desktopfiles_dir))) {
if (dir->d_type != DT_DIR
|| strcmp(dir->d_name, ".") == 0
|| strcmp(dir->d_name, "..") == 0)
|| pa_streq(dir->d_name, ".")
|| pa_streq(dir->d_name, ".."))
continue;
pa_xfree(fn);

View file

@ -142,7 +142,7 @@ static int detect_oss(pa_core *c, int just_one) {
line[strcspn(line, "\r\n")] = 0;
if (!b) {
b = strcmp(line, "Audio devices:") == 0 || strcmp(line, "Installed devices:") == 0;
b = pa_streq(line, "Audio devices:") || pa_streq(line, "Installed devices:");
continue;
}

View file

@ -537,7 +537,7 @@ static uint32_t get_role_index(const char* role) {
pa_assert(role);
for (uint32_t i = ROLE_NONE; i < NUM_ROLES; ++i)
if (strcmp(role, role_names[i]) == 0)
if (pa_streq(role, role_names[i]))
return i;
return PA_INVALID_INDEX;
@ -551,7 +551,7 @@ static void update_highest_priority_device_indexes(struct userdata *u, const cha
pa_assert(u);
pa_assert(prefix);
sink_mode = (strcmp(prefix, "sink:") == 0);
sink_mode = pa_streq(prefix, "sink:");
if (sink_mode)
indexes = &u->preferred_sinks;
@ -592,7 +592,7 @@ static void update_highest_priority_device_indexes(struct userdata *u, const cha
PA_IDXSET_FOREACH(sink, u->core->sinks, idx) {
if ((pa_sink*) ignore_device == sink)
continue;
if (strcmp(sink->name, device_name) == 0) {
if (pa_streq(sink->name, device_name)) {
found = TRUE;
idx = sink->index; /* Is this needed? */
break;
@ -604,7 +604,7 @@ static void update_highest_priority_device_indexes(struct userdata *u, const cha
PA_IDXSET_FOREACH(source, u->core->sources, idx) {
if ((pa_source*) ignore_device == source)
continue;
if (strcmp(source->name, device_name) == 0) {
if (pa_streq(source->name, device_name)) {
found = TRUE;
idx = source->index; /* Is this needed? */
break;
@ -1159,7 +1159,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
if ((device_name = get_name(name, "sink:"))) {
pa_sink* s;
PA_IDXSET_FOREACH(s, u->core->sinks, idx) {
if (strcmp(s->name, device_name) == 0) {
if (pa_streq(s->name, device_name)) {
found_index = s->index;
break;
}
@ -1168,7 +1168,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
} else if ((device_name = get_name(name, "source:"))) {
pa_source* s;
PA_IDXSET_FOREACH(s, u->core->sources, idx) {
if (strcmp(s->name, device_name) == 0) {
if (pa_streq(s->name, device_name)) {
found_index = s->index;
break;
}

View file

@ -562,7 +562,7 @@ int pa__init(pa_module*m) {
goto fail;
}
if (strcmp(d->Label, label) == 0)
if (pa_streq(d->Label, label))
break;
}
@ -627,7 +627,7 @@ int pa__init(pa_module*m) {
for (p = 0; p < d->PortCount; p++) {
if (strcmp(d->PortNames[p], pname) == 0) {
if (pa_streq(d->PortNames[p], pname)) {
if (LADSPA_IS_PORT_AUDIO(d->PortDescriptors[p]) && LADSPA_IS_PORT_INPUT(d->PortDescriptors[p])) {
input_ladspaport[c] = p;
} else {
@ -653,7 +653,7 @@ int pa__init(pa_module*m) {
goto fail;
}
for (p = 0; p < d->PortCount; p++) {
if (strcmp(d->PortNames[p], pname) == 0) {
if (pa_streq(d->PortNames[p], pname)) {
if (LADSPA_IS_PORT_AUDIO(d->PortDescriptors[p]) && LADSPA_IS_PORT_OUTPUT(d->PortDescriptors[p])) {
output_ladspaport[c] = p;
} else {

View file

@ -1136,7 +1136,7 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_t
pa_proplist_free(pl);
if (!u->sink_name || strcmp(name, u->sink_name))
if (!u->sink_name || !pa_streq(name, u->sink_name))
return;
pa_xfree(u->device_description);
@ -1347,7 +1347,7 @@ static void source_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa
pa_proplist_free(pl);
if (!u->source_name || strcmp(name, u->source_name))
if (!u->source_name || !pa_streq(name, u->source_name))
return;
pa_xfree(u->device_description);

View file

@ -163,17 +163,17 @@ static void resolver_cb(
char *key, *value;
pa_assert_se(avahi_string_list_get_pair(l, &key, &value, NULL) == 0);
if (strcmp(key, "device") == 0) {
if (pa_streq(key, "device")) {
pa_xfree(device);
device = value;
value = NULL;
} else if (strcmp(key, "rate") == 0)
} else if (pa_streq(key, "rate"))
ss.rate = (uint32_t) atoi(value);
else if (strcmp(key, "channels") == 0)
else if (pa_streq(key, "channels"))
ss.channels = (uint8_t) atoi(value);
else if (strcmp(key, "format") == 0)
else if (pa_streq(key, "format"))
ss.format = pa_parse_sample_format(value);
else if (strcmp(key, "channel_map") == 0) {
else if (pa_streq(key, "channel_map")) {
pa_channel_map_parse(&cm, value);
channel_map_set = TRUE;
}

View file

@ -359,7 +359,7 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {
line[strcspn(line, "\r\n")] = 0;
if (!b) {
b = strcmp(line, "Audio devices:") == 0;
b = pa_streq(line, "Audio devices:");
continue;
}

View file

@ -166,7 +166,7 @@ static void resolver_cb(
pa_assert_se(avahi_string_list_get_pair(l, &key, &value, NULL) == 0);
pa_log_debug("Found key: '%s' with value: '%s'", key, value);
if (strcmp(key, "device") == 0) {
if (pa_streq(key, "device")) {
pa_xfree(device);
device = value;
value = NULL;

View file

@ -303,11 +303,11 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
while ((token = pa_split(aj, delimiters, &token_state))) {
if ((pc = strstr(token, "="))) {
*pc = 0;
if (!strcmp(token, "type") && !strcmp(pc+1, "digital")) {
if (pa_streq(token, "type") && pa_streq(pc+1, "digital")) {
c->jack_type = JACK_TYPE_DIGITAL;
}
} else {
if (!strcmp(token,"connected"))
if (pa_streq(token, "connected"))
c->jack_status = JACK_STATUS_CONNECTED;
}
pa_xfree(token);

View file

@ -398,13 +398,13 @@ const char* pa_rtp_format_to_string(pa_sample_format_t f) {
pa_sample_format_t pa_rtp_string_to_format(const char *s) {
pa_assert(s);
if (!(strcmp(s, "L16")))
if (pa_streq(s, "L16"))
return PA_SAMPLE_S16BE;
else if (!strcmp(s, "L8"))
else if (pa_streq(s, "L8"))
return PA_SAMPLE_U8;
else if (!strcmp(s, "PCMA"))
else if (pa_streq(s, "PCMA"))
return PA_SAMPLE_ALAW;
else if (!strcmp(s, "PCMU"))
else if (pa_streq(s, "PCMU"))
return PA_SAMPLE_ULAW;
else
return PA_SAMPLE_INVALID;

View file

@ -187,7 +187,7 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
*s2p = '\0';
s2p -= 1;
}
if (c->waiting && 0 == strcmp("RTSP/1.0 200 OK", s2)) {
if (c->waiting && pa_streq(s2, "RTSP/1.0 200 OK")) {
c->waiting = 0;
if (c->response_headers)
pa_headerlist_free(c->response_headers);

View file

@ -212,7 +212,7 @@ int pa_sap_recv(pa_sap_context *c, pa_bool_t *goodbye) {
e = buf + k;
size -= (int) k;
if ((unsigned) size >= sizeof(MIME_TYPE) && !strcmp(e, MIME_TYPE)) {
if ((unsigned) size >= sizeof(MIME_TYPE) && pa_streq(e, MIME_TYPE)) {
e += sizeof(MIME_TYPE);
size -= (int) sizeof(MIME_TYPE);
} else if ((unsigned) size < sizeof(PA_SDP_HEADER)-1 || strncmp(e, PA_SDP_HEADER, sizeof(PA_SDP_HEADER)-1)) {

View file

@ -103,7 +103,7 @@ static pa_hook_result_t servers_changed_cb(void *hook_data, void *call_data, voi
pa_assert(u);
screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper));
if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id)) {
if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", t, sizeof(t)) || !pa_streq(t, u->id)) {
pa_log_warn("PulseAudio information vanished from X11!");
return PA_HOOK_OK;
}
@ -217,7 +217,7 @@ void pa__done(pa_module*m) {
int screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper));
/* Yes, here is a race condition */
if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id))
if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", t, sizeof(t)) || !pa_streq(t, u->id))
pa_log_warn("PulseAudio information vanished from X11!");
else {
pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID");