Service: harden for unattended running (auto-restart, findable logs, resume)
Local checkpoint - NOT for public release. A "what else does a service need" pass. - AUTO-RESTART ON CRASH: DoInstall now sets sc failure actions (restart 5s/10s/then 60s, reset daily). Without this a crashed service stays dead until reboot - fatal for an always-on streamer. - FINDABLE LOGS: --run-service redirects the service's data dir to the machine-wide ProgramData\RemSound\service location, so its log sits next to its profile instead of buried in the SYSTEM account's AppData. - POWER RESUME: the service handles OnPowerEvent and re-opens capture on wake (audio devices re-initialise after sleep; the device-change watcher usually catches it, but a resume doesn't always fire an endpoint change, so we re-open explicitly). - Start/stop already auto-log to the Windows Event Log via ServiceBase. Test: "Service registration args" now also checks the audio-service dependency and the auto-restart failure args. Gate 27/27. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
4f5265d8b0
commit
92ed477ddf
@@ -166,6 +166,20 @@ public sealed class ServiceSendHost : IDisposable
|
||||
Suspend();
|
||||
}
|
||||
|
||||
/// <summary>Force a re-open of capture if we intend to send — called after a power resume, when the
|
||||
/// audio devices have re-initialised and the current capture may be dead. The device-change watcher
|
||||
/// usually catches this too, but a resume doesn't always fire an endpoint change, so we re-open
|
||||
/// explicitly to be safe.</summary>
|
||||
public void ReopenAfterResume()
|
||||
{
|
||||
if (!wantSending || disposed) return;
|
||||
var profile = loadProfile();
|
||||
if (profile is null) return;
|
||||
log?.Invoke("service: re-opening capture after power resume");
|
||||
Suspend();
|
||||
ApplyProfile(profile);
|
||||
}
|
||||
|
||||
/// <summary>Device-set change callback (COM thread). While we intend to send, (re)open capture — this
|
||||
/// is the event that fires when the audio stack finishes coming up at boot, a device is plugged or
|
||||
/// unplugged, or the audio service restarts. Debounced: a single hot-plug fires several notifications.</summary>
|
||||
|
||||
Reference in New Issue
Block a user