fix: share soundcard between darkice and ISR via ALSA dsnoop

hw:0,0 is an exclusive ALSA device — darkice holding it caused arecord
to fail silently (stderr was /dev/null), leaving all recordings at 0 bytes
with no errors in the log.

asound.conf: defines a dsnoop virtual device 'shared_mic' that opens
hw:0,0 once and lets multiple processes capture simultaneously.

docker-compose.yml: mount asound.conf into the container as
/etc/asound.conf; add ipc: host so the container shares the host IPC
namespace (dsnoop uses System V shared memory which does not cross the
container IPC boundary without this).

config.example.ini: document the dsnoop setup and shared-device pattern.
README, CLAUDE.md: document the full setup procedure.
This commit is contained in:
2026-04-26 14:21:31 +02:00
parent 357b3e6ed9
commit e67e27f047
5 changed files with 65 additions and 3 deletions
+18 -1
View File
@@ -182,7 +182,24 @@ arecord -l # list capture hardware
ls -la /dev/snd # check device nodes
```
**Stream-only deployments:** If you don't use soundcard recording, remove the `devices` block from `docker-compose.yml` — the image works fine without it.
**Sharing the soundcard with another app (e.g. darkice):** ALSA `hw:` devices are exclusive — only one process can hold them at a time. `asound.conf` in this repo defines a `dsnoop` virtual device (`shared_mic`) that lets multiple processes capture simultaneously:
```bash
# 1. Deploy the ALSA config to the host (once)
sudo cp asound.conf /etc/asound.conf
# 2. Change darkice (or any other app) to use device "shared_mic" instead of hw:0,0
# 3. In config.ini set: device = shared_mic
# docker-compose.yml already mounts asound.conf and sets ipc: host
# (ipc: host is required so the container shares the host IPC namespace for dsnoop shared memory)
# 4. Restart everything
sudo systemctl restart darkice
docker compose down && docker compose up -d --build
```
**Stream-only deployments:** If you don't use soundcard recording, remove the `devices` block and the `asound.conf` volume mount and `ipc: host` line from `docker-compose.yml` — the image works fine without them.
**Log file in Docker:** The recorder always logs to stdout, so `docker compose logs -f` shows live output. To persist logs on the host, set `log_file = /app/recordings/recorder.log` in `config.ini` (the `recordings` directory is the bind mount).