Solved USB DAC as default device?

I'm using a USB DAC as my sole audio output (besides system beep) and it works, but the sound devices built into the motherboard are interfering.

cat /dev/sndstat
Code:
Installed devices:
pcm0: <Realtek ALC892 (Rear Analog 7.1/2.0)> (play/rec) default
pcm1: <Realtek ALC892 (Front Analog)> (play/rec)
pcm2: <Realtek ALC892 (Onboard Digital)> (play)
pcm3: <Realtek ALC892 (Rear Digital)> (play)
pcm4: <USB audio> (play)

I have hw.snd.default_unit=4 in my /etc/sysctl.conf but if I don't have the DAC powered on when I boot, or I turn the DAC off, pcm0 reverts to being the default.

Is there a way of turning off all sound devices without touching snd_uaudio? Or is there another method for setting the USB audio as default, even when it's not on?
 
Last edited by a moderator:
Use devd(8) to switch the default device when your USB card is ready. There are lots of examples for other kinds of USB devices in /etc/devd.conf that you can adapt.

Edit: Maybe you can solve this by just setting hw.snd.default_auto=2 (see sound(4)), which means that the most recently attached device becomes the default sound unit.
 
I'm not sure if it's the best way to solve the issue, but this is what I did to fix the problem.

I created /etc/devd/nad-dac.conf
Code:
# /etc/devd/nad-dac.conf
attach 100 {
  device-name "pcm4";
  action "sysctl hw.snd.default_unit=4";
};

detach 100 {
  device-name "pcm4";
  action "sysctl hw.snd.default_unit=0";
};
So now it switches the default device whenever I turn on/off the DAC (I'm not sure if the detach is necessary).
 
Last edited by a moderator:
Hi,

I know this thread is marked as solved, but I thought I would offer an additional option. I think enabling the hw.snd.default_auto knob should do what you were looking for. For example, you could set your default backup sound device to the second device with:
Code:
hw.snd.default_unit=1
and then set
Code:
hw.snd.default_auto=1
to automatically use any USB sound device plugged in after the system has already booted. When the USB device is turned off or unplugged, the system would then default to using the second output device again.
 
Back
Top