[pulseaudio-discuss] [PATCH] switch-on-port-available: check and change default sink or source
Georg Chini
georg at chini.tk
Fri May 5 14:43:12 UTC 2017
On 03.05.2017 12:51, Tanu Kaskinen wrote:
> On Wed, 2017-05-03 at 11:23 +0800, Hui Wang wrote:
>> Today I tested the latest master branch (already including your two
>> patches), seems it did not fix the problem. Below is my testing detail:
>>
>> Install ubuntu 16.04 on my laptop.
>> clone the latest pulseaudio source code, checkout master branch
>> build the source code: ./autogen.sh;make
>> kill the existing pulseaudio and run the latest pulseaudio: pulseaudio
>> --kill && ./src/pulseaudio -vvvnF ./src/default.pa -p $(pwd)/src
>>
>> On this machine, we have sound cards, sinks and ports like below:
>>
>> Card#0(HDA INTEL HDMI)-> Sink#0(hdmi-stereo)->hdmi-output(priority: 5900)
>> Card#1(HDA INTEL PCH)->Sink#1(analog-stereo)->headphones(priority: 9000)
> No speaker port at all on the PCH card?
>
>> with the new pulseaudio, I can only see one sink (analog-stereo)
>> through pactl list sinks at the beginning.
>>
>> After I plug the HDMI cable (headphone is not plugged), I can see two
>> sinks via pactl list sinks, but the default sink is still the analog-
>> stereo, here I expect the default sink is hdmi-stereo since the
>> headphone is not plugged yet.
> That's what I'd expect too. Is the headphone port marked as unavailable
> as it should?
>
>> Then I plug the headphone, and I select the hdmi (hdmi is also
>> plugged in) as the default sink, after a while I unplug the hdmi
>> cable, here I expect the default sink is back to analog-stereo since
>> headphone is still plugged, but the default sink did not switch to
>> analog-stereo. BTW after I unplug the hdmi cable, I can still see two
>> sinks.
> The default sink is set in pa_core_update_default_sink() in
> src/pulsecore/core.c. That function uses the compare_sinks() function,
> and the first thing compare_sinks() does is to check if one of the
> compared sinks has an unavailable port active. Can you figure out what
> goes wrong? Is pa_core_update_default_sink() not called when you plug
> in or unplug things, or does pa_core_update_default_sink() really
> choose a sink whose active port is unavailable?
>
Looking through the patch it seems to me that availability changes of a port
do not trigger a recalculation of the default sink. Or am I missing
something?
Another similar point, while reading the code of module-switch-on-connect, i
found a possible issue:
When a new sink turns up, pa_core_update_default_sink() is called from
sink_put(). After that, PA_CORE_HOOK_SINK_PUT is fired. Within the hook
in module switch-on-connect, it is checked, if the new sink is the default
sink. If yes, the hook does nothing. Doesn't that mean that if the new
sink has highest priority (and no user default is set), the streams will
not be moved away from the old default sink, because the old default
is lost when pa_core_update_default_sink() is called before the hook?
The same has already been the case before the recent changes, so again
I'm not sure if I am missing something ...
More information about the pulseaudio-discuss
mailing list