LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 02-25-2013, 11:44 AM   #1
WhiteHotLoveTiger
Member
 
Registered: Jun 2012
Location: NB, Canada
Distribution: Slackware
Posts: 68

Rep: Reputation: 1
Getting audio to switch to usb headphones


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.

I read through http://docs.slackware.com/howtos:har..._snd-hda-intel and tried
Code:
echo "options snd-hda-intel model=auto" > /etc/modprobe.d/snd-hda-intel.conf
though this had no effect, even after a restart.

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.
 
Old 02-25-2013, 12:07 PM   #2
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,294

Rep: Reputation: Disabled
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).

However, if this thread accumulates good info I will collect it into a HOWTO on http://docs.slackware.com/howtos:start .

Eric
 
Old 02-25-2013, 12:47 PM   #3
frankiej
LQ Newbie
 
Registered: Feb 2013
Distribution: Slackware
Posts: 16

Rep: Reputation: 4
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
 
Old 02-25-2013, 02:00 PM   #4
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,294

Rep: Reputation: Disabled
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
 
Old 02-25-2013, 02:14 PM   #5
WhiteHotLoveTiger
Member
 
Registered: Jun 2012
Location: NB, Canada
Distribution: Slackware
Posts: 68

Original Poster
Rep: Reputation: 1
@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.
 
Old 04-13-2013, 11:12 AM   #6
Slacker B.
LQ Newbie
 
Registered: Apr 2013
Posts: 2

Rep: Reputation: Disabled
Quote:
Originally Posted by Alien Bob View Post
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:

(Taken from http://alsa.opensrc.org/.asoundrc)


% 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 View Post
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.



Slacker B.
 
Old 04-13-2013, 11:56 AM   #7
DavidMcCann
Senior Member
 
Registered: Jul 2006
Location: London
Distribution: CentOS, Salix
Posts: 3,124

Rep: Reputation: 792Reputation: 792Reputation: 792Reputation: 792Reputation: 792Reputation: 792Reputation: 792
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

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

Get the card number with "aplay -l".

The KDE configuration tool doesn't touch ALSA, only Phonon, which means that it words with Kinqueror but not with Firefox.
 
  


Reply

Tags
audio, usb


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Audio output only on headphones on laptop adrian2009 Slackware 11 10-17-2010 08:42 AM
USB Headphones & OnBoard Audio/Speakers MIRV Linux - Hardware 0 02-27-2008 03:25 AM
Sound: how to switch from headphones to speakers? FreakboY Slackware 1 11-28-2007 12:59 AM
no audio on Headphones d4harvey Linux - Laptop and Netbook 5 10-21-2005 10:22 AM
Core 4 audio through headphones only keithmcd Fedora 5 08-05-2005 12:19 AM


All times are GMT -5. The time now is 09:03 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration