[headless] Plexamp locks audio device on startup

On a system without a mixer, such as when simply using ALSA without resampling, Plexamp effectively locks the sound device when the service is started with the creation of an empty stream.

cat /proc/asound/BossDAC/pcm0p/sub0/hw_params

access: MMAP_INTERLEAVED
format: S32_LE
subformat: STD
channels: 2
rate: 44100 (705600/16)
period_size: 1323
buffer_size: 2646

lsof /dev/snd/*

COMMAND     PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
node    3978670 vtr1000  mem    CHR  116,4           463 /dev/snd/pcmC1D0p
node    3978670 vtr1000   45u   CHR  116,5      0t0  464 /dev/snd/controlC1
node    3978670 vtr1000   48u   CHR  116,4      0t0  463 /dev/snd/pcmC1D0p

Note however, that nothing is playing. This is seemingly produced in preparation for playing/processing. It doesn’t prevent Plexamp itself from playing, but is does prevent any other service or daemon such as MPD from doing so.

Short of stopping the Plexamp service itself, the only way to unlock the audio device in this situation is by playing a track on Plexamp and then stopping it - a few seconds later, the stream is closed & the alsa device is available for use by other programs.

I have verified this behavior on multiple, very different systems, so hopefully it’s easy to reproduce. Attached is a log from a fresh restart of the Plexamp service.

Plexamp.log (51.1 KB)

i can reproduce this but only if i start playback on another device (phone etc.), pause, then transfer to headless … audio device is then locked until the track that was paused at time of transfer is either stopped or unpaused at least once

hopefully devs can fix … in the meantime, there are ways to avoid the issue … for example, connect to headless first and then start playback

My current solution is a modified systemd service which starts & stops playback in quick succession as a post-process. I don’t hear anything play either.

[Unit]
Description=Plexamp
Wants=sound.target
After=sound.target
Wants=network-online.target
After=network-online.target

[Service]
WorkingDirectory=/home/vtr1000/plexamp
ExecStart=/home/vtr1000/.nvm/versions/node/v20.18.0/bin/node /home/vtr1000/plexamp/js/index.js
ExecStartPost=sleep 5
ExecStartPost=/usr/bin/curl localhost:32500/player/playback/play
ExecStartPost=/usr/bin/curl localhost:32500/player/playback/stop
Restart=on-failure
RestartSec=10

[Install]
WantedBy=default.target

Most people will only be interested in the ExecStartPost lines. Obviously, this requires curl to be installed.

[EDIT]: Updated to reflect changes to playback API (start–>play).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.