Disable a linux sound card

13,589

Solution 1

Perhaps your NVIDIA card is set as the default audio device; I have a similar issue when trying to get audio via HDMI in e.g. Flash. Problem is my Realtek card is set as default and some applications doesn't let you select which sound device to use. I solve the issue by setting my HDMI audio as default aduio device, which can be achieved by editing the .asoundrc file in your home directory.

Here's what to do. First you have to find the proper card and device you want to use. Run the command aplay -l. I'm guessing you want audio to come out your USB headphones? From the output of aplay -l you can see that the USB headphones is card number 2 and device number 0, so put the following in your .asoundrc file.

pcm.!default {
type hw
card 2
device 0
}

ctl.!default {
type hw
card 2
device 0
}

Solution 2

  1. You can knock PCI/PCIe cards out from under ALSA with the remove sysfs node:

    echo 1 | sudo tee /sys/class/sound/card0/device/remove
    

    For example:

    # current cards
    $ cat /proc/asound/cards
    0 [HDMI           ]: HDA-Intel - HDA ATI HDMI
                        HDA ATI HDMI at 0xfcba0000 irq 73
    1 [Generic        ]: HDA-Intel - HD-Audio Generic
                        HD-Audio Generic at 0xfca00000 irq 76
    2 [Mic            ]: USB-Audio - Samson Meteor Mic
                        Samson Technologies Samson Meteor Mic at usb-0000:09:00.3-2.3, full speed
    3 [SoundBar       ]: USB-Audio - Dell AC511 USB SoundBar
                        Dell Dell AC511 USB SoundBar at usb-0000:09:00.3-2.4.1, full speed
    
    # remove cards
    $ echo 1 | sudo tee /sys/class/sound/card0/device/remove
    1
    $ echo 1 | sudo tee /sys/class/sound/card1/device/remove
    1
    
    # updated cards
    $ cat /proc/asound/cards
    2 [Mic            ]: USB-Audio - Samson Meteor Mic
                        Samson Technologies Samson Meteor Mic at usb-0000:09:00.3-2.3, full speed
    3 [SoundBar       ]: USB-Audio - Dell AC511 USB SoundBar
                        Dell Dell AC511 USB SoundBar at usb-0000:09:00.3-2.4.1, full speed
    

    To re-enable the card(s) poke the PCI rescan node:

    echo 1 | sudo tee /sys/bus/pci/rescan
    
  2. USB cards are a little trickier since you have to read the USB device path out of the /sys/class/sound/cardX/device symlink to plumb it into device/unbind:

    CARD=card3; \
    basename $(readlink /sys/class/sound/$CARD/device) | \
    sudo tee /sys/class/sound/$CARD/device/unbind
    

Note that removing card 0 will confuse alsamixer:

$ alsamixer
cannot open mixer: No such file or directory

...so make sure to select a different card with the --card option.

Share:
13,589

Related videos on Youtube

Ferenc Deak
Author by

Ferenc Deak

Updated on September 18, 2022

Comments

  • Ferenc Deak
    Ferenc Deak over 1 year

    I have updated to Kubuntu 12.10 from 12.04 and my sound stopped working ... I think because of I have two soundcards in my system and I think that disabling one of them shouldsolve the problem. Here is the output of inxi:

    $ inxi -Ax
    Audio:     Card-1: NVIDIA GF106 High Definition Audio Controller
                 driver: snd_hda_intel     bus-ID: 05:00.1
               Card-2: Advanced Micro Devices [AMD] nee ATI SBx00 Azalia (Intel HDA) 
                 driver:     snd_hda_intel bus-ID: 00:14.2
               Sound: Advanced Linux Sound Architecture ver: 1.0.25
    $ 
    

    I want to disable the NVIDIA GF106 because it's HDMI output is not coming to my earphones. How do I do that? Or any other tips to get the sound back? Thanks a lot.

    Here is the aplay -l output:

    **** List of PLAYBACK Hardware Devices ****
    card 0: SB [HDA ATI SB], device 0: ALC892 Analog [ALC892 Analog]
      Subdevices: 0/1
      Subdevice #0: subdevice #0
    card 0: SB [HDA ATI SB], device 1: ALC892 Digital [ALC892 Digital]
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 1: NVidia [HDA NVidia], device 7: HDMI 0 [HDMI 0]
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 1: NVidia [HDA NVidia], device 8: HDMI 0 [HDMI 0]
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 1: NVidia [HDA NVidia], device 9: HDMI 0 [HDMI 0]
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 2: Headset [Logitech USB Headset], device 0: USB Audio [USB Audio]
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    

    and here is the ~/.asoundrc

    pcm.!default {type hw card 0 device 0}
    ctl.!default {type hw card 0 device 0}
    

    and still not working :(

  • Ferenc Deak
    Ferenc Deak over 10 years
    modified the question to include my output of aplay -l
  • Ferenc Deak
    Ferenc Deak over 10 years
    Even after applying the changes it is not working :(
  • AcId
    AcId over 10 years
    I'm guessing you want audio to come out your USB headset? (correct me if I'm wrong). From aplay -l you can see that the card number is 2 and device number is 0, so your .aoundrc should read pcm.!default { type hw card 2 device 0 } and ctl.!default { type hw card 2 device 0 }. And remeber to restart any application that you want to use the new default device.
  • AcId
    AcId over 10 years
    I've found it helpfull to have several .aoundrc.* files in my home dir. E.g. I have a file called .aoundrc.hdmi file so that I can just do a cp ~/.asoundrc.hdmi ~/.asoundrc whenever I want to set HDMI as the default device.
  • AcId
    AcId over 10 years
    I've edited my answer according to the information supplied from aplay -l.
  • Ferenc Deak
    Ferenc Deak over 10 years
    No, actually I want the output from the analog device of the ATI SB. The USB headphone is plugged into a Windows Virtual machine and it works there. So, for me card 0, and device 0 were the obvious changes... That's how I created the .asoundrc
  • AcId
    AcId over 10 years
    Have adjusted the mixer levels with alsamixer? There's usually a separate channel for headphones/AUX output, you should also make sure that it is not muted.
  • Ferenc Deak
    Ferenc Deak over 10 years
    Strangely I cannot start alsamixer: $ alsamixer cannot open mixer: Invalid argument