You are not logged in.

#1 2015-08-27 11:46:15

enihcam
Member
From: Internet
Registered: 2009-12-20
Posts: 222

how to setup sound device priority?

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: MID [HDA Intel MID], device 0: ALC269VB Analog [ALC269VB Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: MID [HDA Intel MID], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

My laptop has two devices on the same card, where first is the analog, and second is the HDMI. How to make the audio output to HDMI when HDMI is connected?

Thanks.

Offline

#2 2015-08-27 19:08:14

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,076

Re: how to setup sound device priority?

Quick solution, use pulseaudio and set hdmi as the fallback device, activate the module-switch-on-connect (before the if..udev-block) in the default.pa.

Long solution, try to do this in ALSA by following this: http://alsa.opensrc.org/Udev but I can't really help you further than this if you choose to go this route

Offline

#3 2015-08-27 23:52:01

enihcam
Member
From: Internet
Registered: 2009-12-20
Posts: 222

Re: how to setup sound device priority?

V1del wrote:

Quick solution, use pulseaudio and set hdmi as the fallback device, activate the module-switch-on-connect (before the if..udev-block) in the default.pa.

Long solution, try to do this in ALSA by following this: http://alsa.opensrc.org/Udev but I can't really help you further than this if you choose to go this route


Thanks. Do you have wiki or doc for the quick solution?

Offline

#4 2015-08-28 00:31:48

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: how to setup sound device priority?

I've never ever heard pulse audio considered the quick solution to anything.

Try this, one simple line, done once.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2015-08-28 07:03:36

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,076

Re: how to setup sound device priority?

Unless I sorely misinterpreted his post he wants dynamic switching on HDMI connect which the one liner is not gonna give you

You could technically do it a similar way by creating a .asoundrc with the following contents:

defaults.pcm.card 0
defaults.pcm.device 3
defaults.ctl.card 0

and running

systemctl restart alsa-restore

and restarting all your applications. Which would be a plain ALSA solution. Then writing a script triggered on Udev events to switch out the files and call systemctl at which point we are at the solution I gave the link for (which comes from the Archwiki although I have a faint memory of there being a simpler udev-based solution mentioned there, which I didn't find).

Edit: in retrospect the link seems overly convoluted, If you want to do this the ALSA way check https://wiki.archlinux.org/index.php/Udev find out what triggers get called on HDMI plug-in and write a script that swaps out the asoundrc would probably be sufficient (real hotplugging, with keeping the existing streams alive without restart, is still not possible then afaik)

@enihcam Install pulseaudio, pavucontrol and pulseaudio-alsa (lib32-libpulse and lib32-alsa-plugins to have working 32bit programs). Add the load-module module-switch-on-connect at the position I've mentioned. Start to play some sound they should switch when you connect your HDMI. Optionally set the HDMI as  the fallback device in pavucontrol so that streams default to it when HDMI is connected

Additional reading http://www.freedesktop.org/wiki/Softwar … r/Modules/

Last edited by V1del (2015-08-28 09:01:41)

Offline

#6 2015-08-28 11:24:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: how to setup sound device priority?

V1del wrote:

Unless I sorely misinterpreted his post

D'Oh.  No, it was me who did that.  Sorry.

Something more dynamic could certainly be done with alsa which I would shoot for if I needed this, but this is the sort of thing where pulse audio could become more practical.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB