Score:0

How to set which HDMI/DP port used to play audio?

ht flag

I have two monitor connect to the ubuntu host (one through HDMI port, the other through DP port).

$ xrandr -q | grep -i XWAYLAND
XWAYLAND0 connected primary 2560x1440+1440+557 (normal left inverted right x axis y axis) 600mm x 340mm
XWAYLAND1 connected 1440x2560+0+0 (normal left inverted right x axis y axis) 330mm x 600mm

I need to stream the audio to the device that use DP port. But in the ubuntu setting, the HDMI/DP audio output options are a same option, like:

HDMI and DP output are in one option

It seems that it use HDMI as output port as default, when I close the HDMI connected monitor, the device connected through DP port play the sound.

There are some related ports information.(I'm not familiar with that, if more information needed, just tell me.)

$ find /sys/devices -name "edid"
/sys/devices/pci0000:00/0000:00:08.1/0000:10:00.0/drm/card0/card0-HDMI-A-1/edid
/sys/devices/pci0000:00/0000:00:08.1/0000:10:00.0/drm/card0/card0-DP-2/edid
/sys/devices/pci0000:00/0000:00:08.1/0000:10:00.0/drm/card0/card0-DP-3/edid
/sys/devices/pci0000:00/0000:00:08.1/0000:10:00.0/drm/card0/card0-DP-1/edid

Audio device information from aplay.

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 0: ALC897 Analog [ALC897 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

And config in ~/.config/pulse/**-default-sink

cat ~/.config/pulse/2235aa67aade40c4b290abaf5e5b312a-default-sink 
alsa_output.pci-0000_10_00.1.hdmi-stereo
Score:0
br flag

Find the names of output audio devices

Try to determine the audio output device in your system. It is possible that you will see HDMI and DP separately. Note the second column of the output. The column contains names of audio devices.

pactl list short sinks

More detailed output:

pactl list sinks

Search for HDMi and DP.

Output settings

To select an output device using a command, do the following (example):

pactl set-default-sink alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1

Input device (not requested)

For the sake of completeness, I will also mention the findings and settings of input devices, although you did not ask about it.

Listing

pacmd list-sources | grep -e 'index:' -e device.string -e 'name:'

Settings (example)

pactl set-default-source alsa_input.usb-0c76_USB_PnP_Audio_Device-00.mono-fallback
Kicey avatar
ht flag
Thank you for answering. I'm sorry to say that I've tried pactl and it doesn't work. There is the only one sinks result show by running the `pactl list sinks` command. I think it's something related to the driver not work. I just switch the monitors port, and use the HDMI port to play the audio, sometimes the host don't play the audio again, and I need to logout and login in again which can solve the problem.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.