Automatic Selection of Audio Output Devices

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Thaigolu

Automatic Selection of Audio Output Devices

Post by Thaigolu »

Hello everyone!

I'm running Linux Mint 16 64-bit Cinnamon on a Samsung R510 laptop.
I use different audio output devices. When switching between them I often have to make manual adjustments. E.g. the output device won't be selected automatically and I don't hear anything until having it selected manually from the sound settings. Or I can hear sound from the output device but the volume control on my keyboard wouldn't have any effect on it (I then have to "officially" select it as output device to make the volume control effective).

My priority from low to high would be:
Onboard speakers < Bluetooth speaker (Bose SoundLink Mini) < HDMI Out < Headphones

Is there any possibility to achieve the following?
- The connected device with the highest priority will be recognized and selected automatically. All connected devices with lower priority will be ignored.
- The volume control of the keyboard will automatically work for the connected device with highest priority.

Thanks in advance for any help! :)
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Kalyk
Level 5
Level 5
Posts: 769
Joined: Wed Mar 12, 2014 5:29 pm
Location: The Netherlands

Re: Automatic Selection of Audio Output Devices

Post by Kalyk »

Hello and welcome to this forum!!

Did some searching and found a post that might be usefull
https://bbs.archlinux.org/viewtopic.php?id=164868
Don't know if is what you are looking for but hope it helps.
Add (Solved) to the topic-title of the first post when appropriate so others know they might find a solution here.
Thaigolu

Re: Automatic Selection of Audio Output Devices

Post by Thaigolu »

Hey, thanks for your answer! I guess the solutions in your link is the right approach but I'm pretty new to Linux in general so I'm not sure what to do. I understand that I have to somehow edit "/etc/pulse/default.pa" based on the output of the command "$ pacmd list-cards".

The output is:

Code: Select all

Welcome to PulseAudio! Use "help" for usage information.
>>> 2 card(s) available.
    index: 0
	name: <alsa_card.pci-0000_00_1b.0>
	driver: <module-alsa-card.c>
	owner module: 4
	properties:
		alsa.card = "0"
		alsa.card_name = "HDA Intel"
		alsa.long_card_name = "HDA Intel at 0xf6200000 irq 46"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1b.0"
		sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "293e"
		device.product.name = "82801I (ICH9 Family) HD Audio Controller"
		device.form_factor = "internal"
		device.string = "0"
		device.description = "Internes Audio"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	profiles:
		input:analog-stereo: Analog Stereo Eingang (priority 60, available: unknown)
		output:analog-stereo: Analog Stereo Ausgang (priority 6000, available: unknown)
		output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority 6060, available: unknown)
		output:hdmi-stereo: Digital Stereo (HDMI) Ausgang (priority 5400, available: unknown)
		output:hdmi-stereo+input:analog-stereo: Digital Stereo (HDMI) Ausgang + Analog Stereo Eingang (priority 5460, available: unknown)
		off: Aus (priority 0, available: unknown)
	active profile: <output:hdmi-stereo+input:analog-stereo>
	sinks:
		alsa_output.pci-0000_00_1b.0.hdmi-stereo/#0: Internes Audio Digital Stereo (HDMI)
	sources:
		alsa_output.pci-0000_00_1b.0.hdmi-stereo.monitor/#0: Monitor of Internes Audio Digital Stereo (HDMI)
		alsa_input.pci-0000_00_1b.0.analog-stereo/#1: Internes Audio Analog Stereo
	ports:
		analog-input-microphone-internal: Internes Mikrofon (priority 8900, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-input-microphone"
		analog-input-microphone: Mikrofon (priority 8700, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-input-microphone"
		analog-output-speaker: Lautsprecher (priority 10000, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-speakers"
		analog-output-headphones: Analoge Kopfhörer (priority 9000, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-headphones"
		hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "video-display"
    index: 1
	name: <bluez_card.00_0C_8A_8F_35_53>
	driver: <module-bluetooth-device.c>
	owner module: 23
	properties:
		device.description = "Bose Mini SoundLink"
		device.string = "00:0C:8A:8F:35:53"
		device.api = "bluez"
		device.class = "sound"
		device.bus = "bluetooth"
		device.form_factor = "hifi"
		bluez.path = "/org/bluez/712/hci0/dev_00_0C_8A_8F_35_53"
		bluez.class = "0x240428"
		bluez.name = "Bose Mini SoundLink"
		device.icon_name = "audio-card-bluetooth"
	profiles:
		a2dp: High Fidelity Playback (A2DP) (priority 10, available: unknown)
		off: Aus (priority 0, available: yes)
	active profile: <a2dp>
	sinks:
		bluez_sink.00_0C_8A_8F_35_53/#1: Bose Mini SoundLink
	sources:
		bluez_sink.00_0C_8A_8F_35_53.monitor/#2: Monitor of Bose Mini SoundLink
	ports:
		hifi-output: HiFi (priority 0, latency offset 0 usec, available: unknown)
			properties:
				
		hifi-input: HiFi (priority 0, latency offset 0 usec, available: no)
			properties:
How do I have to edit the Pulse file in order to get what I described in the opening post? Again, thanks in advance!


Edit: I just had a look at the "$ pacmd list-cards" output again and noticed that there already are priorities. The (I think) interesting ones for me are:

Code: Select all

output:analog-stereo: Analog Stereo Ausgang ([b]priority 6000[/b], available: unknown)

Code: Select all

output:hdmi-stereo: Digital Stereo (HDMI) Ausgang ([b]priority 5400[/b], available: unknown)

Code: Select all

analog-output-headphones: Analoge Kopfhörer ([b]priority 9000[/b], latency offset 0 usec, available: no)

Code: Select all

hifi-output: HiFi ([b]priority 0[/b], latency offset 0 usec, available: unknown)
Does anyone know how to changes these priorities and if changing them would have the impact I am looking for?
Thaigolu

Re: Automatic Selection of Audio Output Devices

Post by Thaigolu »

Does noone have an idea? I absolutely don't mean to be rude but I figure I cannot be the only one who uses multiple audio output devices and connects his/her computer to his/her TV sometimes!?
Kalyk
Level 5
Level 5
Posts: 769
Joined: Wed Mar 12, 2014 5:29 pm
Location: The Netherlands

Re: Automatic Selection of Audio Output Devices

Post by Kalyk »

When searching I see two programs which might be interesting, but I can't install and test them here.
padevchooser: should give a fast systemtray-program to choose the right output;
paprefs: don't know which prefs can be set, but might be just what you need.
Both should be available from the softwaremanager.
And perhaps there is some more pa*-stuff available there.
Add (Solved) to the topic-title of the first post when appropriate so others know they might find a solution here.
Thaigolu

Re: Automatic Selection of Audio Output Devices

Post by Thaigolu »

Thanks, that sounded good. However, I couldn't find any suitable settings in either of these programs. It seems like they are mostly about network devices.
Thaigolu

Re: Automatic Selection of Audio Output Devices

Post by Thaigolu »

OK, apparently there is no (easy) solution for my problem. However, is it at least possible to automatically select my bluetooth speaker as soon as it connects? At the moment, it is used as actual output device as soon as it connects but isn't automatically selected as such. Thus, the volume control doesn't work and the volume of my bluetooth speaker is always all the way up until I manually select it as output device and lower the volume again.
Thaigolu

Re: Automatic Selection of Audio Output Devices

Post by Thaigolu »

So, I found a udev rule that is supposed to automatically switch between output devices: http://ubuntuforums.org/showthread.php? ... st11655118
Is there any possibility to expand this rule or to complement it with other rules (e.g. one for bluetooth connection and one for headphone connection) so automatic selection will work for all my output devices?
Locked

Return to “Sound”