[pulseaudio-discuss] [PATCH] switch-on-port-available: check and change default sink or source

Georg Chini georg at chini.tk
Fri May 5 18:43:28 UTC 2017


On 05.05.2017 16:43, Georg Chini wrote:
> 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?
Sorry, I was wrong. The actual commit is slightly different from the 
patch in
patchwork and includes the necessary calls.


More information about the pulseaudio-discuss mailing list