|##########|
|#MAGIC   #|CLABLOAC
|#PROJECT #|"IMPORTALL"
|#PATHS   #|"StdProject"
|#FLAGS   #|xx-x-x--xx----x-----------------
|#USERSW  #|--------------------------------
|#USERMASK#|--------------------------------
|#SWITCHES#|x-xx-x----------
|##########|
DEFINITION MODULE Audio;


| Groups in this module ( in this order ):
|
| AudioGrp All

(* $A- *)
FROM T_Exec       IMPORT NoFreeSignal,OpenError,IOCommand,IOFlagSet,
                         IOFlags,IORequest,IOReturn,Message,nonstdVAL;
FROM Resources    IMPORT ContextPtr;
FROM System	  IMPORT Regs;

CONST

  | System Constants
  hardChannels     = 4;

  minPrec          = -128;
  maxPrec          = 127;

  | values for IORequest.command
  free             = IOCommand( nonstdVAL + 0 );
  setPrec          = IOCommand( nonstdVAL + 1 );
  finish           = IOCommand( nonstdVAL + 2 );
  perVol           = IOCommand( nonstdVAL + 3 );
  lock             = IOCommand( nonstdVAL + 4 );
  waitCycle        = IOCommand( nonstdVAL + 5 );
  allocate         = IOCommand( 32 );
  noUnit           = allocate;

  | values for IORequest.flags
  pervol           = IOFlagSet:{ IO4 };
  syncCycle        = IOFlagSet:{ IO5 };
  noWait           = IOFlagSet:{ IO6 };
  writeMessages    = IOFlagSet:{ IO7 };

  | errors returned in IORequest.error
  noAllcation      = IOReturn( $F6 );
  allocFailed      = IOReturn( $F5 );
  channelStolen    = IOReturn( $F4 );


TYPE

  IOAudioPtr =   POINTER TO IOAudio;
  IOAudio    =   RECORD OF IORequest
                   allocKey  : INTEGER;
                   data      : ANYPTR;
                   length    : LONGCARD;
                   period    : CARDINAL;
                   volume    : CARDINAL;
                   cycles    : CARDINAL;
                   writeMsg  : Message;
                 END;


|   OpenAudio
|
| try to open the audio.device.
| EXCEPTION NoFreeSignal OpenError
|
PROCEDURE OpenAudio(context : ContextPtr:=NIL) : IOAudioPtr;

PROCEDURE CloneAudio(request : IOAudioPtr;context : ContextPtr:=NIL):IOAudioPtr;

PROCEDURE BeginIO(request IN A1 : IOAudioPtr);

PROCEDURE AbortIO(request IN A1 : IOAudioPtr);

|   CloseAudio
| close the audio device associated with the request.
| will be called if forgotten.
PROCEDURE CloseAudio(VAR request : IOAudioPtr);


GROUP
  AudioGrp =  hardChannels,minPrec,maxPrec,free,setPrec,finish,
              perVol,lock,waitCycle,noUnit,allocate,pervol,syncCycle,
              noWait,writeMessages,noAllcation,allocFailed,
              channelStolen,IOAudio,IOAudioPtr,OpenAudio,CloseAudio;

  All      = AudioGrp;

END Audio.
