Types
AudioInfo: TYPE ~ AudioLibrary.AudioInfo;
AudioInfoBody: TYPE ~ AudioLibrary.AudioInfoBody;
ErrCode: TYPE ~ AudioLibrary.ErrCode;
FD: TYPE ~ AudioLibrary.FD;
IPAddress: TYPE ~ AudioLibrary.IPAddress;
IPPort: TYPE ~ AudioLibrary.IPPort;
MixerID: TYPE ~ AudioLibrary.MixerID;
portOffset: NAT ¬ BYTES[WORD]-BYTES[IPPort]; -- assumes big-endian, though.
noisy: BOOL¬FALSE;
Glue
AudioGetInfo:
PUBLIC PROC [fd:
FD]
RETURNS [err: ErrCode, info: AudioInfo] ~ {
info ¬ NEW[AudioInfoBody ¬ []];
err ¬ AuGeIn[fd, info];
IF noisy AND err#success THEN VoiceUtils.ReportFR["GetInfo returned %g", NIL, NIL, Ival[err]];
};
AuGeIn:
PROC [fd:
FD, info: AudioInfo]
RETURNS [err: ErrCode] ~
TRUSTED MACHINE CODE { "audio←getinfo" };
AudioSetInfo:
PUBLIC
PROC [fd:
FD, info: AudioInfo, returnCurrentValue:
BOOL¬
FALSE]
RETURNS [err: ErrCode, newInfo: AudioInfo] ~ {
newInfo ¬ NEW[AudioLibrary.AudioInfoBody ¬ info];
err ¬ AuSeIn[fd, newInfo, returnCurrentValue];
IF noisy AND err#success THEN VoiceUtils.ReportFR["SetInfo returned %g", NIL, NIL, Ival[err]];
};
AuSeIn:
PROC [fd:
FD, info: AudioInfo, rCV:
BOOL]
RETURNS [err: ErrCode] ~
TRUSTED MACHINE CODE { "audio←setinfo" };
MixerLinkStream:
PUBLIC PROC [mixerID: MixerID, fd:
FD]
RETURNS [err: ErrCode] ~ {
err ¬ MiLiSt[mixerID, fd];
IF noisy AND err#success THEN VoiceUtils.ReportFR["MixerLinkStream returned %g", NIL, NIL, Ival[err]];
};
MiLiSt:
PROC [mixerID: MixerID, fd:
FD]
RETURNS [err: ErrCode] ~
TRUSTED MACHINE CODE { "mixer←linkstream" };
MixerUnlinkStream:
PUBLIC PROC [fd: FD]
RETURNS [err: ErrCode] ~ {
err ¬ MiUnSt[fd];
IF noisy AND err#success THEN VoiceUtils.ReportFR["MixerUnlinkStream returned %g", NIL, NIL, Ival[err]];
};
MiUnSt:
PROC [fd:
FD]
RETURNS [err: ErrCode] ~
TRUSTED MACHINE CODE { "mixer←unlinkstream" };
TransmitStreamCreate:
PUBLIC
PROC [
groupAddr: IPAddress, groupPort: IPPort, packetLen: INT, voxEnable: BOOL]
RETURNS [fd: FD] ~ {
wPort: WORD ¬ LOOPHOLE[groupPort];
i: INT;
fd ¬ TrStCr[groupAddr, wPort, packetLen, voxEnable];
IF noisy AND (i¬LOOPHOLE[fd, INT])<0 THEN VoiceUtils.ReportFR["Xmit Create returned %g", NIL, NIL, [integer[i]]];
};
TrStCr:
PROC [
groupAddr: IPAddress, groupPort: WORD, packetLen: INT, voxEnable: BOOL]
RETURNS [fd: FD] ~ TRUSTED MACHINE CODE { "xmitstream𡤌reate" };
ReceiveStreamCreate:
PUBLIC PROC [
groupAddr: IPAddress, groupPort: IPPort,
remoteAddr: IPAddress, remotePort: IPPort, jitterDelay: INT]
RETURNS [fd:
FD] ~
{
wgPort: WORD ¬ LOOPHOLE[groupPort];
wrPort: WORD ¬ LOOPHOLE[remotePort];
i: INT;
fd ¬ ReStCr[groupAddr, wgPort, remoteAddr, wrPort, jitterDelay];
IF noisy AND (i¬LOOPHOLE[fd, INT])<0 THEN VoiceUtils.ReportFR["Rcv Create returned %g", NIL, NIL, [integer[i]]];
};
ReStCr:
PROC [
groupAddr: IPAddress, groupPort: WORD,
remoteAddr: IPAddress, remotePort: WORD, jitterDelay: INT]
RETURNS [fd: FD] ~ TRUSTED MACHINE CODE { "recvstream𡤌reate" };
StreamDestroy:
PUBLIC PROC [fd:
FD]
RETURNS [err: ErrCode] ~
{
err ¬ StDe[fd];
IF noisy AND err#success THEN VoiceUtils.ReportFR["StreamDestroy returned %g", NIL, NIL, Ival[err]];
};
StDe:
PROC [fd:
FD]
RETURNS [err: ErrCode] ~
TRUSTED MACHINE CODE { "streamstroy" };
StreamGetLocalAddr:
PUBLIC PROC [fd:
FD]
RETURNS [err: ErrCode, localAddr: IPAddress, localPort: IPPort] ~ TRUSTED {
wPort: WORD;
err ¬ StGeLoAd[fd, @localAddr, @wPort];
IF noisy AND err#success THEN VoiceUtils.ReportFR["StreamGetLcl returned %g", NIL, NIL, Ival[err]];
localPort ¬ LOOPHOLE[wPort];
};
StGeLoAd:
PROC [
fd: FD, localAddrP: POINTER TO IPAddress, localPortP: POINTER TO WORD]
RETURNS [err: ErrCode] ~ TRUSTED MACHINE CODE { "stream←getlcladdr" };
StreamSetGroupAddr:
PUBLIC PROC [fd:
FD, groupAddr: IPAddress, groupPort: IPPort]
RETURNS [err: ErrCode] ~ {
wPort: WORD ¬ LOOPHOLE[groupPort];
err ¬ StSeGrAd[fd, groupAddr, wPort];
IF noisy AND err#success THEN VoiceUtils.ReportFR["StreamSetGrp returned %g", NIL, NIL, Ival[err]];
};
StSeGrAd:
PROC [fd:
FD, groupAddr: IPAddress, groupPort:
WORD]
RETURNS [err: ErrCode] ~ TRUSTED MACHINE CODE { "stream←setgrpaddr" };
StreamSetRemoteAddr:
PUBLIC PROC [fd:
FD, remoteAddr: IPAddress, remotePort: IPPort]
RETURNS [err: ErrCode] ~ {
wPort: WORD ¬ LOOPHOLE[remotePort];
err ¬ StSeReAd[fd, remoteAddr, wPort];
IF noisy AND err#success THEN VoiceUtils.ReportFR["StreamSetRemote returned %g", NIL, NIL, Ival[err]];
};
StSeReAd:
PROC [fd:
FD, remoteAddr: IPAddress, remotePort:
WORD]
RETURNS [err: ErrCode] ~ TRUSTED MACHINE CODE { "stream←setremaddr" };
Ival: PROC[err: ErrCode] RETURNS [IO.Value] ~ { RETURN[[integer[LOOPHOLE[err]]]]; };
NoisyOn: Commander.CommandProc~{ noisy ¬ TRUE; };
NoisyOff: Commander.CommandProc~{ noisy ¬ FALSE; };
Commander.Register["AudioLibNoisyOn", NoisyOn];
Commander.Register["AudioLibNoisyOff", NoisyOff];
}.