always-sink: Ignore filter sinks

We don't want to count filter sinks towards the list of actual sinks,
since those also need a real underlying sink to exist.
This commit is contained in:
Arun Raghavan 2015-06-09 12:07:44 +05:30
parent 81f7589a3f
commit ceae6b1e61

View file

@ -61,12 +61,15 @@ static void load_null_sink_if_needed(pa_core *c, pa_sink *sink, struct userdata*
pa_assert(c);
pa_assert(u);
pa_assert(u->null_module == PA_INVALID_INDEX);
if (u->null_module != PA_INVALID_INDEX)
return; /* We've already got a null-sink loaded */
/* Loop through all sinks and check to see if we have *any*
* sinks. Ignore the sink passed in (if it's not null) */
* sinks. Ignore the sink passed in (if it's not null), and
* don't count filter sinks. */
PA_IDXSET_FOREACH(target, c->sinks, idx)
if (!sink || target != sink)
if (!sink || ((target != sink) && !pa_sink_is_filter(target)))
break;
if (target)
@ -111,6 +114,10 @@ static pa_hook_result_t put_hook_callback(pa_core *c, pa_sink *sink, void* userd
if (sink->module && sink->module->index == u->null_module)
return PA_HOOK_OK;
/* We don't count filter sinks since they need a real sink */
if (pa_sink_is_filter(sink))
return PA_HOOK_OK;
pa_log_info("A new sink has been discovered. Unloading null-sink.");
pa_module_unload_request_by_index(c, u->null_module, true);