forked from unom/punktfunk
Field report (2026-08-12): Punktfunk's audio devices tank Helldivers 2 to 1% lows of 2-5 FPS; uninstalling restores performance. Two host-side mechanisms can plausibly do that, both fixed here. The mint retry storm: minted::ensure_blocking() ran a FULL provisioning pass on every mic-pump open with no cooldown, no in-flight guard, and no give-up - and ensure_role() reached UpdateDriverForPlugAndPlayDevicesW even when the devnode already existed. On a box where minting never latches, the pump's reopen backoff (capped 60 s) turned that into a PnP driver rebind + system-wide device-change broadcast roughly once a minute, forever - and games rebuild their audio graph on each broadcast. Now: * ensure_role() gets a steady-state fast path: a marker devnode whose endpoints are all live resolves without touching PnP or the default-device policy. * ensure_blocking() waits on an in-flight pass instead of racing a second SetupAPI sweep against it (the dead-mic-air deploy race), honours RETRY_COOLDOWN after a failed pass (first-ever resolve still blocks, per the cold-boot mint contract), and * five unlatched passes stop minting for the host lifetime (a service restart re-arms) - counted across the worker and the blocking path. The never-reverted session tuning: pf-frame's tune_process_once() put the whole host at HIGH_PRIORITY_CLASS with timeBeginPeriod(1) and DWM MMCSS on the first hot stream thread and documented 'reverts at process exit' - but the host is a 24/7 service, so after one stream it competed at HIGH class with a 1 ms global timer against whatever the user played locally, forever. The process-wide tuning is now refcounted across the hot threads via a TLS guard: the first hot thread applies it, the last one's exit reverts it (timeEndPeriod, DwmEnableMMCSS(0), NORMAL class) - the same thread-exit lifetime the MMCSS and execution-state effects already ride. Every on_hot_thread() call site is a session-scoped thread (capture/encode, packetizer, send, NVENC retrieve), so the revert lands at session teardown.