You are not logged in.

#1 2019-11-06 11:36:14

headphonechannel
Member
Registered: 2019-11-06
Posts: 5

How to change audio output on the fly?

I'm using ALSA. I have simple PC sprekers set to my PC's audio jack. Today I bought new headphone that are connected with USB, they worked just fine out of the box. But I don't want to always get up and remove the headphones in order to use the speakers. So when I plug the headphones in, they 'capture' the sound output and I can't get it back to speakers unless I unplug them. Does ALSA have some command that I could switch the audio output? I was searching and found amixer -c and I tried to switch the card but it didn't help. If I open alsamixer I can see the headphones listed as a card.

Offline

#2 2019-11-06 12:17:08

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,427

Re: How to change audio output on the fly?

Install and use pulseaudio. This requirement is one of the main reasons pulseaudio exists.

Though the rest of your description does sound like you are already using pulse, since no automatic switching should happen from USB to built-in and vice versa on a plain ALSA setup. Can you post

aplay -lL
amixer -c0
pacmd list-cards
pacmd list-sinks
pacmd list-sink-inputs

Last edited by V1del (2019-11-06 12:21:43)

Offline

#3 2019-11-06 13:09:06

headphonechannel
Member
Registered: 2019-11-06
Posts: 5

Re: How to change audio output on the fly?

V1del wrote:

Install and use pulseaudio. This requirement is one of the main reasons pulseaudio exists.

Though the rest of your description does sound like you are already using pulse, since no automatic switching should happen from USB to built-in and vice versa on a plain ALSA setup. Can you post

aplay -lL
amixer -c0
pacmd list-cards
pacmd list-sinks
pacmd list-sink-inputs

You were right, I actually have pulseaudio. I swear I have not installed it haha.

aplay -lL

null
    Discard all samples (playback) or generate zero samples (capture)
jack
    JACK Audio Connection Kit
pulse
    PulseAudio Sound Server
default
    Default ALSA Output (currently PulseAudio Sound Server)
hdmi:CARD=Generic,DEV=0
    HD-Audio Generic, HDMI 0
    HDMI Audio Output
hdmi:CARD=Generic,DEV=1
    HD-Audio Generic, HDMI 1
    HDMI Audio Output
hdmi:CARD=Generic,DEV=2
    HD-Audio Generic, HDMI 2
    HDMI Audio Output
hdmi:CARD=Generic,DEV=3
    HD-Audio Generic, HDMI 3
    HDMI Audio Output
hdmi:CARD=Generic,DEV=4
    HD-Audio Generic, HDMI 4
    HDMI Audio Output
hdmi:CARD=Generic,DEV=5
    HD-Audio Generic, HDMI 5
    HDMI Audio Output
usbstream:CARD=Generic
    HD-Audio Generic
    USB Stream Output
sysdefault:CARD=Generic_1
    HD-Audio Generic, Generic Analog
    Default Audio Device
front:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    Front speakers
surround21:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Digital
    IEC958 (S/PDIF) Digital Audio Output
usbstream:CARD=Generic_1
    HD-Audio Generic
    USB Stream Output
sysdefault:CARD=X
    PRO X, USB Audio
    Default Audio Device
front:CARD=X,DEV=0
    PRO X, USB Audio
    Front speakers
surround21:CARD=X,DEV=0
    PRO X, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=X,DEV=0
    PRO X, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=X,DEV=0
    PRO X, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=X,DEV=0
    PRO X, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=X,DEV=0
    PRO X, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=X,DEV=0
    PRO X, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=X,DEV=0
    PRO X, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
usbstream:CARD=X
    PRO X
    USB Stream Output
**** List of PLAYBACK Hardware Devices ****
card 0: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 11: HDMI 5 [HDMI 5]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 0: Generic Analog [Generic Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 1: Generic Digital [Generic Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: X [PRO X], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

amixer -c0

null
    Discard all samples (playback) or generate zero samples (capture)
jack
    JACK Audio Connection Kit
pulse
    PulseAudio Sound Server
default
    Default ALSA Output (currently PulseAudio Sound Server)
hdmi:CARD=Generic,DEV=0
    HD-Audio Generic, HDMI 0
    HDMI Audio Output
hdmi:CARD=Generic,DEV=1
    HD-Audio Generic, HDMI 1
    HDMI Audio Output
hdmi:CARD=Generic,DEV=2
    HD-Audio Generic, HDMI 2
    HDMI Audio Output
hdmi:CARD=Generic,DEV=3
    HD-Audio Generic, HDMI 3
    HDMI Audio Output
hdmi:CARD=Generic,DEV=4
    HD-Audio Generic, HDMI 4
    HDMI Audio Output
hdmi:CARD=Generic,DEV=5
    HD-Audio Generic, HDMI 5
    HDMI Audio Output
usbstream:CARD=Generic
    HD-Audio Generic
    USB Stream Output
sysdefault:CARD=Generic_1
    HD-Audio Generic, Generic Analog
    Default Audio Device
front:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    Front speakers
surround21:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Generic_1,DEV=0
    HD-Audio Generic, Generic Digital
    IEC958 (S/PDIF) Digital Audio Output
usbstream:CARD=Generic_1
    HD-Audio Generic
    USB Stream Output
sysdefault:CARD=X
    PRO X, USB Audio
    Default Audio Device
front:CARD=X,DEV=0
    PRO X, USB Audio
    Front speakers
surround21:CARD=X,DEV=0
    PRO X, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=X,DEV=0
    PRO X, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=X,DEV=0
    PRO X, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=X,DEV=0
    PRO X, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=X,DEV=0
    PRO X, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=X,DEV=0
    PRO X, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=X,DEV=0
    PRO X, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
usbstream:CARD=X
    PRO X
    USB Stream Output
**** List of PLAYBACK Hardware Devices ****
card 0: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 11: HDMI 5 [HDMI 5]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 0: Generic Analog [Generic Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 1: Generic Digital [Generic Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: X [PRO X], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

Last edited by headphonechannel (2019-11-06 13:12:48)

Offline

#4 2019-11-06 13:10:09

headphonechannel
Member
Registered: 2019-11-06
Posts: 5

Re: How to change audio output on the fly?

pacmd list-cards

3 card(s) available.
    index: 0
	name: <alsa_card.pci-0000_0a_00.1>
	driver: <module-alsa-card.c>
	owner module: 6
	properties:
		alsa.card = "0"
		alsa.card_name = "HD-Audio Generic"
		alsa.long_card_name = "HD-Audio Generic at 0xfcba0000 irq 141"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:0a:00.1"
		sysfs.path = "/devices/pci0000:00/0000:00:03.1/0000:08:00.0/0000:09:00.0/0000:0a:00.1/sound/card0"
		device.bus = "pci"
		device.vendor.id = "1002"
		device.vendor.name = "Advanced Micro Devices, Inc. [AMD/ATI]"
		device.product.id = "ab38"
		device.product.name = "Navi 10 HDMI Audio"
		device.string = "0"
		device.description = "Navi 10 HDMI Audio"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	profiles:
		output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 5900, available: no)
		output:hdmi-surround: Digital Surround 5.1 (HDMI) Output (priority 800, available: no)
		output:hdmi-surround71: Digital Surround 7.1 (HDMI) Output (priority 800, available: no)
		output:hdmi-stereo-extra1: Digital Stereo (HDMI 2) Output (priority 5700, available: no)
		output:hdmi-surround-extra1: Digital Surround 5.1 (HDMI 2) Output (priority 600, available: no)
		output:hdmi-surround71-extra1: Digital Surround 7.1 (HDMI 2) Output (priority 600, available: no)
		output:hdmi-stereo-extra2: Digital Stereo (HDMI 3) Output (priority 5700, available: no)
		output:hdmi-surround-extra2: Digital Surround 5.1 (HDMI 3) Output (priority 600, available: no)
		output:hdmi-surround71-extra2: Digital Surround 7.1 (HDMI 3) Output (priority 600, available: no)
		output:hdmi-stereo-extra3: Digital Stereo (HDMI 4) Output (priority 5700, available: no)
		output:hdmi-surround-extra3: Digital Surround 5.1 (HDMI 4) Output (priority 600, available: no)
		output:hdmi-surround71-extra3: Digital Surround 7.1 (HDMI 4) Output (priority 600, available: no)
		output:hdmi-stereo-extra4: Digital Stereo (HDMI 5) Output (priority 5700, available: unknown)
		output:hdmi-stereo-extra5: Digital Stereo (HDMI 6) Output (priority 5700, available: no)
		output:hdmi-surround-extra5: Digital Surround 5.1 (HDMI 6) Output (priority 600, available: no)
		output:hdmi-surround71-extra5: Digital Surround 7.1 (HDMI 6) Output (priority 600, available: no)
		off: Off (priority 0, available: unknown)
	active profile: <output:hdmi-stereo-extra4>
	sinks:
		alsa_output.pci-0000_0a_00.1.hdmi-stereo-extra4/#5: Navi 10 HDMI Audio Digital Stereo (HDMI 5)
	sources:
		alsa_output.pci-0000_0a_00.1.hdmi-stereo-extra4.monitor/#6: Monitor of Navi 10 HDMI Audio Digital Stereo (HDMI 5)
	ports:
		hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "video-display"
		hdmi-output-1: HDMI / DisplayPort 2 (priority 5800, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "video-display"
		hdmi-output-2: HDMI / DisplayPort 3 (priority 5700, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "video-display"
		hdmi-output-3: HDMI / DisplayPort 4 (priority 5600, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "video-display"
		hdmi-output-4: HDMI / DisplayPort 5 (priority 5500, latency offset 0 usec, available: yes)
			properties:
				device.icon_name = "video-display"
				device.product.name = "C49RG9x"
		hdmi-output-5: HDMI / DisplayPort 6 (priority 5400, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "video-display"
    index: 1
	name: <alsa_card.pci-0000_0c_00.4>
	driver: <module-alsa-card.c>
	owner module: 7
	properties:
		alsa.card = "1"
		alsa.card_name = "HD-Audio Generic"
		alsa.long_card_name = "HD-Audio Generic at 0xfca00000 irq 143"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:0c:00.4"
		sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:0c:00.4/sound/card1"
		device.bus = "pci"
		device.vendor.id = "1022"
		device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
		device.product.id = "1487"
		device.product.name = "Starship/Matisse HD Audio Controller"
		device.string = "1"
		device.description = "Starship/Matisse HD Audio Controller"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	profiles:
		input:analog-stereo: Analog Stereo Input (priority 65, available: no)
		output:analog-stereo: Analog Stereo Output (priority 6500, available: unknown)
		output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority 6565, available: no)
		output:analog-surround-21: Analog Surround 2.1 Output (priority 1300, available: unknown)
		output:analog-surround-21+input:analog-stereo: Analog Surround 2.1 Output + Analog Stereo Input (priority 1365, available: no)
		output:analog-surround-40: Analog Surround 4.0 Output (priority 1200, available: unknown)
		output:analog-surround-40+input:analog-stereo: Analog Surround 4.0 Output + Analog Stereo Input (priority 1265, available: no)
		output:analog-surround-41: Analog Surround 4.1 Output (priority 1300, available: unknown)
		output:analog-surround-41+input:analog-stereo: Analog Surround 4.1 Output + Analog Stereo Input (priority 1365, available: no)
		output:analog-surround-50: Analog Surround 5.0 Output (priority 1200, available: unknown)
		output:analog-surround-50+input:analog-stereo: Analog Surround 5.0 Output + Analog Stereo Input (priority 1265, available: no)
		output:analog-surround-51: Analog Surround 5.1 Output (priority 1300, available: unknown)
		output:analog-surround-51+input:analog-stereo: Analog Surround 5.1 Output + Analog Stereo Input (priority 1365, available: no)
		output:iec958-stereo: Digital Stereo (IEC958) Output (priority 5500, available: unknown)
		output:iec958-stereo+input:analog-stereo: Digital Stereo (IEC958) Output + Analog Stereo Input (priority 5565, available: no)
		off: Off (priority 0, available: unknown)
	active profile: <output:analog-stereo>
	sinks:
		alsa_output.pci-0000_0c_00.4.analog-stereo/#1: Starship/Matisse HD Audio Controller Analog Stereo
	sources:
		alsa_output.pci-0000_0c_00.4.analog-stereo.monitor/#1: Monitor of Starship/Matisse HD Audio Controller Analog Stereo
	ports:
		analog-input-front-mic: Front Microphone (priority 8500, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-input-microphone"
		analog-input-rear-mic: Rear Microphone (priority 8200, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-input-microphone"
		analog-input-linein: Line In (priority 8100, latency offset 0 usec, available: no)
			properties:
				
		analog-output-lineout: Line Out (priority 9000, latency offset 0 usec, available: yes)
			properties:
				
		analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-headphones"
		iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
			properties:
				
    index: 2
	name: <alsa_card.usb-Logitech_PRO_X_000000000000-00>
	driver: <module-alsa-card.c>
	owner module: 22
	properties:
		alsa.card = "2"
		alsa.card_name = "PRO X"
		alsa.long_card_name = "Logitech PRO X at usb-0000:05:00.1-3.2, full speed"
		alsa.driver_name = "snd_usb_audio"
		device.bus_path = "pci-0000:05:00.1-usb-0:3.2:1.0"
		sysfs.path = "/devices/pci0000:00/0000:00:01.2/0000:02:00.0/0000:03:08.0/0000:05:00.1/usb1/1-3/1-3.2/1-3.2:1.0/sound/card2"
		udev.id = "usb-Logitech_PRO_X_000000000000-00"
		device.bus = "usb"
		device.vendor.id = "046d"
		device.vendor.name = "Logitech, Inc."
		device.product.id = "0aaa"
		device.product.name = "PRO X"
		device.serial = "Logitech_PRO_X_000000000000"
		device.string = "2"
		device.description = "PRO X"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-usb"
	profiles:
		input:mono-fallback: Mono Input (priority 1, available: unknown)
		input:multichannel-input: Multichannel Input (priority 1, available: unknown)
		output:analog-stereo: Analog Stereo Output (priority 6500, available: unknown)
		output:analog-stereo+input:mono-fallback: Analog Stereo Output + Mono Input (priority 6501, available: unknown)
		output:analog-stereo+input:multichannel-input: Analog Stereo Output + Multichannel Input (priority 6501, available: unknown)
		output:iec958-stereo: Digital Stereo (IEC958) Output (priority 5500, available: unknown)
		output:iec958-stereo+input:mono-fallback: Digital Stereo (IEC958) Output + Mono Input (priority 5501, available: unknown)
		output:iec958-stereo+input:multichannel-input: Digital Stereo (IEC958) Output + Multichannel Input (priority 5501, available: unknown)
		off: Off (priority 0, available: unknown)
	active profile: <output:analog-stereo+input:mono-fallback>
	sinks:
		alsa_output.usb-Logitech_PRO_X_000000000000-00.analog-stereo/#2: PRO X Analog Stereo
	sources:
		alsa_output.usb-Logitech_PRO_X_000000000000-00.analog-stereo.monitor/#2: Monitor of PRO X Analog Stereo
		alsa_input.usb-Logitech_PRO_X_000000000000-00.mono-fallback/#3: PRO X Mono
	ports:
		analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-input-microphone"
		multichannel-input: Multichannel Input (priority 0, latency offset 0 usec, available: unknown)
			properties:
				
		analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
			properties:
				
		iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
			properties:
				

Last edited by headphonechannel (2019-11-06 13:10:48)

Offline

#5 2019-11-06 13:11:56

headphonechannel
Member
Registered: 2019-11-06
Posts: 5

Re: How to change audio output on the fly?

pacmd list-sinks

3 sink(s) available.
    index: 1
	name: <alsa_output.pci-0000_0c_00.4.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
	state: SUSPENDED
	suspend cause: IDLE
	priority: 9039
	volume: front-left: 33439 /  51% / -17.53 dB,   front-right: 33439 /  51% / -17.53 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 1
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	fixed latency: 100.14 ms
	card: 1 <alsa_card.pci-0000_0c_00.4>
	module: 7
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "Generic Analog"
		alsa.id = "Generic Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "1"
		alsa.card_name = "HD-Audio Generic"
		alsa.long_card_name = "HD-Audio Generic at 0xfca00000 irq 143"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:0c:00.4"
		sysfs.path = "/devices/pci0000:00/0000:00:08.1/0000:0c:00.4/sound/card1"
		device.bus = "pci"
		device.vendor.id = "1022"
		device.vendor.name = "Advanced Micro Devices, Inc. [AMD]"
		device.product.id = "1487"
		device.product.name = "Starship/Matisse HD Audio Controller"
		device.string = "front:1"
		device.buffering.buffer_size = "17664"
		device.buffering.fragment_size = "2944"
		device.access_mode = "mmap"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "Starship/Matisse HD Audio Controller Analog Stereo"
		alsa.mixer_name = "Realtek Generic"
		alsa.components = "HDA:10ec0b00,1458a0cf,00100001"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		analog-output-lineout: Line Out (priority 9000, latency offset 0 usec, available: yes)
			properties:
				
		analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-headphones"
	active port: <analog-output-lineout>
  * index: 2
	name: <alsa_output.usb-Logitech_PRO_X_000000000000-00.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: RUNNING
	suspend cause: (none)
	priority: 9049
	volume: front-left: 37998 /  58% / -14.20 dB,   front-right: 37998 /  58% / -14.20 dB
	        balance 0.00
	base volume: 54094 /  83% / -5.00 dB
	volume steps: 65537
	muted: no
	current latency: 80.58 ms
	max request: 14 KiB
	max rewind: 14 KiB
	monitor source: 2
	sample spec: s16le 2ch 48000Hz
	channel map: front-left,front-right
	             Stereo
	used by: 1
	linked by: 1
	configured latency: 75.00 ms; range is 0.50 .. 1837.50 ms
	card: 2 <alsa_card.usb-Logitech_PRO_X_000000000000-00>
	module: 22
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "USB Audio"
		alsa.id = "USB Audio"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "2"
		alsa.card_name = "PRO X"
		alsa.long_card_name = "Logitech PRO X at usb-0000:05:00.1-3.2, full speed"
		alsa.driver_name = "snd_usb_audio"
		device.bus_path = "pci-0000:05:00.1-usb-0:3.2:1.0"
		sysfs.path = "/devices/pci0000:00/0000:00:01.2/0000:02:00.0/0000:03:08.0/0000:05:00.1/usb1/1-3/1-3.2/1-3.2:1.0/sound/card2"
		udev.id = "usb-Logitech_PRO_X_000000000000-00"
		device.bus = "usb"
		device.vendor.id = "046d"
		device.vendor.name = "Logitech, Inc."
		device.product.id = "0aaa"
		device.product.name = "PRO X"
		device.serial = "Logitech_PRO_X_000000000000"
		device.string = "front:2"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "PRO X Analog Stereo"
		alsa.mixer_name = "USB Mixer"
		alsa.components = "USB046d:0aaa"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-usb"
	ports:
		analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
			properties:
				
	active port: <analog-output>
    index: 5
	name: <alsa_output.pci-0000_0a_00.1.hdmi-stereo-extra4>
	driver: <module-alsa-card.c>
	flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: SUSPENDED
	suspend cause: IDLE
	priority: 9030
	volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 6
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	configured latency: 0.00 ms; range is 0.50 .. 1999.82 ms
	card: 0 <alsa_card.pci-0000_0a_00.1>
	module: 6
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "HDMI 4"
		alsa.id = "HDMI 4"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "10"
		alsa.card = "0"
		alsa.card_name = "HD-Audio Generic"
		alsa.long_card_name = "HD-Audio Generic at 0xfcba0000 irq 141"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:0a:00.1"
		sysfs.path = "/devices/pci0000:00/0000:00:03.1/0000:08:00.0/0000:09:00.0/0000:0a:00.1/sound/card0"
		device.bus = "pci"
		device.vendor.id = "1002"
		device.vendor.name = "Advanced Micro Devices, Inc. [AMD/ATI]"
		device.product.id = "ab38"
		device.product.name = "Navi 10 HDMI Audio"
		device.string = "hdmi:0,4"
		device.buffering.buffer_size = "352768"
		device.buffering.fragment_size = "176384"
		device.access_mode = "mmap+timer"
		device.profile.name = "hdmi-stereo-extra4"
		device.profile.description = "Digital Stereo (HDMI 5)"
		device.description = "Navi 10 HDMI Audio Digital Stereo (HDMI 5)"
		alsa.mixer_name = "ATI R6xx HDMI"
		alsa.components = "HDA:1002aa01,00aa0100,00100700"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		hdmi-output-4: HDMI / DisplayPort 5 (priority 5500, latency offset 0 usec, available: yes)
			properties:
				device.icon_name = "video-display"
				device.product.name = "C49RG9x"
	active port: <hdmi-output-4>

pacmd list-sink-inputs

0 sink input(s) available.

Offline

#6 2019-11-06 13:23:24

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,427

Re: How to change audio output on the fly?

Please all of them into a single post in the future. That last one is most interesting during actual playback.

What you can do here depends on what you want, for ease of use I suggest you install at least pavucontrol that provides you with quie an intuitive way to do what you want. To prevent autoswitching from happening you will want to comment/remove

load-module module-switch-on-connect
....
load-module switch-on-port-available

in your /etc/pulse/default.pa however at least the first of these two should not be enabled by default and it will be responsible for the kind of switching you are seeing. Is this actually an Arch install?

Another thing that could implicitly enable this would be a relevant audio mixer of your environment, nearly all of the GUI mixers of the big DEs will have a checkbox to set and unset loading of the previously mentioned module.

Last edited by V1del (2019-11-06 13:23:47)

Offline

#7 2019-11-06 13:32:03

headphonechannel
Member
Registered: 2019-11-06
Posts: 5

Re: How to change audio output on the fly?

V1del wrote:

Please all of them into a single post in the future. That last one is most interesting during actual playback.

What you can do here depends on what you want, for ease of use I suggest you install at least pavucontrol that provides you with quie an intuitive way to do what you want. To prevent autoswitching from happening you will want to comment/remove

load-module module-switch-on-connect
....
load-module switch-on-port-available

in your /etc/pulse/default.pa however at least the first of these two should not be enabled by default and it will be responsible for the kind of switching you are seeing. Is this actually an Arch install?

Another thing that could implicitly enable this would be a relevant audio mixer of your environment, nearly all of the GUI mixers of the big DEs will have a checkbox to set and unset loading of the previously mentioned module.

I tried, but when I pressed preview or submit, the editor just got cleared. When I tried to split it to smaller pieces then the preview and submit worked so I thought that there is a length limit.

Thank you for the help. I'll try pavucontrol.
Yes, this is vanilla Arch install and I haven't messed with any audio settings before. I honestly don't even remember that I have installed pulseaudio, I'll check in the evening how it got to my system. Of course it's possible that I did install it but just can't remember. I don't use DE so I would prefer to have some command so I can do a keybinding to switch the output easily from headphones to speakers.

Offline

#8 2019-11-06 16:07:44

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,427

Re: How to change audio output on the fly?

For a terminal method

pacmd move-sink-input $sink-index alsa_output.usb-Logitech_PRO_X_000000000000-00.analog-stereo #Move to headset, to move to internal card replace that last part with alsa_output.pci-0000_0c_00.4.analog-stereo

You can find the sink index for your actual streams with the aforementioned sink-input command or in a bit more terse format with

pactl list sink-inputs short

You might also want to look at the following script: https://www.freedesktop.org/wiki/Softwa … #index40h3 to move all your streams in one go.

There are also a few command line pulse mixers that might have some more extensive features.

Offline

Board footer

Powered by FluxBB