You are not logged in.

#1 2012-03-06 20:01:44

stavrakis
Member
Registered: 2011-12-29
Posts: 22

[SOLVED] Switch all audio input/output to USB headset

Hi, I have a USB headset that I frequently plug/unplug from the computer. Is there a way to make it the default sound device when plugged, and automatically switch back to the motherboard's on-board audio device when unplugged?

Last edited by stavrakis (2012-04-26 15:57:56)

Offline

#2 2012-03-06 23:53:53

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,354

Re: [SOLVED] Switch all audio input/output to USB headset

You don't mention what configuration you're using for sound. I use a script to do it, with pulseaudio, but the process would differ depending what you use.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#3 2012-03-07 17:14:04

stavrakis
Member
Registered: 2011-12-29
Posts: 22

Re: [SOLVED] Switch all audio input/output to USB headset

I have an Intel HDA 5.1 internal audio card, and a 5.1 USB headset, using the modules snd_hda_intel and snd_usb_audio respectively. The internal card is set as card 0, and the usb headset is set as card 1.
I'm using ALSA right now, but I wouldn't have a problem switching to Pulseaudio if it's easier.



EDIT: I used pulseaudio and solved it for applications that are not already playing sound (not shown on pavucontrol's Playback tab)

I created a udev rule, which executes a script when card1 is inserted, since I know it is the USB sound device:

SUBSYSTEM=="sound", KERNEL=="card1", ACTION=="change", RUN+="/home/stavros/bin/pulse-ins.sh"

This script (pulse-ins.sh) executes another script as the current user:

#!/bin/bash
su -c "/home/stavros/bin/pulse_insert_card.sh & exit" stavros

pulse_insert_card.sh contains the following:

#!/bin/bash
/usr/bin/pacmd set-default-sink alsa_output.usb-0d8c_USB_Sound_Device-00-Device.analog-surround-51
/usr/bin/pacmd set-default-source alsa_input.usb-0d8c_USB_Sound_Device-00-Device.analog-stereo

These 2 scripts and the udev rule automatically change pulseaudio's default output & mic input when the card is inserted. However, applications already playing music have to be switched manually through pavucontrol.
Sometimes, the card is incorrectly identified as "Analog Stereo Duplex", with no 5.1 option. In that case killing pulseaudio and letting it start again solves the problem.

Last edited by stavrakis (2012-03-31 11:49:43)

Offline

Board footer

Powered by FluxBB