[pulseaudio-discuss] [PATCH] alsa-ucm: setting default active port based on jacks state

David Henningsson david.henningsson at canonical.com
Wed Aug 28 05:38:08 PDT 2013


On 08/27/2013 07:06 PM, Felipe Tonello wrote:
> Hi David,
> 
> On Tue, Aug 27, 2013 at 12:27 AM, David Henningsson
> <david.henningsson at canonical.com> wrote:
>> On 08/26/2013 08:15 PM, Felipe F. Tonello wrote:
>>> From: "Felipe F. Tonello" <eu at felipetonello.com>
>>>
>>> This fixes a bug when switching profiles under ALSA UCM. If a jack, hence a
>>> port, was previsouly active, when PA performed a profile switch, the jack
>>> would continue to be available but not active.
>>>
>>> This patche ensures that it activates a port if a jack is previously connected.
>>
>> Thanks,
>> but I'm not sure this is the right way to do it.
>>
>> It feels like setting the active port is more like something for a
>> policy module (e g module-switch-on-port-available), rather than being
>> hardcoded in the module itself.
> 
> With today's implementation it doesn't work, since if you switch
> profiles the jack won't change its state, so
> module-switch-on-port-available will not notice that.
> 
> What it could be done is to ensure when you create a sink/source, to
> report jack state, but this is a local function in alsa-module-card.
> It would need more hack to make it work.
> 
> Also, this is not hardcode the port, since the sink/source it self
> does that, it checks if someone else set active_port before, otherwise
> sets itself.
> 
> IHMO this patch is less intrusive.

Even if a jack is available, it does not mean that the port should be
activated, unless you have a policy module saying so. It's the policy
module that causes port switches in the first place.

There are already hooks for new sink/sources in
module-switch-on-port-available which fill in the port that should be
initially selected.

Now that I've read your patch again, it looks like you're only making an
initial suggestion for active_port, which later should get overwritten
by module-switch-on-port-available or module-device-restore, so I don't
understand why your patch makes a difference at all?

(And pa_alsa_ucm_set_active_port should be named
pa_alsa_ucm_get_preferred_port or something like that, because the name
is currently misleading.)

> PS: One comment about module-switch-on-port-available is that it needs
> to be loaded before module-alsa-card(also udev detect, if using it) in
> order to switch to the port if a jack was connected before PA.

Correct. This is fixed in the latest release of PA (see
src/daemon/default.pa.in).

-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic


More information about the pulseaudio-discuss mailing list