There is an easy way to switch between sound cards without needing to reboot. This is the solution I've come up with, and so far it works quite well.
In order to make this work, first I needed to gather some information on how ALSA looks at my sound cards. To do this, I used
aplay is a command-line sound recorder and player for ALSA soundcard driver. The
-l option lists all soundcards and digital audio devices.
The out put I got from the command above looked something like this:
Code:
**** List of PLAYBACK Hardware Devices ****
card 0: I82801DBICH4 [Intel 82801DB-ICH4], device 0: Intel ICH [Intel 82801DB-ICH4]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: I82801DBICH4 [Intel 82801DB-ICH4], device 4: Intel ICH - IEC958 [Intel 82801DB-ICH4 - IEC958]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Headset [Plantronics Headset], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
Notice how my integrated sound card is labeled
card 0 and my Plantronics DSP 500 is labeled
card 1. Depending on how ALSA loads your cards, these may be reversed. The important thing is to note that ALSA refers to one card by
0 and the other by
1.
Now, to switch between cards, simply create a file named
.asoundrc in your home directory.
.asoundrc is a file where you can create a customized configuration for ALSA.
Since my integrated sound card is the default, I wanted to be able to switch to my Plantronics device without rebooting. Since ALSA refers to that device as
card 1, I added the following to my .asoundrc file:
Code:
pcm.!default {
type hw
card 1
}
ctl.!default {
type hw
card 1
}
Here I'm creating two rules that tell ALSA I would like
card 1 to be the default device for output. Switching the output back to
card 0, my integrated sound card, is trivial:
Code:
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
Now, sound comes through my speakers rather than my Headset.
Since I only need to change two numbers in one file to make this switch happen, I imagine it would be quite easy to create a simple script that toggles these numbers for you automatically.