Re: [PATCH v2 4/8] core: move sink-inputs conditionally when update default_sink

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 17.01.19 07:53, Hui Wang wrote:
When the default sink changes, the streams from the old default sink
should be moved to the new default sink, unless the preferred_sink
string is set to the old default sink and the active port of the old
default sink is not unavailable

Signed-off-by: Hui Wang <hui.wang@xxxxxxxxxxxxx>
---
...
+
+void pa_sink_move_streams_to_default_sink(pa_core *core, pa_sink *old_sink, bool from_user) {
+    pa_sink_input *i;
+    uint32_t idx;
+    bool old_sink_is_unavailable;
+
+    pa_assert(core);
+    pa_assert(old_sink);
+
+    if (old_sink == core->default_sink)
+        return;
+
+    if (old_sink->active_port && old_sink->active_port->available == PA_AVAILABLE_NO)
+        old_sink_is_unavailable = true;
+
+    if (pa_idxset_size(old_sink->inputs) > 0) {
+        PA_IDXSET_FOREACH(i, old_sink->inputs, idx) {
+            if (!PA_SINK_INPUT_IS_LINKED(i->state))
+                continue;
+
+            if (pa_safe_streq(old_sink->name, i->preferred_sink) && !old_sink_is_unavailable)
+                continue;
+
+            pa_log_info("The sink input %u \"%s\" is moving to %s due to default_sink is changed.",
+                        i->index, pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_APPLICATION_NAME)), core->default_sink->name);
+            pa_sink_input_move_to(i, core->default_sink, from_user);
+        }
+    }
+}

If the last sink is in the process of getting removed,  old_sink would be the previous default sink and core->default_sink would be NULL. Is it possible, that in this situation there are still inputs on the sink? Maybe the function should check if core->default_sink
is not NULL, just to make sure.



_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss




[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux