mirror of
https://github.com/d4rken-org/capod.git
synced 2026-09-14 18:26:11 -04:00
Two pre-existing concurrency defects in MediaControl (#647). Lost update: sendPlay() wrote capPaused after the suspending sendKey(), whose delay(100) is a window in which a concurrent sendPause(rememberForResume = true) could arm the flag only to have it overwritten. Stem presses run on the app scope while ear, sleep and conversation reactions run on the monitor scope, so the senders really do race. The compound check/dispatch/flag sequence now runs under a Mutex, the flag is cleared before the first suspension, and the key pair completes under NonCancellable so cancellation cannot strand an unpaired DOWN event. Coalescing blind spot: the playback callback ignored its configs argument and read live isMusicActive, so queued deliveries all observed the newest state and an inactive to active edge in between was never seen, leaving capPaused stale. The edge is now derived from the delivered snapshot. A pause that passes the live active check records that observation so an already-queued music-start snapshot cannot drain later and read as a fresh edge.