LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 03-19-2008, 08:34 AM   #1
wastingtime
Member
 
Registered: Sep 2004
Posts: 77

Rep: Reputation: 16
how to configure flash 9 in firefox to use a specific alsa device


My machine has a built in sound card and I also use USB headphones.
The machine is set to use ALSA.

I figured how to configure amarok, xine such that when the headphones are plugged in the audio plays through the headphones, and when they are not plugged in it plays through the speakers

However, I can not make firefox + flash 9 play through the headphones - the sound always go to the speakers.

Using audacity I noticed that when I plug the headphones it lists new ALSA device, and also /dev/dsp1 . And indeed by selecting /dev/dsp or /dev/dsp1 I can tell audacity to play either through the speakers or the headphones. When I unplug the headphones, the additional alsa device and /dev/dsp1 disappear.

I found a post that said use aoss (separate package from synaptic) and specify /dev/dsp1. That did not work and after more reading I learned that flash 9 in firefox uses ALSA (where the old flash 7 used OSS so the aoss solution might had worked for it)

So my question is how do I tell flash 9 in firefox to use a specific alsa device.

An alternative would be to swap the order of the ALSA devices so flash 9 finds the headphones first.
Ideally, that would work in such a way that when the headphones are plugged they are the first device, and when not plugged the speakers are.
Or it could use a script that you run to select which device is first (i.e. the default)
 
Old 03-20-2008, 01:46 PM   #2
pwalden
Member
 
Registered: Jun 2003
Location: Washington
Distribution: Fedora FC19, Raspbian
Posts: 227

Rep: Reputation: 32
Probably not a good solution, but on my Fedora 7 laptop, if you boot with the USB sound plugged in, it sets up the USB sound as the primary alsa device, while the built in sound is ignored. Thus fash 9 goes to the USB.
 
Old 03-21-2008, 04:52 PM   #3
wastingtime
Member
 
Registered: Sep 2004
Posts: 77

Original Poster
Rep: Reputation: 16
A solution is create a file .asoundrc in you home directory that specify the default audio device.

Since in my case I want to change the default device to be the USB headphones when they are plugged in and to the builtin speakers when the USB headphones are not plugged in, I created two different .asoundrc files and I swap them as necessary.

You'd need to close programs that hold to the sound device when swapping (e.g. amarok)

1. Plug in your USB audio device and find out the names of the builtin audio, and the USB audio by running in a terminal (kconsole)
Quote:
$ aplay -l
Mine are
card 0: IHC6
card 1: Headset

2. Create two asoundrc files, one for each configuration and place them in you home directory (notice only the last two lines are different)

.asoundrc.builtin
Quote:
pcm.builtin { type hw; card ICH6; }
ctl.builtin { type hw; card ICH6; }

pcm.usb { type hw; card Headset; }
ctl.usb { type hw; card Headset; }

pcm.!default pcm.builtin
ctl.!default ctl.builtin
.asoundrc.usb
Quote:
pcm.builtin { type hw; card ICH6; }
ctl.builtin { type hw; card ICH6; }

pcm.usb { type hw; card Headset; }
ctl.usb { type hw; card Headset; }

pcm.!default pcm.usb
ctl.!default ctl.usb
3. Create a script to detect whether the headphones are plugged in or not and switch files accordingly; place it in your home directory. As explained above I found out that when the headphones are plugged in /dev/dsp1 exists

switch-audio
Quote:
#!/bin/bash
if [ -e /dev/dsp1 ]; then
cp -f ~/.asoundrc.usb .asoundrc
else
cp -f ~/.asoundrc.builtin .asoundrc
fi
Make sure to give it execute permissions
Quote:
$ chmod +x switch-audio
Now after plugging or unplugging the headphones, close amarok, firefox, etc. and run the script. I created a link to it and placed it in the task bar, where I also have links to amarok, firefox etc.

There should also be a way to run the script automatically when the headphones are plugged or unplugged, but I did not bother with that.
 
1 members found this post helpful.
Old 10-19-2008, 05:46 AM   #4
wayno
Member
 
Registered: May 2007
Location: Brisbane, Australia
Distribution: Fedora 8/9, Xandros (eeepc)
Posts: 110
Blog Entries: 1

Rep: Reputation: 15
Quote:
Originally Posted by wastingtime View Post
A solution is create a file .asoundrc in you home directory that specify the default audio device.

Since in my case I want to change the default device to be the USB headphones when they are plugged in and to the builtin speakers when the USB headphones are not plugged in, I created two different .asoundrc files and I swap them as necessary.

You'd need to close programs that hold to the sound device when swapping (e.g. amarok)

1. Plug in your USB audio device and find out the names of the builtin audio, and the USB audio by running in a terminal (kconsole)


Mine are
card 0: IHC6
card 1: Headset

2. Create two asoundrc files, one for each configuration and place them in you home directory (notice only the last two lines are different)

.asoundrc.builtin


.asoundrc.usb


3. Create a script to detect whether the headphones are plugged in or not and switch files accordingly; place it in your home directory. As explained above I found out that when the headphones are plugged in /dev/dsp1 exists

switch-audio


Make sure to give it execute permissions


Now after plugging or unplugging the headphones, close amarok, firefox, etc. and run the script. I created a link to it and placed it in the task bar, where I also have links to amarok, firefox etc.

There should also be a way to run the script automatically when the headphones are plugged or unplugged, but I did not bother with that.
Fantastic!! I've been searching for a solution to this problem for my Fedora 9 laptop and Logitech wireless USB headset. Everyone else is talking about 'asoundconf list' but I don't have and can't find that package. This solution is very simple and worked a treat for me.

Thanks.

Last edited by wayno; 10-19-2008 at 06:43 AM.
 
Old 10-21-2008, 12:26 PM   #5
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 1,506

Rep: Reputation: 233Reputation: 233Reputation: 233
There's also a defaults.pcm.card 0 option for .asoundrc

...
defaults.pcm.card 0
...

Where the number represents the card / device as it appears in /proc/asound/cards. The scripted solution might work a little faster than manually editing .asoundrc each time.

Another method since many web browsers default to card 0 is to re-index your alsamodules. One of the only ways to get things like Festival to use a specific card.

#/etc/modprobe.d/alsa_custom
options snd-usb-audio index=0

Or something more like this in full.

#/etc/modprobe.d/alsa_custom START
alias char-major-116 snd
alias char-major-14 soundcore

options snd major=116 cards_limit=3
options snd-usb-audio index=0
options snd-atiixp index=1
options snd-atiixp-modem index=2

alias snd-card-0 snd-usb-audio
alias sound-slot-0 snd-card-0
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss

alias snd-card-1 snd-atiixp
alias sound-slot-1 snd-card-1
alias sound-service-1-0 snd-mixer-oss
alias sound-service-1-1 snd-seq-oss
alias sound-service-1-3 snd-pcm-oss
alias sound-service-1-8 snd-seq-oss
alias sound-service-1-12 snd-pcm-oss

alias snd-card-2 snd-atiixp-modem
alias sound-slot-2 snd-card-2
alias sound-service-2-0 snd-mixer-oss
alias sound-service-2-1 snd-seq-oss
alias sound-service-2-3 snd-pcm-oss
alias sound-service-2-8 snd-seq-oss
alias sound-service-2-12 snd-pcm-oss
#/etc/modprobe.d/alsa_custom END

In conjunction with rebooting, and/or just using /etc/init.d/alsasound stop|start (in debian), it gets the job done. For those troublesome OSS only applications. Like web browsers.

Another option might be to start the app with aoss. Or artsdsp -m or esddsp -m as applicable.
 
Old 10-19-2010, 08:01 PM   #6
darthaxul
Member
 
Registered: Aug 2008
Distribution: Gentoo; Funtoo
Posts: 197

Rep: Reputation: 18
asoundrc worked

pcm.usb {type hw; card Headset;}
ctl.usb {type hw; card Headset;}
pcm.!default pcm.usb
ctl.!default ctl.usb

gods, i was searching forever for this...
 
  


Reply


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
Way to make autofs mount to specific USB flash drive to specific folder? utahnix Linux - Software 2 11-24-2010 05:27 PM
Set up IP on specific eth device? johnnybhoy67 Linux - Networking 3 10-21-2005 12:33 PM
ALSA Sound delay with Flash in Firefox Rikra Debian 2 05-11-2005 09:28 AM
how to flash a message to a specific user on login mtest Programming 5 10-30-2003 01:36 AM
Mount hardware to specific location with specified device blixel Linux - Hardware 5 10-21-2003 04:21 PM


All times are GMT -5. The time now is 08:21 AM.

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