home *** CD-ROM | disk | FTP | other *** search
-
- {$I "Include:Exec/Lists.i"}
- {$I "Include:Exec/Libraries.i"}
- {$I "Include:Exec/Tasks.i"}
- {$I "Include:Utility/TagItem.i"}
- {$I "Include:Utility/Hooks.i"}
-
- {***************************************************************************}
-
- const
- { realtime.library's idea of time is based on a clock which emits a pulse
- * 1200 times a second (1.2kHz). All time values maintained by realtime.library
- * are based on this number. For example, the field RealTimeBase->rtb_Time
- * expresses an amount of time equivalent to (RealTimeBase->rtb_Time/TICK_FREQ)
- * seconds.
- }
- TICK_FREQ = 1200;
-
-
- {***************************************************************************}
-
-
- { Each Conductor represents a group of applications which wish to remain
- * synchronized together.
- *
- * This structure must only be allocated by realtime.library and is
- * READ-ONLY!
- }
- Type
- Conductor = Record
- cdt_Link : Node;
- cdt_Reserved0 : WORD;
- cdt_Players : MinList; { this conductor's players }
- cdt_ClockTime, { current time of this sequence }
- cdt_StartTime, { start time of this sequence }
- cdt_ExternalTime, { time from external unit }
- cdt_MaxExternalTime, { upper limit on sync'd time }
- cdt_Metronome : Integer; { MetricTime highest pri node }
- cdt_Reserved1 : WORD;
- cdt_Flags : WORD; { conductor flags }
- cdt_State : Byte; { playing or stopped }
- end;
- ConductorPtr = ^Conductor;
-
- const
- { Flag bits for Conductor.cdt_Flags }
- CONDUCTF_EXTERNAL = 1; { clock is externally driven }
- CONDUCTF_GOTTICK = 2; { received 1st external tick }
- CONDUCTF_METROSET = 4; { cdt_Metronome filled in }
- CONDUCTF_PRIVATE = 8; { conductor is private }
-
- CONDUCTB_EXTERNAL = 0;
- CONDUCTB_GOTTICK = 1;
- CONDUCTB_METROSET = 2;
- CONDUCTB_PRIVATE = 3;
-
- { constants for Conductor.cdt_State and SetConductorState() }
- CONDSTATE_STOPPED = 0; { clock is stopped }
- CONDSTATE_PAUSED = 1; { clock is paused }
- CONDSTATE_LOCATE = 2; { go to 'running' when ready }
- CONDSTATE_RUNNING = 3; { run clock NOW }
-
- { These do not actually exist as Conductor states, but are used as additional
- * arguments to SetConductorState()
- }
- CONDSTATE_METRIC = -1; { ask high node to locate }
- CONDSTATE_SHUTTLE = -2; { time changing but not running }
- CONDSTATE_LOCATE_SET = -3; { maestro done locating }
-
-
- {***************************************************************************}
-
-
- { The Player is the connection between a Conductor and an application.
- *
- * This structure must only be allocated by realtime.library and is
- * READ-ONLY!
- }
- Type
- Player = Record
- pl_Link : Node;
- pl_Reserved0,
- pl_Reserved1 : Byte;
- pl_Hook : HookPtr; { player's hook function }
- pl_Source : ConductorPtr; { pointer to parent context }
- pl_Task : TaskPtr; { task to signal for alarm }
- pl_MetricTime : Integer; { current time in app's metric }
- pl_AlarmTime : Integer; { time to wake up }
- pl_UserData : Address; { for application use }
- pl_PlayerID : WORD; { for application use }
- pl_Flags : WORD; { general Player flags }
- end;
- PlayerPtr = ^Player;
-
- const
- { Flag bits for Player.pl_Flags }
- PLAYERF_READY = 1; { player is ready to go! }
- PLAYERF_ALARMSET = 2; { alarm is set }
- PLAYERF_QUIET = 3; { a dummy player, used for sync }
- PLAYERF_CONDUCTED = 8; { give me metered time }
- PLAYERF_EXTSYNC = 16; { granted external sync }
-
- PLAYERB_READY = 0;
- PLAYERB_ALARMSET = 1;
- PLAYERB_QUIET = 2;
- PLAYERB_CONDUCTED = 3;
- PLAYERB_EXTSYNC = 4;
-
-
- {***************************************************************************}
-
-
- { Tags for CreatePlayer(), SetPlayerAttrs(), and GetPlayerAttrs() }
- PLAYER_Base = (TAG_USER+64) ;
- PLAYER_Hook = (PLAYER_Base+1) ; { set address of hook function }
- PLAYER_Name = (PLAYER_Base+2) ; { name of player }
- PLAYER_Priority = (PLAYER_Base+3) ; { priority of player }
- PLAYER_Conductor = (PLAYER_Base+4) ; { set conductor for player }
- PLAYER_Ready = (PLAYER_Base+5) ; { the "ready" flag }
- PLAYER_AlarmTime = (PLAYER_Base+12); { alarm time (sets PLAYERF_ALARMSET) }
- PLAYER_Alarm = (PLAYER_Base+13); { sets/clears PLAYERF_ALARMSET flag }
- PLAYER_AlarmSigTask = (PLAYER_Base+6) ; { task to signal for alarm/notify }
- PLAYER_AlarmSigBit = (PLAYER_Base+8) ; { signal bit for alarm (or -1) }
- PLAYER_Conducted = (PLAYER_Base+7) ; { sets/clears PLAYERF_CONDUCTED flag }
- PLAYER_Quiet = (PLAYER_Base+9) ; { don't process time thru this }
- PLAYER_UserData = (PLAYER_Base+10);
- PLAYER_ID = (PLAYER_Base+11);
- PLAYER_ExtSync = (PLAYER_Base+14); { attempt/release to ext sync }
- PLAYER_ErrorCode = (PLAYER_Base+15); { error return value }
-
-
- {***************************************************************************}
-
-
- { Method types for messages sent via a Player's hook }
- PM_TICK = 0;
- PM_STATE = 1;
- PM_POSITION = 2;
- PM_SHUTTLE = 3;
-
- Type
- { used for PM_TICK, PM_POSITION and PM_SHUTTLE methods }
- pmTime = Record
- pmt_Method : Integer; { PM_TICK, PM_POSITION, or PM_SHUTTLE }
- pmt_Time : Integer;
- end;
- pmTimePtr = ^pmTime;
-
- { used for the PM_STATE method }
- pmState = Record
- pms_Method : Integer; { PM_STATE }
- pms_OldState: Integer;
- end;
- pmStatePtr = ^pmState;
-
-
- {***************************************************************************}
-
- const
- { Possible lock types for LockRealTime() }
- RT_CONDUCTORS = 0; { conductor list }
-
-
- {***************************************************************************}
-
-
- { realtime.library error codes }
- RTE_NOMEMORY = 801; { memory allocation failed }
- RTE_NOCONDUCTOR = 802; { player needs a conductor }
- RTE_NOTIMER = 803; { timer (CIA) allocation failed }
- RTE_PLAYING = 804; { can't shuttle while playing }
-
-
- {***************************************************************************}
-
-
- { OpenLibrary("realtime.library",0) returns a pointer to this structure.
- * All fields are READ-ONLY.
- }
- Type
- RealTimeRec = Record
- rtb_LibNode : Library;
- rtb_Reserved0 : Array[0..1] of Byte;
-
- rtb_Time, { current time }
- rtb_TimeFrac : Integer; { fixed-point fraction part of time }
- rtb_Reserved1 : WORD;
- rtb_TickErr : WORD; { nanosecond error from ideal Tick }
- end; { length to real tick length }
-
- VAR RealTimeBase : ^RealTimeRec;
-
- { Actual tick length is: 1/TICK_FREQ + rtb_TickErr/1e9 }
-
- const
- RealTime_TickErr_Min = -705;
- RealTime_TickErr_Max = 705;
-
-
- {***************************************************************************}
-
-
-