Ordered sound devices
Hello,
I am having trouble ordering my sound devices. Usually, I modify the /etc/modprobe.d/sound and put the correct indexes for each of my sound devices but this time it doesn't work. This time I have two devices that use the same module and I don't know how I can differentiate between them. I always get the USB as the first card no matter how I tweak my sound file. Any ideas, how I can fix that? I think the only way to do that id to write a udev rule, but I am unsure how to do that. In which file do I have to put that new rule if that is the case. Thank you for your help. Output of /proc/asound/cards Code:
0 [U0x46d0x8c5 ]: USB-Audio - USB Device 0x46d:0x8c5 Code:
0 snd_usb_audio Code:
alias snd-card-0 snd-hda-intel |
I don't have the answer, but this is an excellent question. I guess it's time for us audio users to figure out how to write udev rules. So until a udev expert shows up and tells us the answer, let's dig in and look for a solution.
The problem is basically that when a system is started, the audio devices come up in a random order. The first one that's recognized is assigned to be the default audio device, even if it's the wrong one. This problem has been called "sound card roulette". People have been using stopgap methods to control the order in which multiple audio devices start up. This is a case where the usual stopgap methods fail. This writeup seems like a logical starting point for understanding udev rules: http://reactivated.net/writing_udev_rules.html The udev rules are in /etc/udev. I don't understand it yet, but here is an article from the ALSA wiki on writing udev rules: http://alsa.opensrc.org/index.php/Udev @funkynesh - what kind of audio devices are you working with? |
Okay, googling and consulting the man page for udev reveals that there are two sets of udev rules to work with.
The default rule set is in /lib/udev/rules.d/ The custom rule set is in /etc/udev/rules.d/ I think the idea is that first all the default rule files are merged, then all the custom rules are merged (with the custom rules overriding the default rules of the same name). There is a default ALSA rule file named 40-alsa.rules in /lib/udev/rules.d/: Code:
# do not edit this file, it will be overwritten on update I also guess that the nature of the custom ALSA rules will be to recognize each audio device and assign it the desired device name, i.e., /dev/dsp for the first device, /dev/dsp1 for the second, etc. |
Here's something that seems to work on my system. I put the following into /etc/udev/rules.d/40-alsa.rules:
Code:
# The USB sound device will create: This is probably enough to get you going. It's a very similar approach to what was given in the "Simple Udev Rules" section of the ALSA wiki referenced above, except that the rules don't key off the driver name. Edit to add: This is for Slackware 12.2. I think udev may have been significantly reorganized for 12.2, so this solution may require changes to work with previous versions. |
ALSA Configuration is a Mess
I even wrote an e-mail to the ALSA users mailing list on this topic and Jaroslav responded that the task of configuring ALSA lies with the various distributions. ALSA can be ordered, but it takes far too much time for most users to solve. Here's my file, sound, in /etc/modprobe.d . HTH you arrive at a workable solution... Pay close attention to how the snd-usb-audio devices are ordered.
Code:
|
I think there's an even simpler way for the original poster to select his desired default audio device.
Even though the OP has two audio devices using the same driver, all his audio devices have different ID strings (U0x46d0x8c5, NVidia, or HDMI). So they can be differentiated by ID string and the default can be selected in an ~/.asoundrc file. In the user's home directory create the file ~/.asoundrc as follows: Code:
pcm.!default { For Slackware, it could be put into /etc/asound.conf to make it effective for all users. This isn't a universal solution, but it sure is simpler than messing with udev or modprobe. It works when the desired default device has a unique ID string. |
Wow!
I quickly browsed the replies and there is a lot of precious information in here. :) I managed to fix my problem by discovering that I could assign several indexes to the same driver in /etc/modprobe.d/sound. It isn't perfect, but so far it works. Code:
options snd-hda-intel index=0,1 I am definitely going to bookmark that thread. Thank you all! |
Agreed, it's been a challenge to learn about ALSA configuration. I think the fundamental problem is very simple: sound devices don't have unique serial numbers.
Anyway, it seems we all have pieces of the answer. Here's my attempt to consolidate them into a systematic approach to ALSA sound device ordering in Slackware 12.2. 1 - Start up the system and do cat /proc/asound/cards 2 - If all the sound devices have been autodetected AND the desired default sound device has a unique ID string, then you can use ~/.asoundrc or /etc/asound.conf to select the right default sound device. If all you need to do is select the right default device, you're finished. 3 - If there are any sound devices which have not been autodetected OR if the .asoundrc approach didn't suffice, you need to configure an appropriate /etc/modprobe.d/sound Everything you need to know about configuring /etc/modprobe.d/sound is in the following documentation file which probably came with your Slackware distro (at least this is its location in 12.2): /usr/src/linux/Documentation/sound/alsa/ALSA-Configuration.txt 4 - Within /etc/modprobe.d/sound you can influence the sound device ordering by controlling the order in which the sound card drivers are loaded. If all the sound devices use different drivers, you're finished. 5 - If there are multiple sound devices which use the same driver, you can sometimes use the module options to order all the devices which share a driver. As shown in tpreitzel's example, the snd-usb-audio lets you order USB audio devices by vid (USB vendor ID) and pid (USB product ID). If you can distinguish all your sound devices by their drivers and module options in /etc/modprobe.d/sound, you're finished. 6 - This leaves the trickiest case, where there are multiple identical sound devices that need to be ordered. By identical, I mean devices that for example report the same USB vendor & product IDs. For this case, I think the udev approach is needed, because it can distinguish between sound devices based on their physical addresses on the USB or PCI buses. |
All times are GMT -5. The time now is 03:10 PM. |