LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 12-29-2013, 07:11 PM   #1
narz
Member
 
Registered: May 2007
Location: US
Distribution: slackware
Posts: 184

Rep: Reputation: 35
Switching sound to HDMI output


Does anyone know an easy way I can switch alsa to HDMI output?

I found a udev script on some blog that easily lets me use my USB headset when I have it plugged and switch back to my internal soundcard when it's unplugged.

Code:
KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K > /etc/asound.conf; echo defaults.pcm.card $$K >>/etc/asound.conf'"

KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/bin/sh -c 'echo defaults.ctl.card 0 > /etc/asound.conf; echo defaults.pcm.card 0 >>/etc/asound.conf'"
I'd like to do something similar with HDMI. Not sure I understand why in 2013, switching sound cards with ALSA is still something so hackish and complicated
 
Old 12-29-2013, 07:55 PM   #2
aus9
Guru
 
Registered: Oct 2003
Posts: 5,060

Rep: Reputation: Disabled
Hi

there are 2 main ways

1) easiest (less mess) is on the fly switching by installing pulseaudio, if you are using slackware check out the slackbuilds etc as I don't use slack

2) messier is to first research your config file like this

Code:
cat /proc/asound/pcm

will give you a card list and a device list.

You may have more than one hdmi device showing.

Then create a .asoundrc in home folder

using the formula

pcm.!default {
type hw
card <number>
device <number>
}

since you have an analog device I will assume card 1 will be your hdmi YMMV
but device number may be something like 3 or 5 or 7 etc

once you have created the file,
log out and log back in to try a different device number etc

#######################

once config file is confirmed, then to swap back to analog
rename that .asoundrc to .bsoundrc so alsa can't find it
log out and log in and you regain analog

good luck
 
Old 12-29-2013, 09:40 PM   #3
narz
Member
 
Registered: May 2007
Location: US
Distribution: slackware
Posts: 184

Original Poster
Rep: Reputation: 35
Quote:
Originally Posted by aus9 View Post
Hi

there are 2 main ways

1) easiest (less mess) is on the fly switching by installing pulseaudio, if you are using slackware check out the slackbuilds etc as I don't use slack

2) messier is to first research your config file like this

Code:
cat /proc/asound/pcm

will give you a card list and a device list.

You may have more than one hdmi device showing.

Then create a .asoundrc in home folder

using the formula

pcm.!default {
type hw
card <number>
device <number>
}

since you have an analog device I will assume card 1 will be your hdmi YMMV
but device number may be something like 3 or 5 or 7 etc

once you have created the file,
log out and log back in to try a different device number etc

#######################

once config file is confirmed, then to swap back to analog
rename that .asoundrc to .bsoundrc so alsa can't find it
log out and log in and you regain analog

good luck
Swapping the .asoundrc file and logging in/out is the only way I know how to get hdmi sound, but it's not very practical, and I don't want to use pulseaudio.
 
Old 12-29-2013, 10:21 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Whatever fits the task best
Posts: 15,826
Blog Entries: 2

Rep: Reputation: 4209Reputation: 4209Reputation: 4209Reputation: 4209Reputation: 4209Reputation: 4209Reputation: 4209Reputation: 4209Reputation: 4209Reputation: 4209Reputation: 4209
Quote:
Originally Posted by narz View Post
Not sure I understand why in 2013, switching sound cards with ALSA is still something so hackish and complicated
Easy answer: Because almost any distro uses Pulseaudio nowadays, so there is no need to integrate that functionality in Alsa for most people.
Pulseaudio works fine on my Slackware systems, so this is indeed the easy way, but if you really don't want to use it it may be possible that it works with restarting Alsa instead of logging out and in again.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically switching tv layout and sound hardware when connecting HDMI acid_kewpie Linux - Software 8 01-02-2014 06:44 PM
Is it possible to play Blu Ray through a video card HDMI output to HDMI TV? SharpyWarpy Linux - Hardware 5 10-28-2012 02:01 AM
[ProLiant MicroServer, ATI R6xx HDMI, Digital Out, HDMI] No HDMI sound at all vnatius Linux - Hardware 15 08-16-2012 02:09 PM
Quadro FX570 - HDMI not listed as output device (therefore no sound :-( ) ggerri Linux - Hardware 11 10-05-2011 07:24 PM
no sound output ati hdmi Grub3r Linux - Laptop and Netbook 3 02-14-2011 07:56 PM


All times are GMT -5. The time now is 07:28 PM.

Main Menu
Advertisement
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