yktoo / indicator-sound-switcher

Sound input/output selector indicator for Linux
https://yktoo.com/en/software/sound-switcher-indicator/
GNU General Public License v3.0
369 stars 29 forks source link

[BUG] Unable to switch port on a card with multiple sinks/sources #107

Closed paloha closed 2 years ago

paloha commented 3 years ago

Describe the bug

I am not able to change the output device using the Switcher. The sound coming from the last selected device using the Ubuntu sound settings always stops after interacting with the Switcher. I have to restart the playback app only to get the output of the previously selected output device using the Ubuntu sound settings.

To Reproduce Steps to reproduce the behavior:

Experimenting with just the two output devices of my notebook
  1. The sound is playing from the speakers now. I am starting the switcher with indicator-sound-switcher -vv and this is the output:
    
    INFO     Starting indicator application
    INFO     Loaded configuration file /home/user/.config/indicator-sound-switcher.json
    DEBUG    KeyboardManager.bind_keys()
    DEBUG    .menu_append_item(): appending item `Inputs`
    DEBUG    .menu_append_item(): appending separator
    DEBUG    .menu_append_item(): appending item `Outputs`
    DEBUG    .menu_append_item(): appending separator
    DEBUG    .menu_append_item(): appending item `_Refresh`
    DEBUG    .menu_append_item(): appending item `_Preferences…`
    DEBUG    .menu_append_item(): appending item `_About`
    DEBUG    .menu_append_item(): appending item `_Quit`
    DEBUG    Trying to connect to PulseAudio daemon, attempt #1
    INFO     Context connected
    DEBUG      + Card[2] added: `alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic`, driver: `module-alsa-card.c`
    DEBUG        + Card profile added: `HiFi` (`Play HiFi quality Music`), 4 sinks, 2 sources, priority: 8000 -- Active
    DEBUG        + Card profile added: `off` (`Off`), 0 sinks, 0 sources, priority: 0
    DEBUG        + Card port added: `[Out] HDMI3` (`HDMI3/DP3 Output`); priority: 700; direction: 1; available: No
    DEBUG          . Supported profile: `HiFi`
    DEBUG        + Card port added: `[Out] HDMI2` (`HDMI2/DP2 Output`); priority: 600; direction: 1; available: No
    DEBUG          . Supported profile: `HiFi`
    DEBUG        + Card port added: `[Out] HDMI1` (`HDMI1/DP1 Output`); priority: 500; direction: 1; available: No
    DEBUG          . Supported profile: `HiFi`
    DEBUG        + Card port added: `[Out] Speaker` (`Speaker`); priority: 100; direction: 1; available: Yes
    DEBUG          . Supported profile: `HiFi`
    DEBUG        + Card port added: `[Out] Headphones` (`Headphones`); priority: 200; direction: 1; available: Yes
    DEBUG          . Supported profile: `HiFi`
    DEBUG        + Card port added: `[In] Mic2` (`Headphones Stereo Microphone`); priority: 200; direction: 2; available: No
    DEBUG          . Supported profile: `HiFi`
    DEBUG        + Card port added: `[In] Mic1` (`Digital Microphone`); priority: 100; direction: 2; available: Yes
    DEBUG          . Supported profile: `HiFi`
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ HDMI3/DP3 Output` at index 3 (hidden)
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ HDMI2/DP2 Output` at index 3 (hidden)
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ HDMI1/DP1 Output` at index 3 (hidden)
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ Speaker` at index 6
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ Headphones` at index 6
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ Headphones Stereo Microphone` at index 1 (hidden)
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ Digital Microphone` at index 1
    DEBUG      + Source[29] added: `alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__source`, card 2
    DEBUG        + Source port added: `[In] Mic2` (`Headphones Stereo Microphone`); priority: 200; available: No
    DEBUG        * Activated source port `[In] Mic2`
    DEBUG      + Source[30] added: `alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_6__source`, card 2
    DEBUG        + Source port added: `[In] Mic1` (`Digital Microphone`); priority: 100; available: Yes
    DEBUG        * Activated source port `[In] Mic1`
    DEBUG      + Source output[33] added: `Peak detect`
    DEBUG      + Source output[35] added: `Peak detect`
    DEBUG      + Source output[36] added: `Peak detect`
    DEBUG      + Source output[37] added: `Peak detect`
    DEBUG      + Source output[38] added: `Peak detect`
    DEBUG      + Source output[39] added: `Peak detect`
    DEBUG      + Source output[54] added: `Peak detect`
    DEBUG      + Source output[80] added: `Peak detect`
    DEBUG      + Sink[15] added: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink`, card 2
    DEBUG        + Sink port added: `[Out] HDMI3` (`HDMI3/DP3 Output`); priority: 700; available: No
    DEBUG        * Activated sink port `[Out] HDMI3`
    DEBUG      + Sink[16] added: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_4__sink`, card 2
    DEBUG        + Sink port added: `[Out] HDMI2` (`HDMI2/DP2 Output`); priority: 600; available: No
    DEBUG        * Activated sink port `[Out] HDMI2`
    DEBUG      + Sink[17] added: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sink`, card 2
    DEBUG        + Sink port added: `[Out] HDMI1` (`HDMI1/DP1 Output`); priority: 500; available: No
    DEBUG        * Activated sink port `[Out] HDMI1`
    DEBUG      + Sink[18] added: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink`, card 2
    DEBUG        + Sink port added: `[Out] Speaker` (`Speaker`); priority: 100; available: Yes
    DEBUG        + Sink port added: `[Out] Headphones` (`Headphones`); priority: 200; available: Yes
    DEBUG        * Activated sink port `[Out] Speaker`
    DEBUG      + Sink input[65] added: `Playback Stream` -> sink 18
    DEBUG    * Activated sink: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink`
    DEBUG    * Activated source: `alsa_input.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_6__source`
2. The sound is still playing from the speakers. The Switcher menu contains both my available sound devices as expected. None of them seems to be selected though. I am selecting the headphones output in the Switcher and this is the cli output: 
```bash
INFO     # Card[2], port `[Out] Headphones` selected
DEBUG    * Switching card[2] to profile `HiFi` with priority 8000
DEBUG    .do_context_subscribe(facility: 3, kind: 32, index: 80)
DEBUG      - Source output[80] removed: `Peak detect`
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 18)
DEBUG      * Sink[18] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink`, card 2
DEBUG        * Activated sink port `[Out] Speaker`
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 15)
DEBUG      * Sink[15] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink`, card 2
DEBUG        * Activated sink port `[Out] HDMI3`
DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 65)
DEBUG    .do_context_subscribe(facility: 3, kind: 0, index: 81)
DEBUG      + Source output[81] added: `Peak detect`
  1. There is no sound now. I am interacting with the player (fast forward of the song) and this is the cli output:
    DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 69)
    DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 15)
    DEBUG      * Sink[15] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink`, card 2
    DEBUG        * Activated sink port `[Out] HDMI3`
    DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 15)
    DEBUG      * Sink[15] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink`, card 2
    DEBUG        * Activated sink port `[Out] HDMI3`
    DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 69)
  2. Still no sound, so I exit the player and this is the cli output:
    DEBUG      * Sink[15] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink`, card 2
    DEBUG        * Activated sink port `[Out] HDMI3`
    DEBUG    .do_context_subscribe(facility: 3, kind: 32, index: 84)
    DEBUG      - Source output[84] removed: `Peak detect`
    DEBUG    .do_context_subscribe(facility: 2, kind: 32, index: 69)
    DEBUG      - Sink input[69] removed: `Playback Stream`
  3. I run the player again and this is the cli output:
    DEBUG    .do_context_subscribe(facility: 2, kind: 0, index: 70)
    DEBUG      + Sink input[70] added: `pulsesink probe` -> sink 18
    DEBUG    .do_context_subscribe(facility: 3, kind: 0, index: 85)
    DEBUG      + Source output[85] added: `Peak detect`
    DEBUG    .do_context_subscribe(facility: 3, kind: 32, index: 85)
    DEBUG      - Source output[85] removed: `Peak detect`
    DEBUG    .do_context_subscribe(facility: 2, kind: 32, index: 70)
    DEBUG      - Sink input[70] removed: `pulsesink probe`
    DEBUG    .do_context_subscribe(facility: 2, kind: 0, index: 71)
    DEBUG      + Sink input[71] added: `Playback Stream` -> sink 18
    DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 18)
    DEBUG      * Sink[18] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink`, card 2
    DEBUG        * Activated sink port `[Out] Speaker`
    DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 71)
    DEBUG    .do_context_subscribe(facility: 3, kind: 0, index: 86)
    DEBUG      + Source output[86] added: `Peak detect`
  4. Now I hear the sound from the speakers again (speakers were the last device selected using the Ubuntu sound settings). The Switcher menu looks like the headphones are selected. Now I am selecting the speakers in the Switcher just to see what happens and this is the cli output:
    INFO     # Card[2], port `[Out] Speaker` selected
    DEBUG    * Preferred profile `HiFi` is specified for port `[Out] Speaker`
    DEBUG    * Switching card[2] to profile `HiFi` with priority 8000
    DEBUG    .do_context_subscribe(facility: 3, kind: 32, index: 86)
    DEBUG      - Source output[86] removed: `Peak detect`
    DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 18)
    DEBUG      * Sink[18] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink`, card 2
    DEBUG        * Activated sink port `[Out] Speaker`
    DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 15)
    DEBUG      * Sink[15] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink`, card 2
    DEBUG        * Activated sink port `[Out] HDMI3`
    DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 71)
    DEBUG    .do_context_subscribe(facility: 3, kind: 0, index: 87)
    DEBUG      + Source output[87] added: `Peak detect`
  5. The sound stopped and the Switcher looks like the speaker is selected. I keyboard interrupt the Switcher cli and still no sound. Even selecting headphones or speakers in the Ubuntu sound settings does not bring the sound back. I am restarting the playback app again. The sound starts playing from the speakers.
Situation after connecting the Docking station with 2 additional sound output devices

Through the docking station, I have another two sound devices available. The docking station's headphones output and a RODE-NT USB microphone which has a headphones output for monitoring. All show up in the Switcher's menu.

If I connect the notebook to my docking station and set the output device in the Ubuntu sound settings to the speaker, after interacting with the Switcher the sound stops as usual, but now when I restart the player, the sound starts from the docking station headphones output. But I guess the reason for this is that I have set the Docking station's headphones as a fallback device in the PulseAudio Volume control. Anyways, the problem is the same for all output devices because I am not able to switch even to the RODE-NT USB output using the Switcher.

Expected behavior I expect the Switcher to switch between my output devices successfully and seamlessly without me having to restart the playback app.

Screenshots I do not think the screenshots are necessary, if needed I will provide upon request.

Desktop (please complete the following information):

Indicator log:

The output of the log is used in the "steps to reproduce" section

Additional context

List of my sound devices cat /proc/asound/cards (when connected to the docking station):

 0 [sofhdadsp      ]: sof-hda-dsp - sof-hda-dsp
                      LENOVO-XXXXXXXXXX-ThinkPadX1Carbon7th
 1 [NTUSB          ]: USB-Audio - RODE NT-USB
                      RODE Microphones RODE NT-USB at usb-0000:00:14.0-2.3.4, full speed
 2 [Au             ]: USB-Audio - ThinkPad USB-C Dock Gen2 USB Au
                      Lenovo ThinkPad USB-C Dock Gen2 USB Au at usb-0000:00:14.0-2.3.3.2, full speed

List of the sinks pacmd list-sinks:

5 sink(s) available.
    index: 15
        name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink>
        driver: <module-alsa-card.c>
        flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: IDLE
        suspend cause: (none)
        priority: 9037
        volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                balance 0,00
        base volume: 65536 / 100% / 0,00 dB
        volume steps: 65537
        muted: no
        current latency: 33,94 ms
        max request: 7 KiB
        max rewind: 7 KiB
        monitor source: 25
        sample spec: s16le 2ch 48000Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 1
        configured latency: 40,00 ms; range is 0,50 .. 341,00 ms
        card: 2 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
        module: 25
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = ""
                alsa.id = "HDMI3 (*)"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "5"
                alsa.card = "0"
                alsa.card_name = "sof-hda-dsp"
                alsa.long_card_name = "LENOVO-XXXXXXXXXX-ThinkPadX1Carbon7th"
                alsa.driver_name = "snd_soc_skl_hda_dsp"
                device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
                sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0"
                device.bus = "pci"
                device.vendor.id = "8086"
                device.vendor.name = "Intel Corporation"
                device.product.id = "9dc8"
                device.product.name = "Cannon Point-LP High Definition Audio Controller"
                device.string = "hw:sofhdadsp,5"
                device.buffering.buffer_size = "65472"
                device.buffering.fragment_size = "16320"
                device.access_mode = "mmap+timer"
                device.profile.name = "HiFi: hw:sofhdadsp,5: sink"
                device.profile.description = "HDMI3/DP3 Output"
                alsa.mixer_device = "hw:sofhdadsp"
                device.description = "Cannon Point-LP High Definition Audio Controller HDMI3/DP3 Output"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        ports:
                [Out] HDMI3: HDMI3/DP3 Output (priority 700, latency offset 0 usec, available: no)
                        properties:

        active port: <[Out] HDMI3>
    index: 16
        name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_4__sink>
        driver: <module-alsa-card.c>
        flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: IDLE
        suspend cause: (none)
        priority: 9036
        volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                balance 0,00
        base volume: 65536 / 100% / 0,00 dB
        volume steps: 65537
        muted: no
        current latency: 38,92 ms
        max request: 7 KiB
        max rewind: 7 KiB
        monitor source: 26
        sample spec: s16le 2ch 48000Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 1
        configured latency: 40,00 ms; range is 0,50 .. 341,00 ms
        card: 2 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
        module: 25
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = ""
                alsa.id = "HDMI2 (*)"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "4"
                alsa.card = "0"
                alsa.card_name = "sof-hda-dsp"
                alsa.long_card_name = "LENOVO-XXXXXXXXXX-ThinkPadX1Carbon7th"
                alsa.driver_name = "snd_soc_skl_hda_dsp"
                device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
                sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0"
                device.bus = "pci"
                device.vendor.id = "8086"
                device.vendor.name = "Intel Corporation"
                device.product.id = "9dc8"
                device.product.name = "Cannon Point-LP High Definition Audio Controller"
                device.string = "hw:sofhdadsp,4"
                device.buffering.buffer_size = "65472"
                device.buffering.fragment_size = "16320"
                device.access_mode = "mmap+timer"
                device.profile.name = "HiFi: hw:sofhdadsp,4: sink"
                device.profile.description = "HDMI2/DP2 Output"
                alsa.mixer_device = "hw:sofhdadsp"
                device.description = "Cannon Point-LP High Definition Audio Controller HDMI2/DP2 Output"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        ports:
                [Out] HDMI2: HDMI2/DP2 Output (priority 600, latency offset 0 usec, available: no)
                        properties:

        active port: <[Out] HDMI2>
    index: 17
        name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sink>
        driver: <module-alsa-card.c>
        flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: IDLE
        suspend cause: (none)
        priority: 9035
        volume: front-left: 78640 / 120% / 4,75 dB,   front-right: 78640 / 120% / 4,75 dB
                balance 0,00
        base volume: 65536 / 100% / 0,00 dB
        volume steps: 65537
        muted: no
        current latency: 39,57 ms
        max request: 7 KiB
        max rewind: 7 KiB
        monitor source: 27
        sample spec: s16le 2ch 48000Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 1
        configured latency: 40,00 ms; range is 0,50 .. 341,00 ms
        card: 2 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
        module: 25
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = ""
                alsa.id = "HDMI1 (*)"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "3"
                alsa.card = "0"
                alsa.card_name = "sof-hda-dsp"
                alsa.long_card_name = "LENOVO-XXXXXXXXXX-ThinkPadX1Carbon7th"
                alsa.driver_name = "snd_soc_skl_hda_dsp"
                device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
                sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0"
                device.bus = "pci"
                device.vendor.id = "8086"
                device.vendor.name = "Intel Corporation"
                device.product.id = "9dc8"
                device.product.name = "Cannon Point-LP High Definition Audio Controller"
                device.string = "hw:sofhdadsp,3"
                device.buffering.buffer_size = "65472"
                device.buffering.fragment_size = "16320"
                device.access_mode = "mmap+timer"
                device.profile.name = "HiFi: hw:sofhdadsp,3: sink"
                device.profile.description = "HDMI1/DP1 Output"
                alsa.mixer_device = "hw:sofhdadsp"
                device.description = "Cannon Point-LP High Definition Audio Controller HDMI1/DP1 Output"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        ports:
                [Out] HDMI1: HDMI1/DP1 Output (priority 500, latency offset 0 usec, available: yes)
                        properties:
                                device.product.name = "L2251p Wide"
        active port: <[Out] HDMI1>
    index: 18
        name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink>
        driver: <module-alsa-card.c>
        flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: IDLE
        suspend cause: (none)
        priority: 9032
        volume: front-left: 41942 /  64% / -11,63 dB,   front-right: 41942 /  64% / -11,63 dB
                balance 0,00
        base volume: 65536 / 100% / 0,00 dB
        volume steps: 65537
        muted: no
        current latency: 39,45 ms
        max request: 7 KiB
        max rewind: 7 KiB
        monitor source: 28
        sample spec: s16le 2ch 48000Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 1
        configured latency: 40,00 ms; range is 0,50 .. 341,00 ms
        card: 2 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
        module: 25
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = ""
                alsa.id = "HDA Analog (*)"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "0"
                alsa.card_name = "sof-hda-dsp"
                alsa.long_card_name = "LENOVO-XXXXXXXXXX-ThinkPadX1Carbon7th"
                alsa.driver_name = "snd_soc_skl_hda_dsp"
                device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
                sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0"
                device.bus = "pci"
                device.vendor.id = "8086"
                device.vendor.name = "Intel Corporation"
                device.product.id = "9dc8"
                device.product.name = "Cannon Point-LP High Definition Audio Controller"
                device.string = "hw:sofhdadsp"
                device.buffering.buffer_size = "65472"
                device.buffering.fragment_size = "16320"
                device.access_mode = "mmap+timer"
                device.profile.name = "HiFi: hw:sofhdadsp: sink"
                device.profile.description = "Speaker + Headphones"
                alsa.mixer_device = "hw:sofhdadsp"
                device.description = "Cannon Point-LP High Definition Audio Controller Speaker + Headphones"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-pci"
        ports:
                [Out] Speaker: Speaker (priority 100, latency offset 0 usec, available: unknown)
                        properties:

                [Out] Headphones: Headphones (priority 200, latency offset 0 usec, available: no)
                        properties:

        active port: <[Out] Speaker>
  * index: 20
        name: <alsa_output.usb-Lenovo_ThinkPad_USB-C_Dock_Gen2_USB_Audio_000000000000-00.analog-stereo>
        driver: <module-alsa-card.c>
        flags: HARDWARE HW_MUTE_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
        state: IDLE
        suspend cause: (none)
        priority: 9049
        volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
                balance 0,00
        base volume: 65536 / 100% / 0,00 dB
        volume steps: 65537
        muted: no
        current latency: 40,53 ms
        max request: 6 KiB
        max rewind: 6 KiB
        monitor source: 33
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 0
        linked by: 1
        configured latency: 40,00 ms; range is 0,50 .. 2000,00 ms
        card: 8 <alsa_card.usb-Lenovo_ThinkPad_USB-C_Dock_Gen2_USB_Audio_000000000000-00>
        module: 35
        properties:
                alsa.resolution_bits = "16"
                device.api = "alsa"
                device.class = "sound"
                alsa.class = "generic"
                alsa.subclass = "generic-mix"
                alsa.name = "USB Audio"
                alsa.id = "USB Audio"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                alsa.device = "0"
                alsa.card = "2"
                alsa.card_name = "ThinkPad USB-C Dock Gen2 USB Au"
                alsa.long_card_name = "Lenovo ThinkPad USB-C Dock Gen2 USB Au at usb-0000:00:14.0-2.3.3.2, full speed"
                alsa.driver_name = "snd_usb_audio"
                device.bus_path = "pci-0000:00:14.0-usb-0:2.3.3.2:1.0"
                sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.3/1-2.3.3/1-2.3.3.2/1-2.3.3.2:1.0/sound/card2"
                udev.id = "usb-Lenovo_ThinkPad_USB-C_Dock_Gen2_USB_Audio_000000000000-00"
                device.bus = "usb"
                device.vendor.id = "17ef"
                device.vendor.name = "Lenovo"
                device.product.id = "a396"
                device.product.name = "ThinkPad USB-C Dock Gen2 USB Audio"
                device.serial = "Lenovo_ThinkPad_USB-C_Dock_Gen2_USB_Audio_000000000000"
                device.string = "front:2"
                device.buffering.buffer_size = "352800"
                device.buffering.fragment_size = "176400"
                device.access_mode = "mmap+timer"
                device.profile.name = "analog-stereo"
                device.profile.description = "Analog Stereo"
                device.description = "ThinkPad USB-C Dock Gen2 USB Audio Analog Stereo"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card-usb"
        ports:
                analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
                        properties:

        active port: <analog-output>

Last notes: after installing the Switcher I have restarted my computer. Also I have installed the Switcher on my desktop pc with the same OS and all works as expected.

claudio4git commented 3 years ago

I'm having this same problem.

Command: cat /proc/asound/cards

 0 [C925e          ]: USB-Audio - Logitech Webcam C925e
                      Logitech Webcam C925e at usb-0000:00:14.0-2.4, high speed
 1 [Headset        ]: USB-Audio - Logitech USB Headset
                      Logitech Logitech USB Headset at usb-0000:00:14.0-2.1, full speed
 2 [sofhdadsp      ]: sof-hda-dsp - sof-hda-dsp
                      DellInc.-Vostro5490--0M9F58

Command: pacmd list-sinks

5 sink(s) available.
    index: 1
    name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink>
    driver: <module-alsa-card.c>
    flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: SUSPENDED
    suspend cause: IDLE
    priority: 9037
    volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
            balance 0,00
    base volume: 65536 / 100% / 0,00 dB
    volume steps: 65537
    muted: no
    current latency: 0,00 ms
    max request: 0 KiB
    max rewind: 0 KiB
    monitor source: 1
    sample spec: s16le 2ch 48000Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 0,00 ms; range is 0,50 .. 341,00 ms
    card: 0 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
    module: 23
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = ""
        alsa.id = "HDMI3 (*)"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "5"
        alsa.card = "2"
        alsa.card_name = "sof-hda-dsp"
        alsa.long_card_name = "DellInc.-Vostro5490--0M9F58"
        alsa.driver_name = "snd_soc_skl_hda_dsp"
        device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
        sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card2"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "02c8"
        device.string = "hw:sofhdadsp,5"
        device.buffering.buffer_size = "65472"
        device.buffering.fragment_size = "16320"
        device.access_mode = "mmap+timer"
        device.profile.name = "HiFi: hw:sofhdadsp,5: sink"
        device.profile.description = "HDMI3/DP3 Output"
        alsa.mixer_device = "hw:sofhdadsp"
        device.description = "sof-hda-dsp HDMI3/DP3 Output"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        [Out] HDMI3: HDMI3/DP3 Output (priority 700, latency offset 0 usec, available: no)
            properties:

    active port: <[Out] HDMI3>
    index: 2
    name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_4__sink>
    driver: <module-alsa-card.c>
    flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: SUSPENDED
    suspend cause: IDLE
    priority: 9036
    volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
            balance 0,00
    base volume: 65536 / 100% / 0,00 dB
    volume steps: 65537
    muted: no
    current latency: 0,00 ms
    max request: 0 KiB
    max rewind: 0 KiB
    monitor source: 2
    sample spec: s16le 2ch 48000Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 0,00 ms; range is 0,50 .. 341,00 ms
    card: 0 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
    module: 23
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = ""
        alsa.id = "HDMI2 (*)"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "4"
        alsa.card = "2"
        alsa.card_name = "sof-hda-dsp"
        alsa.long_card_name = "DellInc.-Vostro5490--0M9F58"
        alsa.driver_name = "snd_soc_skl_hda_dsp"
        device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
        sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card2"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "02c8"
        device.string = "hw:sofhdadsp,4"
        device.buffering.buffer_size = "65472"
        device.buffering.fragment_size = "16320"
        device.access_mode = "mmap+timer"
        device.profile.name = "HiFi: hw:sofhdadsp,4: sink"
        device.profile.description = "HDMI2/DP2 Output"
        alsa.mixer_device = "hw:sofhdadsp"
        device.description = "sof-hda-dsp HDMI2/DP2 Output"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        [Out] HDMI2: HDMI2/DP2 Output (priority 600, latency offset 0 usec, available: no)
            properties:

    active port: <[Out] HDMI2>
    index: 3
    name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sink>
    driver: <module-alsa-card.c>
    flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: SUSPENDED
    suspend cause: IDLE
    priority: 9035
    volume: front-left: 29181 /  45% / -21,08 dB,   front-right: 28691 /  44% / -21,52 dB
            balance -0,02
    base volume: 65536 / 100% / 0,00 dB
    volume steps: 65537
    muted: no
    current latency: 0,00 ms
    max request: 0 KiB
    max rewind: 0 KiB
    monitor source: 3
    sample spec: s16le 2ch 48000Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 0,00 ms; range is 0,50 .. 341,00 ms
    card: 0 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
    module: 23
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = ""
        alsa.id = "HDMI1 (*)"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "3"
        alsa.card = "2"
        alsa.card_name = "sof-hda-dsp"
        alsa.long_card_name = "DellInc.-Vostro5490--0M9F58"
        alsa.driver_name = "snd_soc_skl_hda_dsp"
        device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
        sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card2"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "02c8"
        device.string = "hw:sofhdadsp,3"
        device.buffering.buffer_size = "65472"
        device.buffering.fragment_size = "16320"
        device.access_mode = "mmap+timer"
        device.profile.name = "HiFi: hw:sofhdadsp,3: sink"
        device.profile.description = "HDMI1/DP1 Output"
        alsa.mixer_device = "hw:sofhdadsp"
        device.description = "sof-hda-dsp HDMI1/DP1 Output"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        [Out] HDMI1: HDMI1/DP1 Output (priority 500, latency offset 0 usec, available: yes)
            properties:
                device.product.name = "LG ULTRAWIDE"
    active port: <[Out] HDMI1>
  * index: 4
    name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink>
    driver: <module-alsa-card.c>
    flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: RUNNING
    suspend cause: (none)
    priority: 9032
    volume: front-left: 60143 /  92% / -2,24 dB,   front-right: 60143 /  92% / -2,24 dB
            balance 0,00
    base volume: 65536 / 100% / 0,00 dB
    volume steps: 65537
    muted: no
    current latency: 38,30 ms
    max request: 7 KiB
    max rewind: 7 KiB
    monitor source: 4
    sample spec: s16le 2ch 48000Hz
    channel map: front-left,front-right
                 Stereo
    used by: 1
    linked by: 2
    configured latency: 40,00 ms; range is 0,50 .. 341,00 ms
    card: 0 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
    module: 23
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = ""
        alsa.id = "HDA Analog (*)"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "0"
        alsa.card = "2"
        alsa.card_name = "sof-hda-dsp"
        alsa.long_card_name = "DellInc.-Vostro5490--0M9F58"
        alsa.driver_name = "snd_soc_skl_hda_dsp"
        device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
        sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card2"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "02c8"
        device.string = "hw:sofhdadsp"
        device.buffering.buffer_size = "65472"
        device.buffering.fragment_size = "16320"
        device.access_mode = "mmap+timer"
        device.profile.name = "HiFi: hw:sofhdadsp: sink"
        device.profile.description = "Speaker + Headphones"
        alsa.mixer_device = "hw:sofhdadsp"
        device.description = "sof-hda-dsp Speaker + Headphones"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        [Out] Speaker: Speaker (priority 100, latency offset 0 usec, available: unknown)
            properties:

        [Out] Headphones: Headphones (priority 200, latency offset 0 usec, available: no)
            properties:

    active port: <[Out] Speaker>
    index: 5
    name: <alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo>
    driver: <module-alsa-card.c>
    flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: SUSPENDED
    suspend cause: IDLE
    priority: 9049
    volume: front-left: 60637 /  93% / -2,02 dB,   front-right: 60637 /  93% / -2,02 dB
            balance 0,00
    base volume: 65536 / 100% / 0,00 dB
    volume steps: 65537
    muted: no
    current latency: 0,00 ms
    max request: 0 KiB
    max rewind: 0 KiB
    monitor source: 7
    sample spec: s16le 2ch 44100Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 0,00 ms; range is 0,50 .. 2000,00 ms
    card: 1 <alsa_card.usb-Logitech_Logitech_USB_Headset-00>
    module: 24
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = "USB Audio"
        alsa.id = "USB Audio"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "0"
        alsa.card = "1"
        alsa.card_name = "Logitech USB Headset"
        alsa.long_card_name = "Logitech Logitech USB Headset at usb-0000:00:14.0-2.1, full speed"
        alsa.driver_name = "snd_usb_audio"
        device.bus_path = "pci-0000:00:14.0-usb-0:2.1:1.0"
        sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.1/1-2.1:1.0/sound/card1"
        udev.id = "usb-Logitech_Logitech_USB_Headset-00"
        device.bus = "usb"
        device.vendor.id = "046d"
        device.vendor.name = "Logitech, Inc."
        device.product.id = "0a44"
        device.product.name = "Headset H390"
        device.serial = "Logitech_Logitech_USB_Headset"
        device.form_factor = "headset"
        device.string = "front:1"
        device.buffering.buffer_size = "352800"
        device.buffering.fragment_size = "176400"
        device.access_mode = "mmap+timer"
        device.profile.name = "analog-stereo"
        device.profile.description = "Analog Stereo"
        device.description = "Headset H390 Analog Stereo"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-headset-usb"
        device.intended_roles = "phone"
    ports:
        analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: unknown)
            properties:
                device.icon_name = "audio-headphones"
    active port: <analog-output-headphones>
yktoo commented 3 years ago

@paloha thanks for the detailed account of your research. There's a lot of stuff in the logs yet it's still a bit difficult to figure out where it goes wrong. I think we should first try to narrow the problem down as to where it arises, I have a strong suspicion that it has little to do with SSI but rather with PulseAudio.

Also, I noticed that you provided a preferred profile for your output:

DEBUG    * Preferred profile `HiFi` is specified for port `[Out] Speaker`
DEBUG    * Switching card[2] to profile `HiFi` with priority 8000

Could you remove it from the port (set to (none)) and try switching without?

As to why the playback stops, I think we can attribute it to the fact that the sink gets switched twice, first to Speakers and immediately after to HDMI3:

DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 18)
DEBUG      * Sink[18] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink`, card 2
DEBUG        * Activated sink port `[Out] Speaker`
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 15)
DEBUG      * Sink[15] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink`, card 2
DEBUG        * Activated sink port `[Out] HDMI3`

Not sure why that happens, but it's very unlikely it's caused by the indicator.

paloha commented 3 years ago

@claudio4git thanks for confirming you have the same problem.

@yktoo thanks for your reply. As per your recommendation, I have tried to remove the preferred profile from my speakers.

I again added your ppa (I removed it after I submitted this issue a while ago) and installed the switcher according to https://yktoo.com/en/software/sound-switcher-indicator/ using the commands:

sudo apt-add-repository ppa:yktooo/ppa
sudo apt-get update
sudo apt-get install indicator-sound-switcher

In the Pulse Audio Volume Control > Configuration I have changed the Profile of Cannon Point-LP High Definition Audio Controller from Play HiFi quality Music to off. I have closed the Pulse Audio Volume Control.

Now the experiment:

  1. I am plyaing a video using default Videos application in Ubuntu. Sound is coming from my Rode-NT USB headphones output as expected (last selected output device in Ubuntu Sound settings). I quit the Videos app.

  2. Now I run the indicator-sound-switcher -vv and this is the output:

    INFO     Starting indicator application
    INFO     Loaded configuration file /home/paloha/.config/indicator-sound-switcher.json
    DEBUG    KeyboardManager.bind_keys()
    DEBUG    .menu_append_item(): appending item `Inputs`
    DEBUG    .menu_append_item(): appending separator
    DEBUG    .menu_append_item(): appending item `Outputs`
    DEBUG    .menu_append_item(): appending separator
    DEBUG    .menu_append_item(): appending item `_Refresh`
    DEBUG    .menu_append_item(): appending item `_Preferences…`
    DEBUG    .menu_append_item(): appending item `_About`
    DEBUG    .menu_append_item(): appending item `_Quit`
    DEBUG    Trying to connect to PulseAudio daemon, attempt #1
    INFO     Context connected
    DEBUG      + Card[2] added: `alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic`, driver: `module-alsa-card.c`
    DEBUG        + Card profile added: `HiFi` (`Play HiFi quality Music`), 4 sinks, 2 sources, priority: 8000
    DEBUG        + Card profile added: `off` (`Off`), 0 sinks, 0 sources, priority: 0 -- Active
    DEBUG        + Card port added: `[Out] HDMI3` (`HDMI3/DP3 Output`); priority: 700; direction: 1; available: No
    DEBUG          . Supported profile: `HiFi`
    DEBUG        + Card port added: `[Out] HDMI2` (`HDMI2/DP2 Output`); priority: 600; direction: 1; available: Yes
    DEBUG          . Supported profile: `HiFi`
    DEBUG        + Card port added: `[Out] HDMI1` (`HDMI1/DP1 Output`); priority: 500; direction: 1; available: No
    DEBUG          . Supported profile: `HiFi`
    DEBUG        + Card port added: `[Out] Speaker` (`Speaker`); priority: 100; direction: 1; available: Yes
    DEBUG          . Supported profile: `HiFi`
    DEBUG        + Card port added: `[Out] Headphones` (`Headphones`); priority: 200; direction: 1; available: No
    DEBUG          . Supported profile: `HiFi`
    DEBUG        + Card port added: `[In] Mic2` (`Headphones Stereo Microphone`); priority: 200; direction: 2; available: No
    DEBUG          . Supported profile: `HiFi`
    DEBUG        + Card port added: `[In] Mic1` (`Digital Microphone`); priority: 100; direction: 2; available: Yes
    DEBUG          . Supported profile: `HiFi`
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ HDMI3/DP3 Output` at index 3 (hidden)
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ HDMI2/DP2 Output` at index 3
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ HDMI1/DP1 Output` at index 3 (hidden)
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ Speaker` at index 6
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ Headphones` at index 6 (hidden)
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ Headphones Stereo Microphone` at index 1 (hidden)
    DEBUG    .menu_insert_ordered_item(): inserting item `    Cannon Point-LP High Definition Audio Controller ‣ Digital Microphone` at index 1
    DEBUG      + Card[11] added: `alsa_card.usb-RODE_Microphones_RODE_NT-USB-00`, driver: `module-alsa-card.c`
    DEBUG        + Card profile added: `input:analog-stereo` (`Analog Stereo Input`), 0 sinks, 1 sources, priority: 65
    DEBUG        + Card profile added: `input:iec958-stereo` (`Digital Stereo (IEC958) Input`), 0 sinks, 1 sources, priority: 55
    DEBUG        + Card profile added: `output:analog-stereo` (`Analog Stereo Output`), 1 sinks, 0 sources, priority: 6500
    DEBUG        + Card profile added: `output:analog-stereo+input:analog-stereo` (`Analog Stereo Duplex`), 1 sinks, 1 sources, priority: 6565 -- Active
    DEBUG        + Card profile added: `output:analog-stereo+input:iec958-stereo` (`Analog Stereo Output + Digital Stereo (IEC958) Input`), 1 sinks, 1 sources, priority: 6555
    DEBUG        + Card profile added: `output:iec958-stereo` (`Digital Stereo (IEC958) Output`), 1 sinks, 0 sources, priority: 5500
    DEBUG        + Card profile added: `output:iec958-stereo+input:analog-stereo` (`Digital Stereo (IEC958) Output + Analog Stereo Input`), 1 sinks, 1 sources, priority: 5565
    DEBUG        + Card profile added: `output:iec958-stereo+input:iec958-stereo` (`Digital Stereo Duplex (IEC958)`), 1 sinks, 1 sources, priority: 5555
    DEBUG        + Card profile added: `off` (`Off`), 0 sinks, 0 sources, priority: 0
    DEBUG        + Card port added: `analog-input-mic` (`Microphone`); priority: 8700; direction: 2; available: Yes
    DEBUG          . Supported profile: `input:analog-stereo`
    DEBUG          . Supported profile: `output:analog-stereo+input:analog-stereo`
    DEBUG          . Supported profile: `output:iec958-stereo+input:analog-stereo`
    DEBUG        + Card port added: `iec958-stereo-input` (`Digital Input (S/PDIF)`); priority: 0; direction: 2; available: Yes
    DEBUG          . Supported profile: `input:iec958-stereo`
    DEBUG          . Supported profile: `output:analog-stereo+input:iec958-stereo`
    DEBUG          . Supported profile: `output:iec958-stereo+input:iec958-stereo`
    DEBUG        + Card port added: `analog-output` (`Analog Output`); priority: 9900; direction: 1; available: Yes
    DEBUG          . Supported profile: `output:analog-stereo`
    DEBUG          . Supported profile: `output:analog-stereo+input:analog-stereo`
    DEBUG          . Supported profile: `output:analog-stereo+input:iec958-stereo`
    DEBUG        + Card port added: `iec958-stereo-output` (`Digital Output (S/PDIF)`); priority: 0; direction: 1; available: Yes
    DEBUG          . Supported profile: `output:iec958-stereo`
    DEBUG          . Supported profile: `output:iec958-stereo+input:analog-stereo`
    DEBUG          . Supported profile: `output:iec958-stereo+input:iec958-stereo`
    DEBUG    .menu_insert_ordered_item(): inserting item `    RODE NT-USB ‣ Microphone` at index 3
    DEBUG    .menu_insert_ordered_item(): inserting item `    RODE NT-USB ‣ Digital Input (S/PDIF)` at index 3
    DEBUG    .menu_insert_ordered_item(): inserting item `    RODE NT-USB ‣ Analog Output` at index 12
    DEBUG    .menu_insert_ordered_item(): inserting item `    RODE NT-USB ‣ Digital Output (S/PDIF)` at index 13
    DEBUG      + Card[12] added: `alsa_card.usb-Lenovo_ThinkPad_USB-C_Dock_Gen2_USB_Audio_000000000000-00`, driver: `module-alsa-card.c`
    DEBUG        + Card profile added: `input:mono-fallback` (`Mono Input`), 0 sinks, 1 sources, priority: 1
    DEBUG        + Card profile added: `input:multichannel-input` (`Multichannel Input`), 0 sinks, 1 sources, priority: 1
    DEBUG        + Card profile added: `output:analog-stereo` (`Analog Stereo Output`), 1 sinks, 0 sources, priority: 6500 -- Active
    DEBUG        + Card profile added: `output:analog-stereo+input:mono-fallback` (`Analog Stereo Output + Mono Input`), 1 sinks, 1 sources, priority: 6501
    DEBUG        + Card profile added: `output:analog-stereo+input:multichannel-input` (`Analog Stereo Output + Multichannel Input`), 1 sinks, 1 sources, priority: 6501
    DEBUG        + Card profile added: `output:iec958-stereo` (`Digital Stereo (IEC958) Output`), 1 sinks, 0 sources, priority: 5500
    DEBUG        + Card profile added: `output:iec958-stereo+input:mono-fallback` (`Digital Stereo (IEC958) Output + Mono Input`), 1 sinks, 1 sources, priority: 5501
    DEBUG        + Card profile added: `output:iec958-stereo+input:multichannel-input` (`Digital Stereo (IEC958) Output + Multichannel Input`), 1 sinks, 1 sources, priority: 5501
    DEBUG        + Card profile added: `off` (`Off`), 0 sinks, 0 sources, priority: 0
    DEBUG        + Card port added: `analog-input-headset-mic` (`Headset Microphone`); priority: 8800; direction: 2; available: Yes
    DEBUG          . Supported profile: `input:mono-fallback`
    DEBUG          . Supported profile: `output:analog-stereo+input:mono-fallback`
    DEBUG          . Supported profile: `output:iec958-stereo+input:mono-fallback`
    DEBUG        + Card port added: `multichannel-input` (`Multichannel Input`); priority: 0; direction: 2; available: Yes
    DEBUG          . Supported profile: `input:multichannel-input`
    DEBUG          . Supported profile: `output:analog-stereo+input:multichannel-input`
    DEBUG          . Supported profile: `output:iec958-stereo+input:multichannel-input`
    DEBUG        + Card port added: `analog-output` (`Analog Output`); priority: 9900; direction: 1; available: Yes
    DEBUG          . Supported profile: `output:analog-stereo`
    DEBUG          . Supported profile: `output:analog-stereo+input:mono-fallback`
    DEBUG          . Supported profile: `output:analog-stereo+input:multichannel-input`
    DEBUG        + Card port added: `iec958-stereo-output` (`Digital Output (S/PDIF)`); priority: 0; direction: 1; available: Yes
    DEBUG          . Supported profile: `output:iec958-stereo`
    DEBUG          . Supported profile: `output:iec958-stereo+input:mono-fallback`
    DEBUG          . Supported profile: `output:iec958-stereo+input:multichannel-input`
    DEBUG    .menu_insert_ordered_item(): inserting item `    ThinkPad USB-C Dock Gen2 USB Audio ‣ Headset Microphone` at index 5
    DEBUG    .menu_insert_ordered_item(): inserting item `    ThinkPad USB-C Dock Gen2 USB Audio ‣ Multichannel Input` at index 6
    DEBUG    .menu_insert_ordered_item(): inserting item `    ThinkPad USB-C Dock Gen2 USB Audio ‣ Analog Output` at index 16
    DEBUG    .menu_insert_ordered_item(): inserting item `    ThinkPad USB-C Dock Gen2 USB Audio ‣ Digital Output (S/PDIF)` at index 17
    DEBUG      + Source[21] added: `alsa_input.usb-RODE_Microphones_RODE_NT-USB-00.analog-stereo`, card 11
    DEBUG        + Source port added: `analog-input-mic` (`Microphone`); priority: 8700; available: Yes
    DEBUG        * Activated source port `analog-input-mic`
    DEBUG      + Sink[13] added: `alsa_output.usb-RODE_Microphones_RODE_NT-USB-00.analog-stereo`, card 11
    DEBUG        + Sink port added: `analog-output` (`Analog Output`); priority: 9900; available: Yes
    DEBUG        * Activated sink port `analog-output`
    DEBUG      + Sink[14] added: `alsa_output.usb-Lenovo_ThinkPad_USB-C_Dock_Gen2_USB_Audio_000000000000-00.analog-stereo`, card 12
    DEBUG        + Sink port added: `analog-output` (`Analog Output`); priority: 9900; available: Yes
    DEBUG        * Activated sink port `analog-output`
    DEBUG      + Sink input[337] added: `playback` -> sink 13
    DEBUG      + Sink input[338] added: `playback` -> sink 13
    DEBUG      + Sink input[340] added: `playback` -> sink 13
    DEBUG    * Activated sink: `alsa_output.usb-RODE_Microphones_RODE_NT-USB-00.analog-stereo`
    DEBUG    * Activated source: `alsa_input.usb-RODE_Microphones_RODE_NT-USB-00.analog-stereo`
  3. I run the Videos app again to play a video. The sound is coming from the Rode NT-USB headphones output as expected. I quit the Videos app. Now I switch the sound output to the speakers using the Switcher. The source seems to be selected. Although, after playing the video again, the sound is still going from the headphones and this was the terminal output:

    DEBUG    .do_context_subscribe(facility: 2, kind: 0, index: 668)
    DEBUG      + Sink input[668] added: `pulsesink probe` -> sink 13
    DEBUG    .do_context_subscribe(facility: 2, kind: 32, index: 668)
    DEBUG      - Sink input[668] removed: `pulsesink probe`
    DEBUG    .do_context_subscribe(facility: 2, kind: 0, index: 669)
    DEBUG      + Sink input[669] added: `Playback Stream` -> sink 13
    DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 669)
    DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 669)
    DEBUG    .do_context_subscribe(facility: 2, kind: 32, index: 669)
    DEBUG      - Sink input[669] removed: `Playback Stream`
    INFO     # Card[2], port `[Out] Speaker` selected
    ERROR    Failed to map card[2], port `[Out] Speaker` to a stream
    DEBUG    .do_context_subscribe(facility: 2, kind: 0, index: 670)
    DEBUG      + Sink input[670] added: `pulsesink probe` -> sink 13
    DEBUG    .do_context_subscribe(facility: 2, kind: 32, index: 670)
    DEBUG      - Sink input[670] removed: `pulsesink probe`
    DEBUG    .do_context_subscribe(facility: 2, kind: 0, index: 671)
    DEBUG      + Sink input[671] added: `Playback Stream` -> sink 13
    DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 671)
    DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 671)

At least now there is the an error listed in the log:

 ERROR    Failed to map card[2], port `[Out] Speaker` to a stream

The error made me notice an oddity - if I try to switch to a source other than the speakers, the switcher seems to work. E.g. I tried to switch to the Docking station headphones output and all worked as expected and while the video playback was on - no need to restart the video player or anything. The output from the terminal was this:

INFO     # Card[12], port `analog-output` selected
DEBUG    .do_context_subscribe(facility: 7, kind: 16, index: 4294967295)
DEBUG    * Activated sink: `alsa_output.usb-Lenovo_ThinkPad_USB-C_Dock_Gen2_USB_Audio_000000000000-00.analog-stereo`
DEBUG    * Activated source: `alsa_input.usb-Lenovo_ThinkPad_USB-C_Dock_Gen2_USB_Audio_000000000000-00.mono-fallback`
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 18)
DEBUG      * Sink[18] updated: `alsa_output.usb-Lenovo_ThinkPad_USB-C_Dock_Gen2_USB_Audio_000000000000-00.analog-stereo`, card 12
DEBUG        * Activated sink port `analog-output`
DEBUG    .do_context_subscribe(facility: 1, kind: 16, index: 27)
DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 337)
DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 338)
DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 340)
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 17)
DEBUG      * Sink[17] updated: `alsa_output.usb-RODE_Microphones_RODE_NT-USB-00.analog-stereo`, card 11
DEBUG        * Activated sink port `analog-output`
DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 677)
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 17)
DEBUG      * Sink[17] updated: `alsa_output.usb-RODE_Microphones_RODE_NT-USB-00.analog-stereo`, card 11
DEBUG        * Activated sink port `analog-output`
DEBUG    .do_context_subscribe(facility: 1, kind: 16, index: 26)

If I try to select the speakers now during the playback I get the error again and the sound stays where it was active the last time.

INFO     # Card[2], port `[Out] Speaker` selected
ERROR    Failed to map card[2], port `[Out] Speaker` to a stream

If I try to use the Ubuntu Sound Settings (USS) to set the speakers, they work, but I also noticed it again activates the Play HiFi quality Music for some reason. So I made another experiment. I opened USS and Pulse Audio Volume Control (PAVC), not that the switcher was not running. The sound output in the USS was set to Rode NT-USB headphones, i.e. Analog Output - RODE NT-USB. In the PAVC > Configuration the Profile of Cannon Point-LP High Definition Audio Controller is set to off. Now when I change the output in the USS to those speakers, the Profile in PAVC automatically changes to Play HiFi quality Music. If I change it to off, the speakers stop playing and the output device in the USS changes to Analog Output - ThinkPad USB-C Dock Gen 2 USB Audio.

If I try all this without the Dock connected, the output device in the USS changes to Dummy Output. So as you suggested, there might be some interplay between the switcher and the profile. As it appears, my speakers work only with the profile active. In the end it got so confusing I stopped tracking logs and actually managed to get the system into such a state that sound from notebook did not work no matter where I switched to it. I had to restart the PC to get back to normal.

Do you please have any other suggestions? I really like the switcher and It would help me a lot if it would work.

yktoo commented 3 years ago

There's a whole bunch of stuff going on in your post.

Firstly, by removing the preferred profile I was referring to the SSI's port setting, which you find in the Preferences, not the profile you configure in PulseAudio (using PAVC or anything else): image

Secondly, when you set the actual profile to Off you effectively disable that device. But when you click a port menu item in SSI menu, the indicator tries to pick the most appropriate profile (or uses the preferred one, if configured), so I guess it then assigns a valid profile to the card from the Off value that you selected. So that's expected.

Thirdly, this behaviour:

The source seems to be selected. Although, after playing the video again, the sound is still going from the headphones

is apparently caused by module-stream-restore (see #42 for details) and is expected unless you disable it.

My advice would be to remove any configuration of SSI (~/.config/indicator-sound-switcher.json) and begin from a blank slate. Then open PA Volume control alongside SSI and try to switch a port in one and observe how the other reacts. The expected behaviour is that both reflect the same state — for example, PAVC must update stream mapping to the selected device as well as set that same device as "fallback".

paloha commented 3 years ago

Hello @yktoo, thank you for pointing me in the right direction. I have removed the indicator-sound-switcher.json as you suggested. I have started PAVC and SSI in debug mode.

I have run pactl list short sinks so you can see the list of available sinks and also that the RODE-NT-USB is running:

3       alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink    module-alsa-card.c      s16le 2ch 48000Hz       IDLE
4       alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_4__sink    module-alsa-card.c      s16le 2ch 48000Hz       IDLE
5       alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sink    module-alsa-card.c      s16le 2ch 48000Hz       IDLE
6       alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink      module-alsa-card.c      s16le 2ch 48000Hz       IDLE
10      alsa_output.usb-Lenovo_ThinkPad_USB-C_Dock_Gen2_USB_Audio_000000000000-00.analog-stereo module-alsa-card.c      s16le 2ch 48000Hz       IDLE
14      alsa_output.usb-RODE_Microphones_RODE_NT-USB-00.analog-stereo   module-alsa-card.c      s16le 2ch 48000Hz       RUNNING

So now I change the output to the following sink 6 alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink using PAVC. This sink appears in the PAVC as Cannon Point-LP Hight Definition Audio Controller Speaker + Headphones, not sure why + Headphones, though. The speakers work. This is the console output of SSI:

DEBUG    .do_context_subscribe(facility: 3, kind: 32, index: 81)
DEBUG      - Source output[81] removed: `Peak detect`
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 14)
DEBUG      * Sink[14] updated: `alsa_output.usb-RODE_Microphones_RODE_NT-USB-00.analog-stereo`, card 0
DEBUG        * Activated sink port `analog-output`
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 6)
DEBUG      * Sink[6] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink`, card 2
DEBUG        * Activated sink port `[Out] Speaker`
DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 11)
DEBUG    .do_context_subscribe(facility: 3, kind: 0, index: 82)
DEBUG      + Source output[82] added: `Peak detect`

The SSI still thinks the previous RODE-NT output is selected.

Now I switch back to RODE-NT output using PAVC and this is the output of the SSI:

DEBUG    .do_context_subscribe(facility: 3, kind: 32, index: 82)
DEBUG      - Source output[82] removed: `Peak detect`
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 6)
DEBUG      * Sink[6] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink`, card 2
DEBUG        * Activated sink port `[Out] Speaker`
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 14)
DEBUG      * Sink[14] updated: `alsa_output.usb-RODE_Microphones_RODE_NT-USB-00.analog-stereo`, card 0
DEBUG        * Activated sink port `analog-output`
DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 11)
DEBUG    .do_context_subscribe(facility: 3, kind: 0, index: 83)
DEBUG      + Source output[83] added: `Peak detect`

Now I do the change to what appear in SSI as Cannon Point-LP High Definition Audio Controller > Speaker, please notice there is no + Headphones here. The sound stops working because in PAVC the HDMI3/DP3 Output is selected incorrectly. SSI still thinks the RODE-NT is selected. This is the output of SSI:

INFO     # Card[2], port `[Out] Speaker` selected
DEBUG    * Preferred profile `HiFi` is specified for port `[Out] Speaker`
DEBUG    * Switching card[2] to profile `HiFi` with priority 8000
DEBUG    .do_context_subscribe(facility: 3, kind: 32, index: 83)
DEBUG      - Source output[83] removed: `Peak detect`
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 14)
DEBUG      * Sink[14] updated: `alsa_output.usb-RODE_Microphones_RODE_NT-USB-00.analog-stereo`, card 0
DEBUG        * Activated sink port `analog-output`
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 3)
DEBUG      * Sink[3] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink`, card 2
DEBUG        * Activated sink port `[Out] HDMI3`
DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 11)
DEBUG    .do_context_subscribe(facility: 3, kind: 0, index: 84)
DEBUG      + Source output[84] added: `Peak detect`

Now I change back to RODE-NT in SSI, sound works and this is the output of SSI:

INFO     # Card[0], port `analog-output` selected
DEBUG    .do_context_subscribe(facility: 7, kind: 16, index: 4294967295)
DEBUG    * Activated sink: `alsa_output.usb-RODE_Microphones_RODE_NT-USB-00.analog-stereo`
DEBUG    * Activated source: `alsa_input.usb-Lenovo_ThinkPad_USB-C_Dock_Gen2_USB_Audio_000000000000-00.mono-fallback`
DEBUG    .do_context_subscribe(facility: 3, kind: 32, index: 84)
DEBUG      - Source output[84] removed: `Peak detect`
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 3)
DEBUG      * Sink[3] updated: `alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink`, card 2
DEBUG        * Activated sink port `[Out] HDMI3`
DEBUG    .do_context_subscribe(facility: 0, kind: 16, index: 14)
DEBUG      * Sink[14] updated: `alsa_output.usb-RODE_Microphones_RODE_NT-USB-00.analog-stereo`, card 0
DEBUG        * Activated sink port `analog-output`
DEBUG    .do_context_subscribe(facility: 2, kind: 16, index: 11)
DEBUG    .do_context_subscribe(facility: 3, kind: 0, index: 85)
DEBUG      + Source output[85] added: `Peak detect`

The Preferred profile set to (none) in SSI seems to have no effect on all of this.

Interestingly, in the preferences of SSI, it seems to me the "correct" sink for the speakers is not even listed, i.e. I do not see any Speaker + Headphones there. SSI

Is there any chance SSI just somehow fails to properly map what in the SSI appears as "ports" to the correct sink?

paloha commented 3 years ago

Hello @yktoo, I was wondering if you had time to check my last comment.

andyrozman commented 2 years ago

I have the same problem... Unable to switch sound output. I used SSI on several computer, but installing it on my new computer, indicator just doesn't work... And it looks greyed out on indicator line. If I select another device nothing happens... And if I do refresh then it jumps back to "default" device...

OS: Ubuntu 20.04.3 LTS Desktop Environment: Unity Python: 3.x (I don't have Python 2.x installed at all) Indicator version: 2.3.7

When switch happens there is just one line there:

INFO     # Card[0], port `[Out] Speaker` selected
DEBUG    * Switching card[0] to profile `HiFi` with priority 40768

Comparing to what other guys posted, they have multiple lines here... So I don't think actual switch is done...

pactl list short sinks

0   alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink    module-alsa-card.c  s16le 2ch 48000Hz   RUNNING
1   alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_4__sink    module-alsa-card.c  s16le 2ch 48000Hz   SUSPENDED
2   alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sink    module-alsa-card.c  s16le 2ch 48000Hz   SUSPENDED
3   alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink  module-alsa-card.c  s16le 2ch 48000Hz   SUSPENDED

cat /proc/asound/cards

 0 [sofhdadsp      ]: sof-hda-dsp - sof-hda-dsp
                      HP-HPZBookPowerG7MobileWorkstation--87EC

pacmd list-sinks

4 sink(s) available.
  * index: 0
    name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink>
    driver: <module-alsa-card.c>
    flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: RUNNING
    suspend cause: (none)
    priority: 9037
    volume: front-left: 60334 /  92% / -2.16 dB,   front-right: 60334 /  92% / -2.16 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 59.19 ms
    max request: 11 KiB
    max rewind: 11 KiB
    monitor source: 0
    sample spec: s16le 2ch 48000Hz
    channel map: front-left,front-right
                 Stereo
    used by: 1
    linked by: 3
    configured latency: 60.00 ms; range is 0.50 .. 341.33 ms
    card: 0 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
    module: 7
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = ""
        alsa.id = "HDMI3 (*)"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "5"
        alsa.card = "0"
        alsa.card_name = "sof-hda-dsp"
        alsa.long_card_name = "HP-HPZBookPowerG7MobileWorkstation--87EC"
        alsa.driver_name = "snd_soc_skl_hda_dsp"
        device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
        sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "06c8"
        device.string = "hw:sofhdadsp,5"
        device.buffering.buffer_size = "65536"
        device.buffering.fragment_size = "16384"
        device.access_mode = "mmap+timer"
        device.profile.name = "HiFi: hw:sofhdadsp,5: sink"
        device.profile.description = "HDMI3/DP3 Output"
        alsa.mixer_device = "hw:sofhdadsp"
        device.description = "sof-hda-dsp HDMI3/DP3 Output"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        [Out] HDMI3: HDMI3/DP3 Output (priority 700, latency offset 0 usec, available: yes)
            properties:
                device.product.name = "SAMSUNG"
    active port: <[Out] HDMI3>
    index: 1
    name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_4__sink>
    driver: <module-alsa-card.c>
    flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: SUSPENDED
    suspend cause: IDLE
    priority: 9036
    volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 0.00 ms
    max request: 0 KiB
    max rewind: 0 KiB
    monitor source: 1
    sample spec: s16le 2ch 48000Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 0.00 ms; range is 0.50 .. 341.33 ms
    card: 0 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
    module: 7
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = ""
        alsa.id = "HDMI2 (*)"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "4"
        alsa.card = "0"
        alsa.card_name = "sof-hda-dsp"
        alsa.long_card_name = "HP-HPZBookPowerG7MobileWorkstation--87EC"
        alsa.driver_name = "snd_soc_skl_hda_dsp"
        device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
        sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "06c8"
        device.string = "hw:sofhdadsp,4"
        device.buffering.buffer_size = "65536"
        device.buffering.fragment_size = "16384"
        device.access_mode = "mmap+timer"
        device.profile.name = "HiFi: hw:sofhdadsp,4: sink"
        device.profile.description = "HDMI2/DP2 Output"
        alsa.mixer_device = "hw:sofhdadsp"
        device.description = "sof-hda-dsp HDMI2/DP2 Output"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        [Out] HDMI2: HDMI2/DP2 Output (priority 600, latency offset 0 usec, available: no)
            properties:

    active port: <[Out] HDMI2>
    index: 2
    name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sink>
    driver: <module-alsa-card.c>
    flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: SUSPENDED
    suspend cause: IDLE
    priority: 9035
    volume: front-left: 54245 /  83% / -4.93 dB,   front-right: 54245 /  83% / -4.93 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 0.00 ms
    max request: 0 KiB
    max rewind: 0 KiB
    monitor source: 2
    sample spec: s16le 2ch 48000Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 0.00 ms; range is 0.50 .. 341.33 ms
    card: 0 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
    module: 7
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = ""
        alsa.id = "HDMI1 (*)"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "3"
        alsa.card = "0"
        alsa.card_name = "sof-hda-dsp"
        alsa.long_card_name = "HP-HPZBookPowerG7MobileWorkstation--87EC"
        alsa.driver_name = "snd_soc_skl_hda_dsp"
        device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
        sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "06c8"
        device.string = "hw:sofhdadsp,3"
        device.buffering.buffer_size = "65536"
        device.buffering.fragment_size = "16384"
        device.access_mode = "mmap+timer"
        device.profile.name = "HiFi: hw:sofhdadsp,3: sink"
        device.profile.description = "HDMI1/DP1 Output"
        alsa.mixer_device = "hw:sofhdadsp"
        device.description = "sof-hda-dsp HDMI1/DP1 Output"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        [Out] HDMI1: HDMI1/DP1 Output (priority 500, latency offset 0 usec, available: yes)
            properties:
                device.product.name = "SAMSUNG"
    active port: <[Out] HDMI1>
    index: 3
    name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink>
    driver: <module-alsa-card.c>
    flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
    state: SUSPENDED
    suspend cause: IDLE
    priority: 9032
    volume: front-left: 60334 /  92% / -2.16 dB,   front-right: 60334 /  92% / -2.16 dB
            balance 0.00
    base volume: 65536 / 100% / 0.00 dB
    volume steps: 65537
    muted: no
    current latency: 0.00 ms
    max request: 0 KiB
    max rewind: 0 KiB
    monitor source: 3
    sample spec: s16le 2ch 48000Hz
    channel map: front-left,front-right
                 Stereo
    used by: 0
    linked by: 0
    configured latency: 0.00 ms; range is 0.50 .. 341.33 ms
    card: 0 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
    module: 7
    properties:
        alsa.resolution_bits = "16"
        device.api = "alsa"
        device.class = "sound"
        alsa.class = "generic"
        alsa.subclass = "generic-mix"
        alsa.name = ""
        alsa.id = "HDA Analog (*)"
        alsa.subdevice = "0"
        alsa.subdevice_name = "subdevice #0"
        alsa.device = "0"
        alsa.card = "0"
        alsa.card_name = "sof-hda-dsp"
        alsa.long_card_name = "HP-HPZBookPowerG7MobileWorkstation--87EC"
        alsa.driver_name = "snd_soc_skl_hda_dsp"
        device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
        sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0"
        device.bus = "pci"
        device.vendor.id = "8086"
        device.vendor.name = "Intel Corporation"
        device.product.id = "06c8"
        device.string = "hw:sofhdadsp"
        device.buffering.buffer_size = "65536"
        device.buffering.fragment_size = "16384"
        device.access_mode = "mmap+timer"
        device.profile.name = "HiFi: hw:sofhdadsp: sink"
        device.profile.description = "Speaker + Headphones"
        alsa.mixer_device = "hw:sofhdadsp"
        device.description = "sof-hda-dsp Speaker + Headphones"
        module-udev-detect.discovered = "1"
        device.icon_name = "audio-card-pci"
    ports:
        [Out] Speaker: Speaker (priority 100, latency offset 0 usec, available: unknown)
            properties:

        [Out] Headphones: Headphones (priority 200, latency offset 0 usec, available: no)
            properties:

    active port: <[Out] Speaker>
yktoo commented 2 years ago

Thanks for the input, I hope I nailed the problem.

SSI might incorrectly handle stream mapping/switching in case a card has multiple sinks (or sources), which was your case too. It would erroneously grab the first stream on the card, and if it's a wrong one, it would assume a profile switching is necessary.

On top of that it'd redundantly try to activate a profile when it's already active on the device.

This is visible in the log you attached: on menu item click SSI requested PulseAudio to activate profile HiFi (which was unnecessary), this resulted in activating HDMI3 for an unclear reason (I believe this is PulseAudio's quirk). Which obviously failed since HDMI3 wasn't ever available.

This must be fixed now. On a side note, I find PulseAudio's handling of profiles pretty unstable, it's very easy to screw up the entire sound system by switching profiles a few times. The only way to fix that afterwards is restarting the daemon with pulseaudio -k.

paloha commented 2 years ago

@yktoo thank you very much for your time working on the issue. Can I help you check if the bug is resolved by installing and trying out the dev version?

yktoo commented 2 years ago

@paloha Testing it would help indeed, please try installing from the dev branch.

paloha commented 2 years ago

@yktoo I have just installed from the dev branch. I had to remove the po folder from the cloned repo, otherwise I kept getting error: can't copy 'locale/pt/LC_MESSAGES/indicator-sound-switcher.mo': doesn't exist or not a regular file. Then it installed properly and I was able to test it.

I can confirm that the bug is resolved. Do you already know when you plan a new release? Thank you very much again.

yktoo commented 2 years ago

Thanks for testing, release will come shortly.

yktoo commented 2 years ago

Released in 2.3.8.

token47 commented 2 years ago

Just wanted to mention that it really fixed the problem.

Thank you!!!!