PlayNoiseImpl.mesa
Last Edited by: Swinehart, June 21, 1986 7:29:12 pm PDT
DIRECTORY
Booting USING [ RegisterProcs, CheckpointProc ],
Intervoice USING [ Handle, Open, Play ],
Process USING [ Detach, MsecToTicks, Pause ],
Rope USING [ ROPE ],
UserProfile USING [ Token ],
VoiceUtils USING [ MakeAtom ]
;
PlayNoiseImpl: CEDAR PROGRAM
IMPORTS Booting, Intervoice, Process, UserProfile, VoiceUtils = {
reallyBoot: BOOLTRUE;
didOurBest: BOOL;
maxTime: CARDINAL ← 4000;
PlayTheRollbackButton: Booting.CheckpointProc = TRUSTED {
IF VoiceUtils.MakeAtom[UserProfile.Token["Finch.NoisyBoot", "false"]] # $true
THEN RETURN;
PlayAButton["Rollback"];
IF ~reallyBoot THEN rejection ← "Just pretending";
};
PlayAButton: PROC[name: Rope.ROPE] = TRUSTED {
didOurBest ← FALSE;
Process.Detach[FORK ReallyPlayAButton[name]];
FOR i: NAT IN [0..100) DO
Process.Pause[Process.MsecToTicks[maxTime/100]];
IF didOurBest THEN EXIT;
ENDLOOP;
};
ReallyPlayAButton: PROC[name: Rope.ROPE] = {
C: PROC[complaint: Rope.ROPE] = {NULL}; -- Don't bother complaining.
handle: Intervoice.Handle = Intervoice.Open[Complain: C];
Intervoice.Play[handle: handle, refID: name, refIDType: "SysNoises", wait: TRUE];
didOurBest ← TRUE;
};
Booting.RegisterProcs[c: PlayTheRollbackButton, r: NIL, b: PlayTheRollbackButton];
}.