LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How do I configure X to use an alternate audio device? (https://www.linuxquestions.org/questions/linux-software-2/how-do-i-configure-x-to-use-an-alternate-audio-device-4175578042/)

RandomTroll 04-21-2016 02:27 PM

How do I configure X to use an alternate audio device?
 
The jack built into my computer stopped working. I now use a usb-audio converter. I changed asound.conf to use it but the X apps that I have tried still send sound to the built-in speakers. I assume I need a new OutputDevice section in xorg.conf, but I can't find a model for how to write it.

frankbell 04-21-2016 08:06 PM

What distro/version are you using? Results of a web search are like to refer to specific distros.

Here's an article from the ALSA wiki that might be helpful, but it would be useful to know whether you are using a distro with Pulse Audio.

Shadow_7 04-21-2016 09:29 PM

If you're using pulse audio. pavucontrol

$ pavucontrol

Otherwise you need to change the users .asoundrc

FILE: ~/.asoundrc
Code:

defaults.ctl.card 1
defaults.pcm.card 1
defaults.pcm.device 0

Where the card # is the index associated in /proc/asound/cards

$ cat /proc/asound/cards

And of course test it. Sound is part of the kernel, not X.

$ speaker-test -c 2

Where -c 2 is 2 channels, so left and right speakers alternating. Control + C to exit.

seasons 04-22-2016 08:45 AM

Avoid using custom asound.conf if possible (especially if using Pulseaudio). The easiest way is to disable your onboard audio device in the BIOS if it allows such an option.
Another way is to add a line like this in /etc/modprobe.d/alsa-base.conf:
Code:

options snd-hda-intel enable=0  #use enable=0,0 if you also need to disable HDMI audio
Also, make sure you don't have a line in alsa-base.conf that prevents USB audio devices from getting index 0.

RandomTroll 04-23-2016 12:53 PM

I misdiagnosed. Outside of X I used mplayer, which I configured to use the usb device; the X clients use the default alsa device, which was the builtin. It seems that alsa always makes device 0 the default device, that one cannot configure it otherwise. Thus, preventing the builtin device's modules from loading makes the usb device the default.

Curiously Firefox still makes no noise (xine does), which would seem to make this a Firefox problem.

Shadow_7 04-23-2016 02:41 PM

You probably need the gstreamer-plugin stuff and other things for firefox to work. I believe in my case it works with alsa natively, but not with pulseaudio. Various configuration tricks to make it work with pulseaudio, but not the default in debian iirc.

Yes, device 0 is the default device. But you CAN re-order your driver modules to make any audio device have the index of 0. Although a tad old school to accomplish that and might be quirky if you have multiple sound devices of the same type using the same driver. Basically alsa.conf stuff in /etc/modprobe.d/ to make that happen.

Most times I can get away with NOT using pulseaudio and changing the .asoundrc to say which device index to use.

$ echo "defaults.pcm.card 1" > .asoundrc

Literally as simple as that, unless your distro installed and configured your audio system by default. And pulseaudio by default. Also note that if you do not setup forced indexing, that soundcards can get a different index between reboots. If you have more than one. And most do since your video card, webcam, and everything has a soundcard now. If it's just output or just input, it's still a soundcard.


All times are GMT -5. The time now is 02:15 AM.