#endif
#include <pulse/xmalloc.h>
-#include <pulse/volume.h>
-#include <pulse/timeval.h>
-#include <pulse/util.h>
-#include <pulsecore/core-error.h>
#include <pulsecore/module.h>
#include <pulsecore/core-util.h>
#include <pulsecore/modargs.h>
#include <pulsecore/log.h>
-#include <pulsecore/core-subscribe.h>
#include <pulsecore/sink-input.h>
#include <pulsecore/source-output.h>
#include <pulsecore/namereg.h>
};
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) {
/* Prefer the default source over any other source, just in case... */
if ((def = pa_namereg_get_default_source(c)))
if (role_match(def->proplist, role)) {
- new_data->source = def;
- new_data->save_source = FALSE;
+ pa_source_output_new_data_set_source(new_data, def, FALSE);
return PA_HOOK_OK;
}
/* @todo: favour the highest priority device, not the first one we find? */
if (role_match(s->proplist, role)) {
- new_data->source = s;
- new_data->save_source = FALSE;
+ pa_source_output_new_data_set_source(new_data, s, FALSE);
return PA_HOOK_OK;
}
}