4

My ubuntu desktop does not play any sound through speakers, connected to sound card. It always plays through HDMI monitor, like it is the only sound playing device connected.

I have these settings, and it still plays through HDMI monitor. enter image description here

When I plug my headphones - the system sees it in the 'output device', but sound still goes through HDMI.

When I remove HDMI monitor (it is my secondary monitor), then the sound works fine.

UPD

cat /proc/asound/cards

 0 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xdf220000 irq 126
 1 [NVidia         ]: HDA-Intel - HDA NVidia
                      HDA NVidia at 0xdf080000 irq 17

Can you help?

2

2 Answers 2

6

Update :

i found a script in one of my projects to force asound Analog output ( run it as root in a bash-compliant shell):

aplay -l|grep Analog|grep -v Digital|sed 's/^card /defaults.pcm.card /g;s/:.\+device /\ndefaults.pcm.device /g'|cut -d":" -f1 > /etc/asound.conf 

this will add a permament entry to /etc/asound.conf

1

found a better option

using systemd as described below worked on startup but not when plugging devices in to an already running system.

To ignore audio when hot-plugging and on boot, udev rules are the better option.

Adapted from Tell PulseAudio to ignore a USB device using udev:

  1. use lsusb to identify the vendor/product id of the device you want to ignore

    $ lsusb
    Bus 006 Device 003: ID 17e9:4307 DisplayLink LAPDOCK
    # <other devices I don't care about>
    

    the ID part gives us the magic numbers

  2. create a udev rules file, e.g. /etc/udev/rules.d/80-ignore-audio-cards.rules that sets an environment variable for pulse audio.

    For me this looked like:

    ATTRS{idVendor}=="17e9", ATTRS{idProduct}=="4307", ENV{PULSE_IGNORE}="1"
    

    I chose the 80- prefix for the filename arbitrarily. If you any pulseaudio related rules, make sure your new file starts with a lower number

  3. reboot to ensure it takes effect

With the udev rule in place, pulseaudio ignores the device completely.


previous answer:

Ran into the same problem, and the given answers didn't work for me across restarts. I think my issue was delayed detection of cards; when pulseaudio started up it didn't see all the cards, and some combination of module-switch-on-connect and module-switch-on-port-available was always resetting my choices.

I solved this by making a systemd user unit to run pactl set_card_profile "$MY_CARD_NAME" off when I logged in.

  1. find the name of the card you don't want; hopefully the name should be enough to tell which one:

    $ pactl list cards | grep -E '(Card|Name:)'
    Card #0
        Name: alsa_card.usb-DisplayLink_LAPDOCK_U3D2338486250-02
    Card #1
        Name: alsa_card.pci-0000_01_00.1
    Card #2
        Name: alsa_card.usb-Plantronics_Plantronics_Blackwire_5220_Series_2961D11C621649939CED8BF57E910BA5-00
    Card #3
        Name: alsa_card.usb-HD_Web_Camera_HD_Web_Camera_Ucamera001-02
    Card #4
        Name: alsa_card.pci-0000_00_1f.3
    

    For me, it was the "LAPDOCK" that kept stealing my audio.

  2. create the systemd unit, to call pactl and disable the card:

    $ mkdir -p ~/.config/systemd/user
    $ nano ~/.config/systemd/user/disable-cards.service
    

    Add these contents, changing the ExecStart line to refer to the card you want to drop:

    [Unit]
    Description=Disable card
    
    [Service]
    Type=simple
    Restart=on-failure
    ExecStart=pactl set-card-profile "alsa_card.usb-DisplayLink_LAPDOCK_U3D2338486250-02" off
    
    [Install]
    WantedBy=default.target
    
  3. enable the service: systemctl --user enable disable-cards

Now when you restart systemd will keep trying to disconnect that card until it succeeds. There's probably better systemd config to get this running after the monitor is plugged in; each device shows up as a "unit" (e.g. in the output of systemctl --user) so this could be improved to work as you plug/unplug things.

The other alternative is to change your /etc/pulse/default.pa to use module-switch-on-connect blacklist="REGEX_MATCHING_THE_CARD_NAME", but that didn't work for me; there's no way to customize module-switch-on-port-available, and I think that's what was selecting it for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .