mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-23 08:56:40 -05:00
core: Add a string list membership check function
This adds a pa_str_in_list() to check for a given string in a space-separated list of strings. For now, this is merely present to avoid duplication of role matching code (intended roles can be a space-separate list) across modules.
This commit is contained in:
parent
667289679f
commit
06fc121eef
4 changed files with 23 additions and 40 deletions
|
|
@ -55,27 +55,6 @@ struct userdata {
|
|||
*source_output_move_finish_slot;
|
||||
};
|
||||
|
||||
static pa_bool_t role_match(pa_proplist *proplist, const char *role) {
|
||||
const char *ir;
|
||||
char *r;
|
||||
const char *state = NULL;
|
||||
|
||||
if (!(ir = pa_proplist_gets(proplist, PA_PROP_DEVICE_INTENDED_ROLES)))
|
||||
return FALSE;
|
||||
|
||||
while ((r = pa_split_spaces(ir, &state))) {
|
||||
|
||||
if (pa_streq(role, r)) {
|
||||
pa_xfree(r);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
pa_xfree(r);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static pa_hook_result_t process(struct userdata *u, pa_object *o, pa_bool_t is_sink_input) {
|
||||
const char *want;
|
||||
pa_proplist *pl, *parent_pl;
|
||||
|
|
@ -93,7 +72,7 @@ static pa_hook_result_t process(struct userdata *u, pa_object *o, pa_bool_t is_s
|
|||
return PA_HOOK_OK;
|
||||
|
||||
/* On phone sinks, make sure we're not applying echo cancellation */
|
||||
if (role_match(parent_pl, "phone")) {
|
||||
if (pa_str_in_list_spaces(pa_proplist_gets(parent_pl, PA_PROP_DEVICE_INTENDED_ROLES), "phone")) {
|
||||
const char *apply = pa_proplist_gets(pl, PA_PROP_FILTER_APPLY);
|
||||
|
||||
if (apply && pa_streq(apply, "echo-cancel")) {
|
||||
|
|
|
|||
|
|
@ -66,24 +66,7 @@ struct userdata {
|
|||
};
|
||||
|
||||
static pa_bool_t role_match(pa_proplist *proplist, const char *role) {
|
||||
const char *ir;
|
||||
char *r;
|
||||
const char *state = NULL;
|
||||
|
||||
if (!(ir = pa_proplist_gets(proplist, PA_PROP_DEVICE_INTENDED_ROLES)))
|
||||
return FALSE;
|
||||
|
||||
while ((r = pa_split_spaces(ir, &state))) {
|
||||
|
||||
if (pa_streq(role, r)) {
|
||||
pa_xfree(r);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
pa_xfree(r);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return pa_str_in_list_spaces(pa_proplist_gets(proplist, PA_PROP_DEVICE_INTENDED_ROLES), role);
|
||||
}
|
||||
|
||||
static pa_hook_result_t sink_input_new_hook_callback(pa_core *c, pa_sink_input_new_data *new_data, struct userdata *u) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue