# \[headless\] Plexamp locks audio device on startup

**URL:** <https://forums.plex.tv/t/headless-plexamp-locks-audio-device-on-startup/893056>\
**Category:** Plex Labs\
**Tags:** plexamp\
**Created:** [October 22, 2024, 9:27pm UTC](https://forums.plex.tv/t/headless-plexamp-locks-audio-device-on-startup/893056 "2024-10-22T21:27:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vtr1000](https://avatars.discourse-cdn.com/v4/letter/v/76d3ee/32.png) [@vtr1000](https://forums.plex.tv/u/vtr1000)\
**Post date:** [October 22, 2024, 9:27pm UTC](https://forums.plex.tv/t/headless-plexamp-locks-audio-device-on-startup/893056/1 "2024-10-22T21:27:47Z")

</div>

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_

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

```

_lsof /dev/snd/\*_

```auto
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](https://forums.plex.tv/uploads/short-url/bvbBEBAagowskFKLplpoDoE8fOE.log) (51.1 KB)

---

<div class="post-metadata">

**Author:** ![tgp-2](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/tgp-2/32/276306_2.png) [@tgp-2](https://forums.plex.tv/u/tgp-2)\
**Post date:** [October 23, 2024, 1:37am UTC](https://forums.plex.tv/t/headless-plexamp-locks-audio-device-on-startup/893056/2 "2024-10-23T01:37:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vtr1000](https://avatars.discourse-cdn.com/v4/letter/v/76d3ee/32.png) [@vtr1000](https://forums.plex.tv/u/vtr1000)\
**Post date:** [October 24, 2024, 10:40pm UTC](https://forums.plex.tv/t/headless-plexamp-locks-audio-device-on-startup/893056/3 "2024-10-24T22:40:06Z")

</div>

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.

```auto
[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)._

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [January 22, 2025, 10:40pm UTC](https://forums.plex.tv/t/headless-plexamp-locks-audio-device-on-startup/893056/4 "2025-01-22T22:40:18Z")

</div>

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