You are not logged in.
I want to clarify and correctly set up my ThinkPad T61 sound system finally.
I'm running Arch64 + KDE.
There are two sound cards - the internal HDA Intel and external USB CM118.
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Intel [HDA Intel], device 0: AD198x Analog [AD198x Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: Intel [HDA Intel], device 1: AD198x Digital [AD198x Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
First of all, why are there both analog and digital subdevices?
I just need playback and/or recording support for these applications: opera, firefox, skype, clementine, mplayer, vmplayer. As high quality as possible.
Per-application sound control would be nice but if that adds too much clutter, I could live without it. No need for audio streaming or any other luxuries.
All the applications should use the USB card whenever it's plugged in. The internal SC should take over when CM118 is unplugged.
The problem is that most of the time it doesn't work. For example, if I plug out the USB card and then run some application like Clementine or Firefox there would be no sound ("connection refused" in Clementine).
Here is my asound.conf:
defaults.pcm.card 0
defaults.pcm.device 0
defaults.ctl.card 0
Also kMix/amix should switch the master channel from HDA Intel Master to C-Media Master automatically. The only way to do this is to write some kind of script, right?
AFAIK the following audio components are installed: ALSA, OSS (for some unknown reason), Phonon, Gstreamer.
I guess I can uninstall OSS without worries as no one seems to need it (checked with "whoneeds").
What about that Phonon? Would it override the asoud.conf if I set default device there? Why there are so many different devices in the Phonon configuration list:
C-Media USB Headphone Set, USB Audio (Default Audio Device)
C-Media USB Headphone Set (USB Audio)
C-Media USB Headphone Set, USB Audio (IECblablabla)
hw:1,0
hw:1,1
default
Intel Analog
Intel Digital
blablalba
And that C-Media triplet for every USB port the CM118 has been plugged in.
Too much confusion! All that mess for just two different cards.
So what is the proper way of setting primary and secondary sound cards in this situation?
Thank you!
Last edited by andrisll (2012-07-19 08:48:28)
Offline
andrisll,
1st, learn to structure your postings !
Without sounding too disruptive:
Your posting looks like a mess and makes it hard to read what you really want.
At least post short descriptive questions in a structured way (listed / numbered) !
Now lets head on to the questions I think I have destilled from your writings.
There are both digital and analog devices listed for sound cards mainly because they HAVE digital and analogue I/O. ALSA lists pretty much any device / control on your soundcard even if there might be no plugins available. My old SB Live Gamer, for example, reports tons of I/O, controls and switches in the ALSA mixer even if they aren't external usable. The multiple copies of your USB soundcard which are listed for each port it was plugged in seem to indicate issues with udev. You should verify if plugging and un-pluging the device works fine (check your /var/log/messages with tail -f while pluging / un-pluging your USB card). I suggest you fix this issue first because all following steps rely on a solid hardware detection.
Once the USB soundcard is detected and initialised correctly, you can solve the other problems.
There are several entries in the wiki you should read:
https://wiki.archlinux.org/index.php/ALSA
https://wiki.archlinux.org/index.php/Sound
https://wiki.archlinux.org/index.php/Udev
https://wiki.archlinux.org/index.php/Kernel_modules
From my experiences pulseaudio (https://wiki.archlinux.org/index.php/PulseAudio) sometimes makes things easier when dealing with multiple audio devices (e.g. bluetooth headset, HDMI sound, USB sound, etc) but you might experience other issues such as high CPU load, stuttering sound and such things. PA provides nice graphical tools to assign the output of specific programs to a specific audio device. YMMV....
If you stick to ALSA you could either use the approach described in the wiki on how to define a default sound card or choose the rough approach and simply unload all audio related modules and only load the module required for your USB soundcard. You will find all relevant informations (loading / unloading kernel modules, determining which module is needed for which soundcard) in the wiki entries I mentioned.
Good luck,
D$
My archlinux x86_64 host:
AMD E350 (2x1.6GHz) / 8GB DDR3 RAM / GeForce 9500GT (passive) / Arch running from 16GB USB Stick
Offline
I am sorry for my very late response and the lack of structure in my post.
I did some investigation and found a rather acceptable workaround for one of my problems described below.
Here is the basic functionality I need:
1. Automatic (on the fly) switching to the external sound card when it's plugged in and automatic fallback to the integrated SC when usb is unplugged.
2. Automatic (on the fly) switching of the kMix's master channel according to the changes mentioned above.
As for the first problem, I found this udev rule:
KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K > /etc/asound.conf; echo defaults.pcm.card $$K >>/etc/asound.conf"
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/bin/sh -c 'echo defaults.ctl.card 0 > /etc/asound.conf; echo defaults.pcm.card 0 >>/etc/asound.conf'"
This solution has some disadvantages but it is acceptible. If you know of any better solution, please tell me.
For the second problem, I found this script which uses qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.setCurrentMaster method to set the master channel. However, I think that constant monitoring for the usb SC being plugged is not very effective. So I thought appending the following code to the second line of the previous udev rule would do the work:
, RUN+="/usr/bin/qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.setCurrentMaster "ALSA::C-Media_USB_Headphone_Set:1" "Speaker:0""
But that results in some weird behaviour: master channel stays the same but there would be three new tabs in the kMix window now: USB Set", USB Set# and USB Set$.
Here's what log messages tell us:
07/14/12 12:25:13 PM localhost kernel [10889.749048] usb 3-1: new full-speed USB device number 13 using uhci_hcd
07/14/12 12:25:14 PM localhost kernel [10889.914921] input: C-Media USB Headphone Set as /devices/pci0000:00/0000:00:1a.1/usb3/3-1/3-1:1.3/input/input21
07/14/12 12:25:14 PM localhost kernel [10889.915454] generic-usb 0003:0D8C:000C.000C: input,hidraw0: USB HID v1.00 Device [C-Media USB Headphone Set ] on usb-0000:00:1a.1-1/input3
07/14/12 12:25:14 PM localhost mtp-probe checking bus 3, device 13: "/sys/devices/pci0000:00/0000:00:1a.1/usb3/3-1"
07/14/12 12:25:14 PM localhost mtp-probe checking bus 3, device 13: "/sys/devices/pci0000:00/0000:00:1a.1/usb3/3-1"
07/14/12 12:25:14 PM localhost mtp-probe checking bus 3, device 13: "/sys/devices/pci0000:00/0000:00:1a.1/usb3/3-1"
07/14/12 12:25:14 PM localhost mtp-probe checking bus 3, device 13: "/sys/devices/pci0000:00/0000:00:1a.1/usb3/3-1"
07/14/12 12:25:14 PM localhost mtp-probe bus: 3, device: 13 was not an MTP device
07/14/12 12:25:14 PM localhost mtp-probe bus: 3, device: 13 was not an MTP device
07/14/12 12:25:14 PM localhost mtp-probe bus: 3, device: 13 was not an MTP device
07/14/12 12:25:14 PM localhost mtp-probe bus: 3, device: 13 was not an MTP device
You see, the probe thing is running multiple times!
And here is an excerpt from udev debugger:
starting '/usr/bin/qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.setCurrentMaster '
'/usr/bin/qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.setCurrentMaster '(err) 'Could not connect to D-Bus server: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11'
'/usr/bin/qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.setCurrentMaster ' [2769] exit with return code 1
'/usr/bin/qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.setCurrentMaster '(err) 'Could not connect to D-Bus server: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11'
Some kind of X11 problem... And also happening twice! Why?
Running the setCurrentMaster method in terminal works very nicely, so the problem must be the way udev runs it.
One last thing - sometimes the usb SC automatically reconnects (disconnects and connects). I read somewhere that most probably the usb device makes the trouble, but maybe there are other possiblities?
Last edited by andrisll (2012-07-14 10:04:16)
Offline
UPDATE: I had to do "xhost +" and make the following script for the udev RUN command:
#!/bin/sh
export DISPLAY=:0.0
su - username -c "/usr/bin/qdbus org.kde.kmix /Mixers org.kde.KMix.MixSet.setCurrentMaster "ALSA::C-Media_USB_Headphone_Set:1" "Speaker:0""
PROBLEM SOLVED!
Last edited by andrisll (2012-07-19 08:47:43)
Offline