LarkTestVFSImpl.mesa
Copyright © 1984, 1986 by Xerox Corporation. All rights reserved.
Last edit: L. Stewart, January 3, 1984 11:09 am
Last Edited by: Swinehart, June 6, 1986 8:24:49 am PDT
DIRECTORY
IO,
Jukebox USING [CloseTune, CreateTune, Error, FindJukebox, Handle, OpenJukebox, Tune],
Lark,
LarkTest,
PrincOpsUtils USING [IsBound],
PupSocket USING [Destroy, GetLocalAddress],
Rope USING [ROPE],
VoiceStream USING [AddPiece, Close, Open, SetSocket, wholeTune];
LarkTestVFSImpl: CEDAR MONITOR
IMPORTS IO, Jukebox, PrincOpsUtils, PupSocket, VoiceStream
EXPORTS LarkTest
= BEGIN
jukeOpen: BOOLFALSE;
jukebox: Jukebox.Handle ← NIL;
InitializeJukeBox: PROCEDURE = TRUSTED {
jukeboxName: Rope.ROPE = "Test.Jukebox";
Initialize anything that has to be set up on the VFS side.
haveJuke: BOOLTRUE;
IF NOT PrincOpsUtils.IsBound[LOOPHOLE[Jukebox.FindJukebox]] THEN RETURN;
IF (jukebox ←Jukebox.FindJukebox[jukeboxName]) = NIL THEN {
jukebox ← Jukebox.OpenJukebox[jukeboxName ! Jukebox.Error => { CONTINUE; }];
};
jukeOpen ← jukebox # NIL;
};
OpenVFS: PUBLIC LarkTest.BProc = TRUSTED {
IF NOT jukeOpen THEN InitializeJukeBox[];
IF NOT jukeOpen THEN RETURN;
self.out.PutF["VFS Connect[[%b, %b]\n", IO.int[self.rx1.remoteSocket.net], IO.int[self.rx1.remoteSocket.host]];
self.socket ← PupSocket.CreateEphemeral[
local: self.rx1.remoteSocket.socket,
remote: self.rx1.localSocket,
getTimeout: 100];
self.tx3 ← NEW[Lark.ConnectionSpecRec];
self.tx3.protocol ← Lark.Protocol[interactive];
self.tx3.encoding ← Lark.Encoding[muLaw];
self.tx3.blankA ← 0;
self.tx3.blankB ← 0;
self.tx3.blankC ← 0;
self.tx3.buffer ← in1;
self.tx3.keyIndex ← 0;
self.tx3.localSocket ← self.rx1.localSocket;
self.tx3.remoteSocket ← self.socket.GetLocalAddress[];
self.stream ← VoiceStream.Open[jukebox];
VoiceStream.SetSocket[socket: self.socket, handle: self.stream];
};
CloseVFS: PUBLIC LarkTest.BProc = TRUSTED {
IF NOT jukeOpen THEN RETURN;
IF self.stream#NIL THEN VoiceStream.Close[self.stream];
self.stream ← NIL;
IF self.socket#NIL THEN PupSocket.Destroy[self.socket];
self.socket ← NIL;
};
SetInterval: ENTRY PROC[ self: LarkTest.LarkHandle, utterance: INT, record: BOOL, queueIt: BOOLEAN, nBytes: INT ← VoiceStream.wholeTune] RETURNS [actualUtterance: INT] = TRUSTED {
ENABLE UNWIND=>NULL;
tune: Jukebox.Tune;
IF NOT jukeOpen THEN RETURN;
IF utterance = -1 THEN
IF record THEN {
tune ← Jukebox.CreateTune[jukebox, -1];
utterance ← tune.tuneId;
Jukebox.CloseTune[jukebox, tune];
}
ELSE RETURN;
VoiceStream.AddPiece[
handle: self.stream,
tuneId: utterance,
firstByte: 0,
nBytes: nBytes,
create: record,
playback: NOT record,
keyIndex: 0,
flush: NOT queueIt ];
RETURN[utterance];
};
Playback: PUBLIC LarkTest.PlaybackProc = {
[] ← SetInterval[ self: self, utterance: message, record: FALSE, queueIt: queue ];
};
Record: PUBLIC LarkTest.RecordProc = {
message ← SetInterval[ self: self, utterance: -1, record: TRUE, queueIt: FALSE, nBytes: seconds * 8000 ];
};
END.
Swinehart, May 16, 1986 11:47:06 am PDT
Cedar 6.1
changes to: DIRECTORY, LarkTestVFSImpl, OpenVFS, CloseVFS