You are not logged in.

#1 2017-10-01 15:07:39

dominicm
Member
Registered: 2015-01-03
Posts: 92

Pulseaudio simultaneous output from command line

I am trying to configure simultaneous audio output from analog audio and front/headphone audio jacks but hit an information wall.

I did add the user to audio group and did stop the only other app running (kodi-standalone). This is a headless server except for kodi-standalon and the relevant X dependencies. I have pulseaudio, pulseaudio-libs and pulseaudio-utils packages installed.

I have read through the wiki, man pages and looked at probably 100 other pages at this point with no clear explanation of certain configuration aspects.

I have gotten as far as having simultaneous hdmi and analog ouput with the following config in /etc/pulse/default.pa:

### Load analog device
load-module module-alsa-sink device=hw:0
load-module module-combine-sink sink_name=combined
set-default-sink combined

What I do not understand is the "device=" syntax. From trial and error the only values that worked were "hw:0" and "hdmi". All other values resulted in failure with error complaining about permission denied to the PCM (same with or without audio group). I am also not seeing a device with "combined" in the name but rather "Simultaneous output to ....devices.....", why doesnt sink_name actually define the name of the device?

What are the correct possible ways to define devices? Where do these values come from? I can't see from either "aplay -l" or "pacmd list-sinks  | grep -e 'name:'  -e 'alsa.device ' -e 'alsa.subdevice '/" where does "hdmi" or "hw:0" comes from... There is no device names "hdmi" and depending on what value you look at the number for the hdmi deice could be 0, 1 or 3. If it's just the first device then why doesnt any other number work (there are 2 devices, hdmi and analog)?

Why does the above config even work? I mean I only defined one device but I get output from both both HDMI and analog. Even in the arch wiki I see 2 devices (device=hw:0,1).

Headphones/front audio is a bit different in that it's one device, is it even possible to config simultneous output on analog and front panel audio in linux? I recall in windows it's a single click toggle so there is no hardware limitation. Having all devices output same audio would be good as well as I can just mute/unplug the ones I dont need without touching linux config every time. Any insights on this issue appreiated.

pacmd list-sinks  | grep -e 'name:'  -e 'alsa.device ' -e 'alsa.subdevice '/:

 name: <alsa_output.hw_1>
                alsa.device = "0"
        name: <combined>
        name: <alsa_output.pci-0000_00_01.1.hdmi-stereo>
                alsa.device = "3"
        name: <alsa_output.pci-0000_00_14.2.analog-stereo>
                alsa.device = "0"

aplay -l:

**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 0: ALC1150 Analog [ALC1150 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 1: ALC1150 Digital [ALC1150 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Offline

#2 2017-10-01 16:13:03

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

Re: Pulseaudio simultaneous output from command line

Remove the load-module module-alsa-sink device=hw:0 again, it isn't needed, neither is adding your user to the audio group, but it shouldn't have an inherently negative effect on a single user system. For your question as to where the other cards come from, way earlier in that default.pa there is

load-module module-udev-detect

this module will automatically add and configure cards as they are detected by udev.  Which is why you get sound out of both., the analog and the hdmi card, they are automatically set up and configured because udev notifies pulse of the cards. 

For the devices part, indeed there are two separate standalone cards: the Analog card:0/hw:0 and the HDMI card:1/hw:1 . Now there are also subdevices of physical cards, best explained on the example of HDMI: Each subdevice corresponds to a seperate physical connector (HDMI or DisplayPort), and they are - in ALSA terms - accessed with hw:1,0 (hw:1,1 or hw:1,3) respectively. Again the pulse logic has some heuristics and manages to autodetect that the correct subdevice to use would be 3, because that's where your monitor is plugged in and will configure it's detected HDMI card to output there.

For the simultaneous output from speakers and frontpanel, this is somewhat dependant on driver support, if you are lucky, checking the relevant card in alsamixer (i.e. alsamixer -Dhw:0 in this case) you might have an "Automute" control, which you can set to disabled. If you don't it would be either a bit more involved to get this working or not easily possible.

As for why your combined sink has another "name" than defined. The name is used for unique identification, not for user visible descriptions. If you really want to set that manually, you can expand your combined sink load with a property, like so

load-module module-combine-sink sink_name=combined sink_properties=device.description="Combined"

Last edited by V1del (2017-10-01 16:13:52)

Offline

#3 2017-10-01 18:40:28

dominicm
Member
Registered: 2015-01-03
Posts: 92

Re: Pulseaudio simultaneous output from command line

The snippet I added to default.pa is the first thing in the file well before udev line. I added the user to audio group as that was the solution in another thread. It's also listed as needed in the kodi standalone wiki among other places, not sure why as you are correct, kodi seems to work just fine. Maybe audio group is needed for alsa only setups? There are also 2 users - kodi (no login user) and command line only admin user if it makes a difference.

The sippet with "load-module module-alsa-sink device=hw:0" is taken from arch wiki, can you elaborte why it's not needed? Is it because "load-module module-combine-sink sink_name=combined" outputs to all devices by default which is what I want and if I wanted only certain devices to output audio I would still need that line?

Regarding subdevices, there is only 1 HDMI output but there is 1 HDMI input (not sure how one would make use of it in linux) so maybe that shows up as a hw subdevice as well. I find "Subdevices: 1/1 Subdevice #0: subdevice #0" very misleading, I would  think 1/1 mean 1 out of 1, meaning there is only 1 device and then theres "card 1" listed 2 times... I am also not seeing a subdevice for front audio, how does that work?

When you say "hw:1,0 (hw:1,1 or hw:1,3)" do you mean that "1,0" = all subdevices while "1,1" and "1,3" specify subdevices individually? If not please explain.

I do actually have auo mute in alsa and after removing the first line I get outputs from all devices! Would still like to know how it all works though. I wonder how SPDIF works in tis case, does it output same audio as well? How would digital passthrough work in this case?

Offline

#4 2017-10-01 19:51:35

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

Re: Pulseaudio simultaneous output from command line

It is not needed because the card detected by udev-detect is already doing the same thing, it's the

alsa_output.pci-0000_00_14.2.analog-stereo

card in your pacmd output (+ the auto-detection adds a few more metadata so that device is easier to identify). Now you just have a redundant pulse sink laying around.   

For the subdevices, ignore the 1/1 and subdevice part for this usecase. the identifier after the comma maps to the relevant device, so in your case hw:1,0 is analog and hw:1,1 is SPDIF.  I only realize now that my hdmi sample was a bit misleading since you indeed do only have one HDMI device, if you compare with mine

card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

These all map to some port on my nvidia card. If we were using plain ALSA we'd have to trial and error to find out which of these maps to the connector, either hw:2,3 hw:2,7 ... each maps to one output.

Front audio does not get a separate device because the DAC on the soundcard doesn't care to which output the audio gets sent to it does the conversion and then pushes the audio either to your rear or front jacks (or well both). SPDIF is afaik on this kind of setup with the different devices on the same card exclusive with the analog output, so you can have either analog or SPDIF output, not both at the same time.

If you want to switch that, you can switch to an SPDIF profile in pavucontrols configuration tab or with

pacmd set-card-profile alsa_output.pci-0000_00_14.2.analog-stereo $cardprofile #pacmd list-cards lists available card profiles

Offline

#5 2017-10-04 09:39:39

dominicm
Member
Registered: 2015-01-03
Posts: 92

Re: Pulseaudio simultaneous output from command line

Thanks a lot for the great info, it's much clearer now. One thing though. If I uderstand correctly udev detects all cards and "load-module module-combine-sink sink_name=combined" line combines the detected devices. What if I wanted  to combine only lets say 2 specific audio outputs only? This could be very useful for example setting up music server to run on one audio interface and the rest used for Kodi.

Last edited by dominicm (2017-10-04 09:40:57)

Offline

#6 2017-10-04 09:43:12

progandy
Member
Registered: 2012-05-17
Posts: 5,322

Re: Pulseaudio simultaneous output from command line

dominicm wrote:

What if I wanted  to combine only lets say 2 specific audio outputs only? This could be very useful for example setting up music server to run on one audio interface and the rest used for Kodi.

the combine-sink module has a slaves parameter to define the sinks it should use
https://www.freedesktop.org/wiki/Softwa … #index11h3


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#7 2017-10-04 09:53:57

dominicm
Member
Registered: 2015-01-03
Posts: 92

Re: Pulseaudio simultaneous output from command line

progandy wrote:
dominicm wrote:

What if I wanted  to combine only lets say 2 specific audio outputs only? This could be very useful for example setting up music server to run on one audio interface and the rest used for Kodi.

the combine-sink module has a slaves parameter to define the sinks it should use
https://www.freedesktop.org/wiki/Softwa … #index11h3

So what is the purpose of "load-module module-alsa-sink device=hw:0,1" line in the arch wiki? Is it just outdated wiki sice udev does that by default?

Offline

#8 2017-10-04 10:15:24

progandy
Member
Registered: 2012-05-17
Posts: 5,322

Re: Pulseaudio simultaneous output from command line

dominicm wrote:

So what is the purpose of "load-module module-alsa-sink device=hw:0,1" line in the arch wiki? Is it just outdated wiki sice udev does that by default?

Most likely.

https://www.freedesktop.org/wiki/Softwa … #index54h3

You should (almost) never need to load this module manually. Let module-udev-detect look for the supported cards and then select the profile you want, that will make the right sinks show up.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#9 2017-10-04 10:31:39

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

Re: Pulseaudio simultaneous output from command line

The wiki has a few of those questionable advices, I've been meaning to clean it up a bit, but would want to have a few hours to sit down and do that. Which I don't currently have, we'll see.

Offline

Board footer

Powered by FluxBB