On 05/02/2017 09:27 PM, Tanu Kaskinen wrote: > On Tue, 2017-05-02 at 08:55 +0800, Hui Wang wrote: >> On 04/29/2017 09:04 PM, Tanu Kaskinen wrote: >>> On Fri, 2017-04-28 at 12:21 +0800, Hui Wang wrote: >>>> Hello Tanu, >>>> >>>> Could you please take a look at this patch, you are the maintainer and >>>> recently contributed couple of commits to >>>> module-switch-on-port-available.c. :-) >>> Well, I'm trying to concentrate on preparing for the release, so I >>> don't do patch reviews much at the moment. Now that I read the commit >>> message, I have some comments, though. >>> >>>> On 04/27/2017 11:20 AM, Hui Wang wrote: >>>>> Suppose your machine has two sound cards as 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) >>>>> >>>>> If neither hdmi cable nor headphone plug into the machine, the default >>>>> sink will randomly be Sink#0 or Sink#1, let us assume it is Sink#1, >>>>> then users plug hdmi cable into the machine, the port hdmi-output will >>>>> change to the state PA_AVAILABLE_YES, so the Sink#0 has a port with >>>>> state YES, while the Sink#1 still has a port with state NO, in this >>>>> situation it is reasonable to change the default_sink to Sink#0, but >>>>> current code can't do that. >>> This problem should be fixed by these two patches: >>> https://patchwork.freedesktop.org/patch/139179/ >>> https://patchwork.freedesktop.org/patch/139178/ >>> >>> The patches have been reviewed, but I haven't yet pushed them. I'm not >>> sure if they'll be in the next release or not (I need to ask Georg and >>> Arun if they want to grant a freeze exception for these patches). >>> >>>>> Let us suppose another situation, both hdmi cable and headphone are >>>>> plugged into the machine, and the Sink#0 is the default sink, if users >>>>> unplug the hdmi cable, the port hdmi-output is changed to NO while >>>>> the port headphone is still kept YES, in this situation it is >>>>> reasonable to switch the default_sink to Sink#1, but current code >>>>> can't do that. >>> This should be fixed too by those two patches mentioned above. >>> >> Good to know that, look forward to those patches being merged to the >> mainline. :-) >> >> Thank you for your comment and thank you for your patches. > I pushed the patches to master now. I hope they solve your problems! > 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) 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. 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. Cheers, Hui.