You are not logged in.

#1 2021-02-17 02:08:17

atomicpookavirus
Member
Registered: 2009-06-28
Posts: 53

PulseAudio: Enable 2 output ports by default [solved]

My soundcard has the internal speaker as one of it's output ports. I like to use it alongside my 2.1 speakers for treble.

Unmuting both channels in alsamixer works fine - I get sound out of my lineout and internal speaker, I can adjust their levels independently - great.
   Unfortunately, everytime PA starts, it mutes the internal "Speaker" channel and sets the volume to zero.

I am able to unmute the speaker port using pactl -

pactl set-sink-port 0 analog-output-speaker

I could run that code on startup but then I'd still need to readjust the volume manually. Perhaps their is a code for volume too - that would be a sort of solution.

  Rather than run a script, I want to find the right place to configure my PA settings.
I have created ~/.config/pulse but I'm not clear what to do from here.

Looks like I got some autogenerated files -

$ ls ~/.config/pulse/
4e37b4c3b6444003b93a3fbe36ddf702-card-database.tdb  4e37b4c3b6444003b93a3fbe36ddf702-default-source      4e37b4c3b6444003b93a3fbe36ddf702-stream-volumes.tdb
4e37b4c3b6444003b93a3fbe36ddf702-default-sink       4e37b4c3b6444003b93a3fbe36ddf702-device-volumes.tdb  cookie

I tried a few diagnostic tests -

$ systemctl --user stop pulseaudio.service pulseaudio.socket
$ pulseaudio -vv --log-time 2> /tmp/pulse.log
$ cat /tmp/pulse.log | grep analog-output-speaker
(   0.230|   0.000) D: [pulseaudio] conf-parser.c: Parsing configuration file '/usr/share/pulseaudio/alsa-mixer/paths/analog-output-speaker.conf'
(   0.232|   0.000) D: [pulseaudio] alsa-mixer.c: Probing path 'analog-output-speaker'
(   0.234|   0.000) D: [pulseaudio] alsa-mixer.c: Path analog-output-speaker (Speakers), direction=1, priority=100, probed=yes, supported=yes, has_mute=yes, has_volume=yes, has_dB=yes, min_volume=0, max_volume=31, min_dB=-144, max_dB=0
(   0.256|   0.000) D: [pulseaudio] module-alsa-card.c: Pruned singleton availability group Legacy 5 from port analog-output-speaker
(   0.256|   0.000) D: [pulseaudio] device-port.c: Setting port analog-output-speaker to status no
$ pacmd list-sinks
1 sink(s) available.
  * index: 4
	name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: IDLE
	suspend cause: (none)
	priority: 9039
	volume: front-left: 43111 /  66% / -10.91 dB,   front-right: 43111 /  66% / -10.91 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 36.51 ms
	max request: 7 KiB
	max rewind: 7 KiB
	monitor source: 7
	sample spec: s16le 2ch 48000Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 1
	configured latency: 40.00 ms; range is 0.50 .. 1837.50 ms
	card: 0 <alsa_card.pci-0000_00_1b.0>
	module: 6
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "ALC262 Analog"
		alsa.id = "ALC262 Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "HDA Intel"
		alsa.long_card_name = "HDA Intel at 0xe0500000 irq 30"
		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 = "27d8"
		device.product.name = "NM10/ICH7 Family High Definition Audio Controller"
		device.form_factor = "internal"
		device.string = "front:0"
		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 = "Built-in Audio Analog Stereo"
		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-speaker: Speakers (priority 10000, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-speakers"
		analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-headphones"
	active port: <analog-output-speaker>
$ pacmd list-cards
1 card(s) available.
    index: 0
	name: <alsa_card.pci-0000_00_1b.0>
	driver: <module-alsa-card.c>
	owner module: 6
	properties:
		alsa.card = "0"
		alsa.card_name = "HDA Intel"
		alsa.long_card_name = "HDA Intel at 0xe0500000 irq 30"
		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 = "27d8"
		device.product.name = "NM10/ICH7 Family High Definition Audio Controller"
		device.form_factor = "internal"
		device.string = "0"
		device.description = "Built-in Audio"
		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)
		off: Off (priority 0, available: unknown)
	active profile: <output:analog-stereo>
	sinks:
		alsa_output.pci-0000_00_1b.0.analog-stereo/#4: Built-in Audio Analog Stereo
	sources:
		alsa_output.pci-0000_00_1b.0.analog-stereo.monitor/#7: Monitor of Built-in Audio 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-speaker: Speakers (priority 10000, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-speakers"
		analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-headphones"

Last edited by atomicpookavirus (2021-02-19 00:19:40)

Offline

#2 2021-02-17 09:11:39

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

Re: PulseAudio: Enable 2 output ports by default [solved]

You can define additional commands the pulse server should execute during startup in /etc/pulse/default.pa (... or the user local variant ~/.config/pulse/default.pa) if you do a user config you need to include the system file so that the initial modules are loaded regardless, syntax of that file is the same as for pacmd/pactl just without the leading pacmd e.g.  your ~/.config/pulse/default.pa would look like

.include /etc/pulse/default.pa
set-sink-port alsa_output.pci-0000_00_1b.0.analog-stereo analog-output-speaker
#Afaik you need to use the integer values here, so that would reflect the 66% you've set in the outputs above
set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo 43111

That's probably the simplest way of doing it,  more "proper" would be to create some adjusted profile definitions for the usecase in /usr/share/pulseaudio/alsa-mixers but that can be a bit of a hassle for something that is fixable with a simple redefinition logic during startup.

Offline

#3 2021-02-17 20:53:32

atomicpookavirus
Member
Registered: 2009-06-28
Posts: 53

Re: PulseAudio: Enable 2 output ports by default [solved]

Thanks for the tip V1del!

That default.pa snippet works to activate the "speaker" port but the set-sink-volume command simply controls the master volume for the "analog-stereo" sink.

PA's default analog-stereo sink wants to control all the channels together.

I think I'm starting to see the shape of my problem. I might be the only person in the history of ever to want a 3.1 system with left+right+mono.

Looks like I need to dig into the configs at /usr/share/pulseaudio/alsa-mixer/profile-sets and ../paths
and perhaps do something with daemon.conf
...
I'm starting with reading the free desktop docs

Offline

#4 2021-02-17 22:22:27

atomicpookavirus
Member
Registered: 2009-06-28
Posts: 53

Re: PulseAudio: Enable 2 output ports by default [solved]

Apparently the 3 channel system is already a thing in headset world.
Form from ../paths/usb-gaming-headset-output-stereo.conf

; USB gaming headset mono output path. These headsets usually have two
; output devices. The first one is mono, meant for voice audio, and the second
; one is stereo, meant for everything else. The purpose of this unusual design
; is to provide separate volume controls for voice and other audio, which can
; be useful in gaming.

Offline

#5 2021-02-19 00:18:57

atomicpookavirus
Member
Registered: 2009-06-28
Posts: 53

Re: PulseAudio: Enable 2 output ports by default [solved]

I ended up editing /usr/share/pulseaudio/alsa-mixer/paths/
analog-outptut-lineout.conf
Changed

[Element Speaker]
switch = off
volume = off

to

[Element Speaker]
switch = mute
volume = ignore 

Now I have the desired behavior of setting my levels in alsamixer and letting pulse control them via the master and pcm elements. Voices on crummy youtube audio sound way better now.

Offline

#6 2021-02-19 00:21:53

atomicpookavirus
Member
Registered: 2009-06-28
Posts: 53

Re: PulseAudio: Enable 2 output ports by default [solved]

I had a bit of fun playing with max and merged volume settings so that the pcskr would come on first, then the 2.1 would come in at higher volumes.

Offline

Board footer

Powered by FluxBB