mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
improve default sink/source handling
Currently the default sink policy is simple: either the user has configured it explicitly, in which case we always use that as the default, or we pick the sink with the highest priority. The sink priorities are currently static, so there's no need to worry about updating the default sink when sink priorities change. I intend to make things a bit more complex: if the active port of a sink is unavailable, the sink should not be the default sink, and I also want to make sink priorities dependent on the active port, so changing the port should cause re-evaluation of which sink to choose as the default. Currently the default sink choice is done only when someone calls pa_namereg_get_default_sink(), and change notifications are only sent when a sink is created or destroyed. That makes it hard to add new rules to the default sink selection policy. This patch moves the default sink selection to pa_core_update_default_sink(), which is called whenever something happens that can affect the default sink choice. That function needs to know the previous choice in order to send change notifications as appropriate, but previously pa_core.default_sink was only set when the user had configured it explicitly. Now pa_core.default_sink is always set (unless there are no sinks at all), so pa_core_update_default_sink() can use that to get the previous choice. The user configuration is saved in a new variable, pa_core.configured_default_sink. pa_namereg_get_default_sink() is now unnecessary, because pa_core.default_sink can be used directly to get the currently-considered-best sink. pa_namereg_set_default_sink() is replaced by pa_core_set_configured_default_sink(). I haven't confirmed it, but I expect that this patch will fix problems in the D-Bus protocol related to default sink handling. The D-Bus protocol used to get confused when the current default sink gets removed. It would incorrectly think that if there's no explicitly configured default sink, then there's no default sink at all. Even worse, when the D-Bus thinks that there's no default sink, it concludes that there are no sinks at all, which made it impossible to configure the default sink via the D-Bus interface. Now that pa_core.default_sink is always set, except when there really aren't any sinks, the D-Bus protocol should behave correctly. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99425
This commit is contained in:
parent
ea3ebd09d1
commit
6b34896130
15 changed files with 370 additions and 239 deletions
|
|
@ -660,6 +660,8 @@ void pa_sink_put(pa_sink* s) {
|
|||
|
||||
pa_source_put(s->monitor_source);
|
||||
|
||||
pa_core_update_default_sink(s->core);
|
||||
|
||||
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_NEW, s->index);
|
||||
pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_PUT], s);
|
||||
}
|
||||
|
|
@ -690,6 +692,11 @@ void pa_sink_unlink(pa_sink* s) {
|
|||
pa_namereg_unregister(s->core, s->name);
|
||||
pa_idxset_remove_by_data(s->core->sinks, s, NULL);
|
||||
|
||||
if (s == s->core->configured_default_sink)
|
||||
pa_core_set_configured_default_sink(s->core, NULL);
|
||||
else
|
||||
pa_core_update_default_sink(s->core);
|
||||
|
||||
if (s->card)
|
||||
pa_idxset_remove_by_data(s->card->sinks, s, NULL);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue