[pulseaudio-discuss] [PATCH] move streams when the default sink or source changes
tanuk at iki.fi
Thu Apr 6 20:34:29 UTC 2017
On Thu, 2017-04-06 at 11:52 +0200, Georg Chini wrote:
> On 25.10.2016 15:02, Tanu Kaskinen wrote:
> > This adds a new "use_default_sink" field to pa_sink_input. If
> > use_default_sink is set, the stream will be automatically moved when the
> > default sink changes. Usually if the user changes the default sink, the
> > user also wants to move existing streams there. If a stream is manually
> > routed, use_default_sink isn't set, so automatic moving doesn't happen
> > in that case.
> > pa_sink_input_move_to() and other move functions take use_default_sink
> > as a parameter so that every call site is forced to make a conscious
> > decision whether the stream should stick to the move target or not.
> > There are FIXME items added for some corner cases, because it's not
> > currently possible to properly remember and prioritize the various
> > automatic routing decisions that modules do. The different routing
> > modules tend to step on each other's toes, and this new
> > "use_default_sink" feature adds to the problem.
> > The same changes are made for source outputs too.
> > BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=93006
> > ---
> I don't understand why you need that flag at all. Why not simply
> take all streams that are on the old default sink and move them
> to the new default sink?
If you manually move a stream to a different sink (let's call that sink
S), that stream isn't any more routed to the default sink. If S at some
point becomes the default sink, do you really want to forget the manual
routing choice? With your suggestion the manually-moved stream would
move if some other sink becomes the default later.
> It's really weired that streams that are currently not on the default
> sink should jump to the new default sink if the default changes.
> From a user perspective I would not expect that (and personally
> would not want to have it that way).
Can you give a concrete example where the code should be changed?
Looking at the patch, I can identify these cases that enable "use
default device" for streams that previously might not have been routed
to the default device:
When changing profiles, module-alsa-card moves streams from the old
devices to the new devices. "Use default device" is enabled for those
streams. As a comment says, "we don't have any particular reason to
make the streams stick to the device we're moving them to". I
acknowledge that the chosen approach isn't ideal, but I think it's
better than disabling "use default device". The real fix would involve
improving the routing system so that module-alsa-card wouldn't have to
care about moving the streams at all.
module-allow-passthrough enables "use default device" when restoring
the old routing. This isn't ideal, and there's a FIXME comment. Again,
just disabling "use default device" wouldn't be an improvement in this
case, the routing system needs some bigger changes to deal with this
module-rescue-streams enables "use default device" for rescued streams.
It should ideally pick the default device anyway as the "evacuation"
target, but there's the problem that if the removed sink is the current
default, it's not yet known at the time of stream evacuation which sink
will become the new default, and the current code for selecting the
evacuation sink probably doesn't always pick the "right" sink. Fixing
this problem shouldn't be very difficult. Would you prefer me to fix
module-rescue-streams before applying this patch (assuming that you
agree with the general idea of this patch at all)?
More information about the pulseaudio-discuss