Configuring PulseAudio on FreeBSD.

In this example, the PulseAudio is configured to output to HDMI by default. If USB headphones are attached, then audio output is automatically switched to these. I tested this to be working.

$ pactl list sinks
Sink #3
State: RUNNING
Name: oss_output.dsp3
Description: 3 - Intel (0x2818) (HDMI/DP 8ch)
Mute: no
# nano /usr/local/etc/pulse/default.pa
set-default-sink oss_output.dsp3
load-module module-switch-on-connect

Switching audio output with pactl on FreeBSD.

pactl is a control interface for a running PulseAudio sound server. In this example, the audio output is switched to a pair of USB headphones. The listings indicate, that the headphones are associated with sink 4 and name oss_output.dsp5. The output is switched to to this and it is un-muted. Warning: The volume is optionally set to 100%. The volume setting is the same as the one, that is set on the headphones themselves.

$ pactl list sinks
Sink #4
State: RUNNING
Name: oss_output.dsp5
Description: 5 - Corsair CORSAIR HS80 RGB Wireless Gaming Receiver
muted: yes
Sample Specification: s16le 2ch 44100Hz
$ pactl list sinks short
4 oss_output.dsp5 module-oss.c s16le 2ch 44100Hz RUNNING
$ pactl set-default-sink oss_output.dsp5
$ pactl set-sink-mute oss_output.dsp5 0
$ pactl set-sink-volume oss_output.dsp5 100%

References.