3

Say I have a card with these properties:

index: 1
name: <alsa_card.pci-0000_00_1f.3>
driver: <module-alsa-card.c>
owner module: 7
properties:
    alsa.card = "0"
    alsa.card_name = "HDA Intel PCH"
    alsa.long_card_name = "HDA Intel PCH at 0xf7240000 irq 129"
    alsa.driver_name = "snd_hda_intel"
    device.bus_path = "pci-0000:00:1f.3"
    sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
    device.bus = "pci"
    device.vendor.id = "8086"
    device.vendor.name = "Intel Corporation"
    device.product.id = "a170"
    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 60, available: unknown)
    output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
    output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority 6060, available: unknown)
    output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 5400, available: unknown)
    output:hdmi-stereo+input:analog-stereo: Digital Stereo (HDMI) Output + Analog Stereo Input (priority 5460, available: unknown)
    output:hdmi-surround: Digital Surround 5.1 (HDMI) Output (priority 300, available: unknown)
    output:hdmi-surround+input:analog-stereo: Digital Surround 5.1 (HDMI) Output + Analog Stereo Input (priority 360, available: unknown)
    output:hdmi-surround71: Digital Surround 7.1 (HDMI) Output (priority 300, available: unknown)
    output:hdmi-surround71+input:analog-stereo: Digital Surround 7.1 (HDMI) Output + Analog Stereo Input (priority 360, available: unknown)
    output:hdmi-stereo-extra1: Digital Stereo (HDMI 2) Output (priority 5200, available: unknown)
    output:hdmi-stereo-extra1+input:analog-stereo: Digital Stereo (HDMI 2) Output + Analog Stereo Input (priority 5260, available: unknown)
    output:hdmi-stereo-extra2: Digital Stereo (HDMI 3) Output (priority 5200, available: unknown)
    output:hdmi-stereo-extra2+input:analog-stereo: Digital Stereo (HDMI 3) Output + Analog Stereo Input (priority 5260, available: unknown)
    output:hdmi-surround-extra2: Digital Surround 5.1 (HDMI 3) Output (priority 100, available: unknown)
    output:hdmi-surround-extra2+input:analog-stereo: Digital Surround 5.1 (HDMI 3) Output + Analog Stereo Input (priority 160, available: unknown)
    output:hdmi-surround71-extra2: Digital Surround 7.1 (HDMI 3) Output (priority 100, available: unknown)
    output:hdmi-surround71-extra2+input:analog-stereo: Digital Surround 7.1 (HDMI 3) Output + Analog Stereo Input (priority 160, available: unknown)
    off: Off (priority 0, available: unknown)
active profile: <output:hdmi-stereo-extra1+input:analog-stereo>
sinks:
    alsa_output.pci-0000_00_1f.3.hdmi-stereo-extra1/#1: Built-in Audio Digital Stereo (HDMI 2)
sources:
    alsa_output.pci-0000_00_1f.3.hdmi-stereo-extra1.monitor/#1: Monitor of Built-in Audio Digital Stereo (HDMI 2)
    alsa_input.pci-0000_00_1f.3.analog-stereo/#2: Built-in Audio Analog Stereo
ports:
    analog-input-headphone-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
        properties:
            device.icon_name = "audio-input-microphone"
    analog-input-headset-mic: Headset Microphone (priority 8700, latency offset 0 usec, available: unknown)
        properties:
            device.icon_name = "audio-input-microphone"
    analog-output-lineout: Line Out (priority 9900, latency offset 0 usec, available: no)
        properties:

    analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)
        properties:
            device.icon_name = "audio-speakers"
    analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: yes)
        properties:
            device.icon_name = "audio-headphones"
    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: yes)
        properties:
            device.icon_name = "video-display"
            device.product.name = "Inspiron 7459"
    hdmi-output-2: HDMI / DisplayPort 3 (priority 5700, latency offset 0 usec, available: no)
        properties:
            device.icon_name = "video-display"

I'd like to output unique audio streams to the analog-output-lineout and potentially all of (hdmi-output-0, hdmi-output-1, hdmi-output2): ports. Is there a means to do that simultaneously in PulseAudio? I know in ALSA I can do something like:

gst-launch-1.0 audiotestsrc ! alsasink device="hw:0,0" gst-launch-1.0 audiotestsrc ! alsasink device="hw:0,3"

But what I'm seeing in Pulse indicates that I have to set a single "profile" for the "card", and all the profiles seem tied to a single output port.

Is there a means to do this or is Pulse just fundamentally limited in this regard?

2 Answers 2

7

You must write a custom profile that exposes all the HDMI outputs you need as separate sinks.

Have a look at profiles in the Pulseaudio docs, at the files in /usr/share/pulseaudio/alsa-mixer/paths/, esp. the comments in analog-output.conf.common.

All of this is woefully underdocumented.


An attempt to make it work:

Modify /usr/share/pulseaudio/alsa-mixer/profile-sets/default.conf and append something like the following:

[Profile output:analog-stereo+output:hdmi-stereo+output:hdmi-stereo+output:hdmi-stereo]
description = Foobar
output-mappings = analog-stereo hdmi-stereo hdmi-stereo-extra1 hdmi-stereo-extra2
input-mappings = 

Then restart pulse as the regular desktop user:

pulseaudio --kill; sleep 1; pulseaudio --start

Set the card to use the new profile:

pacmd set-card-profile 0 output:analog-stereo+output:hdmi-stereo+output:hdmi-stereo+output:hdmi-stereo

Now pacmd list-sinks shows a distinct sink for each port identified in the new profile.

The last thing that needs to be done is to figure out how to not muck with the system file. It would be nice to do this through a file in ~/.config/pulse if possible.


Edit

Here is a description how to setup a new profile for an M-Audio USB device.. I also dug up what I did, that's a slight variation of that (I don't like modifying existing files, they tend to get overwritten by package upgrades):

I add a new file /etc/udev/rules.d/91-pulseaudio.rules with the following contents:

# Custom Profile for onboard Intel 8086:12c0

SUBSYSTEM!="sound", GOTO="xpulseaudio_end"
ACTION!="change", GOTO="xpulseaudio_end"
KERNEL!="card*", GOTO="xpulseaudio_end"

SUBSYSTEMS=="pci", ATTRS{vendor}=="0x8086", ATTRS{device}=="0x1c20", ENV{PULSE_PROFILE_SET}="my-personal.conf"

LABEL="xpulseaudio_end"

That's mostly a copy from /lib/udev/rules.d/90-pulseaudio.rules.

As that is an onboard sound card, these rules must be executed at boot, so they should be in the initrd that your kernel uses. I compile my own kernel, and make-kpkg copies these rules, so that wasn't a problem for me.

Then you add make a new file /usr/share/pulseaudio/alsa-mixer/profile-sets/my-personal.conf where you can list the configuration you want (copy and modify from the other configuration files).

9
  • Would this in fact be creating one "card" for each output port?
    – mpr
    Oct 31, 2017 at 15:29
  • Not in any sensible way to use the terminology: A "card" is a single piece of hardware. You are creating different audio sinks on the same card.
    – dirkt
    Nov 1, 2017 at 7:32
  • AFAIK, you can't add profiles under ~/.config/pulse, but you can add an extra file to keep changes contained (and not loose them with the next upgrade).
    – dirkt
    Nov 1, 2017 at 17:58
  • Is it possible to ensure my new conf file will create a profile that is additive--rather than wiping out what is in default.conf? From what I'm seeing the udev rules are supposed to set a PULSE_PROFILE_SET env var, which would override default.conf?
    – mpr
    Nov 1, 2017 at 18:20
  • 1
    @JonathanNeufeld they are not excited about anything; as in e.g. C, != means "not equal", and == means "equal" (and = means "assign a value). Read man udev for the complete syntax.
    – dirkt
    Jun 15, 2021 at 19:20
1

I'm using a GeForce RTX 2070 on Fedora 32, with an HTC Vive connected. Often when someone is playing VR, other people are watching on the monitor. I configured the game audio to go to both the Vive and the monitor.

First, find all of the audio devices using aplay -L, then test those devices to see which ones are connected. For example, speaker-test -D hdmi:CARD=NVidia,DEV=1 -c2. However, that command hit an odd bug with the Nvidia driver:

$ speaker-test -D hdmi:CARD=NVidia,DEV=1 -c2 

speaker-test 1.2.3

Playback device is hdmi:CARD=NVidia,DEV=1
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 8544000
Period size range from 32 to 4272000
Using max buffer size 8544000
Periods = 4
Unable to set hw params for playback: Cannot allocate memory
Setting of hwparams failed: Cannot allocate memory

Explicitly setting the buffer size lower works around the bug:

$ speaker-test -D hdmi:CARD=NVidia,DEV=1 -c2 -b10000

speaker-test 1.2.3

Playback device is hdmi:CARD=NVidia,DEV=1
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 8544000
Period size range from 32 to 4272000
Requested buffer time 10000 us
Periods = 4
was set period_size = 96
was set buffer_size = 480
 0 - Front Left
^C 1 - Front Right
Time per period = 0.438162

After you have figured out which outputs are valid for the device, explicitly add them to pulseaudio by creating the .config/pulse/default.pa file. The device description can be set to whatever you want. Here's my file:

load-module module-alsa-sink device=hdmi:CARD=NVidia,DEV=0 sink_properties="device.description='NVIDIA HDMI Vive'"
load-module module-alsa-sink device=hdmi:CARD=NVidia,DEV=1 sink_properties="device.description='NVIDIA HDMI monitor'"

.include /etc/pulse/default.pa

Restart pulseaudio by running systemctl --user restart pulseaudio.service, then verify the devices show up in pavucontrol. Finally use paprefs to enable simultaneous output to all audio devices.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.