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
+9 -2
View File
@@ -82,5 +82,12 @@ The `output_directory` value is used as-is: a relative path like `recordings` re
## Docker
Two services share a `./recordings` bind mount:
- `recorder` — runs `isr.py`; volume mounted at `/app/recordings` (matches `output_directory = recordings`); maps `/dev/snd` for ALSA access; `stop_grace_period: 30s` so open files are closed before SIGKILL
- `web` — runs `web.py`; same `./recordings` bind mounted read-only at `/recordings`; exposes port 8080
- `recorder` — runs `isr.py`; volume at `/app/recordings`; mounts `asound.conf` as `/etc/asound.conf`; maps `/dev/snd`; `ipc: host` for dsnoop shared memory; `stop_grace_period: 30s`
- `web` — runs `web.py`; same `./recordings` read-only at `/recordings`; exposes port 8080
**Sharing the soundcard with darkice (or any other ALSA app):**
ALSA `hw:` devices are exclusive. `asound.conf` defines a `dsnoop` virtual device `shared_mic` that both processes use instead:
1. `sudo cp asound.conf /etc/asound.conf` on the host
2. Change darkice config to `device = shared_mic`
3. Set `device = shared_mic` in `config.ini`
4. `ipc: host` in `docker-compose.yml` is already set — required for dsnoop shared memory to cross the container boundary