I have multiple small form factor desktops that I used on a day to day basis. Each with their own Operating Systems. One is running Windows 10, one is running Manjaro Linux and on another I decided I was going to run a FreeBSD desktop. Just to be different!
I have all the desktops connected up to a HDMI KVM switch which means that I can use the headphone socket on the monitor to be able to listen to whichever desktop I happen to be using. And while the desktops use DisplayPort, I use HDMI converters and have had no issues with audio. Until trying to play something on the FreeBSD desktop that is.
FreeBSD uses OSS as it’s default audio interface. While I could get no audio out of the monitor via HDMI I could get audio plugged into one of the two jacks on the desktop. So I had to do a bit of poking about.
The first thing you need to do is to see how the audio devices are enumerated by the kernel at boot time. Like most desktops and laptops these days there are usually two audio hardware devices. My desktop is no different in having a Realtek ALC233 on board audio (that uses the two jacks on the PC) and an Intel HD Audio Device.
Which ever one is enumerated first becomes the default audio device. In my case it was the Realtek Device.
You can check this yourself with the following command (as root)
cat /dev/sndstat
You will see something like this:
Here you can see the Realtek is enumerated first as both pcm0 and pcm1.
The important thing to remember here is that while three devices are listed there are actually just two audio devices which means the HDMI device is actually device 2
To make the HDMI audio device the default device you need to execute a sysctl command as root:
sysctl hw.snd.default_unit=2
If this works and your audio is now routed correctly you will need to make the change permanent.
To do this you need to edit the file /etc/sysctl.conf
and add the line we used above (minus the sysctl part) to it. Mine looks like this:
Now your HDMI audio output should persist after a reboot.
Or at least it should! In my case on this particular desktop I had no audio at all. Even though the HDMI audio was set correctly to default! It was driving me crazy until I realised that the desktop has two Display Port sockets at the back. I switched the cable to the other one and finally I had sound.
Recent Comments