record-daemon: keep one recorder running per machine

One test recording produced two half-files: the game in one, the
microphone in the other. Two daemons were alive at once, each with its
own OBS, and only one of them won the game's capture hook and its audio.
Any launch path can start a daemon (the app when it cannot reach the
pipe, the tray, a manual run) and the pipe server accepts a second
instance without complaint, so nothing stopped the second copy.

The daemon now claims a lock file in its configuration directory before
booting OBS. On Windows the file is opened with a share mode of zero, so
a second open fails with a sharing violation; on Unix an exclusive
flock does the same. The loser logs which process holds the lock and
exits, leaving the running recorder alone. Closing the handle releases
the lock, so a crash does not leave the machine without a recorder.
This commit is contained in:
vhaudiquet committed 2026-11-16 22:20:51 +01:00
1 parent 2953ab1ee3
commit 9f5f1f669d
5 files changed
+129

No files matched your search

+1
View File
@@ -74,6 +74,7 @@ display-info = "0.5"
# Signal handling for graceful shutdown (Unix only)
[target.'cfg(unix)'.dependencies]
libc = "0.2"
signal-hook = "0.4"
signal-hook-tokio = { version = "0.4", features = ["futures-v0_3"] }