Notes // Linux USB Audio Keep-Alive Service

Keep a USB audio device from sleeping by creating a keep alive service to play a silent sin wave using sox.

Snap, Crackle, Pop

I recently bought some new speakers for my desk. They are big and require a power amp. I didn't want to put a big AV receiver on my desk, so after a bunch of reading I decided to buy an AITIMA A07 power amp. The AITIMA has a very small footprint. It has RCA inputs so I could connect it via a 3.5mm stereo to RCA splitter cable, but I also have some pretty good over-ear headphones and I wanted to add a headphone amp to the mix. I decided to buy the FX-AUDIO DAC-X6 - it has RCA outputs for the AITIMA amp, 3 different inputs (Optical, USB, and Coaxial) - it also has a built in headphone amplifier and a volume knob.

I hooked everything up and it sounded great, except for one big flaw: when there was no sound the DAC would go to sleep. This doesn't seem like a big issue, but every time I would play or pause an audio stream from any application it would take a few ms to wake up and then it would make a minor "pop" sound as it woke up. Likewise when I stopped or paused any audio application it would make a minor "pop" sound when it went to sleep. This was very annoying.

Failed Solutions

I started googling. Many people recommend disabling a pulseaudio module called module-suspend-on-idle. This is a power saving module that shuts down an audio device when there is no sound. I tried commenting out the load-module module-suspend-on-idle line in /etc/pulse/default.pa. But this had no effect on my setup because the DAC was shutting itself off, independently of the pulseaudio setting.

The other thing that is recommended is to disable the snd_hda_intel power saving feature via a kernel module option. Unfortunately, I have the DAC connected via USB, thus the kernel uses the snd_usb_module which has no power saving features.

Keeping Alive With Silence

I finally found a few comments on Stackoverflow and a few forums that recommended playing a silent signal to keep external devices alive. I tested a few of these recommendations and compiled my own solution.

Step 1. Install sox:

For Arch you can use yay or paru to install sox.

$ paru sox

For ubuntu you could use apt:

$ apt install sox

Step 2. Create a systemd service file to run a sox command to generate a silent sin signal:

$ vim ~/.config/systemd/user/usb-audio-keep-alive.service

Here are the contents of the service file:

[Unit]
Description=Keep USB Audio Alive Using sox

[Service]
ExecStart=/usr/bin/play -n -c2 synth sin gain -100

[Install]
WantedBy=default.target

Step 3. Start and enable the keep alive service:

$ systemctl --user start usb-audio-keep-alive.service
$ systemctl --user enable usb-audio-keep-alive.service

Now, in your mixer (I use pavucontrol) you should see a sox entry that is silent. Perfect! The DAC is awake all the time and there is no more popping.

Side Notes

The AITIMA A07 amp is phenomenal! There is zero noise and the speakers sound great. I can't believe how small it is. Even at high volume it doesn't get hot. I am extremely impressed with it.

The FX-AUDIO DAC-X6 is fine. It has features that I like: RCA outputs for the amp, a headphone jack, and a volume knob for the headphone amp. It is built really well but I can't tell if the DAC is any higher quality than the Realtek chip on my mobo. For $50 I am satisfied.

Written by
Published
Email destin{AT}destinmoulton.com if you have any comments or questions.