SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've got a set of usb headphones, and I'd like to have all of my audio switch over to them when they're plugged in, rather than coming out of my laptop's speakers. Currently, my sound plays from the laptop speakers regardless of whether the headphones are plugged in or not.
When I go into kmix -> Settings -> Audio Setup, the headphones are listed as a playback device. I can select it, play the test audio, and it does come out of the headphones, even while I have audio from another source playing out of the laptop speakers at the same time.
I've moved the headphone up to the top of preference list. Now whenever I plug in/unplug the headphones I get a little pop-up message telling me that audio playback is switching to the headphones/falling back to the laptop speakers. The only problem is that my speakers keep on playing all my audio, and the headphones don't play anything.
My next step is to start looking through some of the more complex options on that page, but I feel like the solution should be pretty simple. After all, the headphones have played a little audio, and Slackware seems to think it's switching the playback device.
I'd love to hear any suggestions.
Specifics:
Slackware-current
Lenovo ThinkPad T410
Logitech usb headphones/mic
Last edited by WhiteHotLoveTiger; 02-25-2013 at 12:04 PM.
It will probably involve writing custom UDEV rules. Google around a bit, no distro has this fully covered, but you will find lots of good pointers, as well as scripts.
I never bothered to try them out (I do not own a USB headset but my son does).
I have a Logitech USB headset that I have gotten to work without any changes except in KMix -> Settings -> Audio Setup.
You said you changed the preference order. Which preference order did you change? Changing the Audio Playback level itself has no effect whatsoever, at least not for me. If I change the preferences in Audio Playback - Music, I do see things work for Amarok. I can unplug and plug in my headset and things switch back and forth just fine (it won't switch if you have the headset plugged in initially, I guess it has to see the USB device trigger).
You can do that "Apply Device List To" to make changes at the Audio Playback level and have it apply to all of the sub-types. But I struggled with that for a bit until I finally realized the top level doesn't have any direct effect.
Note that this is on a stock Slackware 14 system.
Update:I did a little more playing around and what I posted probably will not help you in your situation. I don't get the notification that it is trying to switch when I don't have the sub-type preference orders switched like I was suggesting. Sorry.
Last edited by frankiej; 02-25-2013 at 01:22 PM.
Reason: Update information
It would be best to come up with a DE-agnostic solution. KDE is smart at switching audio playback devices on-demand, but it would be nice to find a solution which works for other desktop environments as well. Even for the console.
@Bob: I'll have to take a look at UDEV later. I'll let you know if I get it working.
@frankiej: I was ititially just changing the order under music, but I later used the "Apply Device List To". Even after setting the preference order in each category, I'm still having the same problem.
It would be best to come up with a DE-agnostic solution. KDE is smart at switching audio playback devices on-demand, but it would be nice to find a solution which works for other desktop environments as well. Even for the console.
Eric
Hi Alien Bob,
First off I know I'm posting in a thread that's several weeks old but I'm been attempting to resolve this on my own. I apologize for the late reply!
I've been struggling with this on my laptop and home machine for a while now. I have yet to pursue the UDEV route of getting this to work as I'm using the troubleshooting to learn more about how sound works on Linux.
Here's what I've attempted:
I did find this script which at least in my case allows me to switch between cards fairly easily:
% cat /usr/bin/asoundrc
#!/bin/bash
# asoundrc v0.1.0 20090101 markc@renta.net GPLv3
# asoundrc v0.2.0 20090320 quatro_por_quatro@yahoo.es GPLv3
#
# A simple script to create a particular default audio device regardless
# of what cards are loaded or in what order. It could be used anytime or
# placed in a ~/.bashrc script for a persistent setup every login.
#
# Usage: asoundrc [DEFAULT_CARD] > ~/.asoundrc
# use the first parameter as the card name, or else
# look for the sound card, discarding those that are only microphones
# when there are multiple cards, use the first one
if default_card="${1:-$(cat "$(for f in $(ls -1 /proc/asound/card[0-9]*/{midi,codec}* 2>/dev/null); do echo "${f%/*}"; done \
| sed -e '\|^[\[:blank:]\]$|d' -e 'q')/id" 2>/dev/null)}"; then
echo "Using sound card: ${default_card}" >&2
cat /proc/asound/card[0-9]*/id | \
gawk --assign default_card="${default_card}" \
'{print "pcm."$1" { type hw; card "$1"; }\nctl."$1" { type hw; card "$1"; }" }
END {print "pcm.!default pcm."default_card"\nctl.!default ctl."default_card}'
else
echo "Warning: No sound cards found." >&2
fi
This allowed my to switch the primary sound device/output between my USB headset or speakers. However I'm left with the issue that only one program may use the audio device at a time. The second application attempting to use the sound gets a resource busy error. I found a suggestion on another distributions wiki on how to attempt and resolve this:
Software mixing (dmix)
Note: For ALSA 1.0.9rc2 and higher on analog sound outputs you do not need to setup dmix. Dmix is enabled as default for soundcards which do not support hardware mixing.
If that does not work however, it is a matter of simply creating a .asoundrc file in your home folder with the following contents.
pcm.dsp {
type plug
slave.pcm "dmix"
}
I ended up creating a .asound.rc file in my home directory using the previously mentioned scirpt and attempting to append the above pcm.dsp into the .asound.rc file with the hopes that this would allow multiple applications to access the sound device. It didn't work.
dugan answered in this thread regarding a similar issue (sound only playing from one device) to disable the load_alsa_oss_modules:
Quote:
Originally Posted by dugan
To get software mixing that always works, all I do is edit /etc/rc.d/rc.alsa and comment out the load_alsa_oss_modules lines. That will prevent anything from running in OSS Emulation mode. Anything running in OSS emulation mode would get exclusive use of the sound card and block everything else from using it. Anything not running in OSS emulation mode gets software mixing, and that's been true for quite a few years.
I have attempted to do so but I was still unable to get the sound to auto switch to a USB device (headset)
I'm not an expert but I am willing to attempt and find a DE solution to the problem. Would anyone have suggestions on how to work towards that solution? I think this functionality would be a great addition to Slackware desktop experience. I imagine I'm not the only one having this issue or the only one who's not familiar enough with UDEV to make it switch sound devices. All of this being said It looks like I may end up reading more on UDEV to get my sound working in the short term.
I've never tried my usb speakers with Slackware, although Salix sorts them out in seconds with a GUI tool), but have you tried creating $HOME/.asoundrc with contents like this
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.