added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / compiler / include / libraries / realtime.h
blobaad8d6ba4cbd7ec2ef8bda182ed35fd6126e52e1
1 #ifndef LIBRARIES_REALTIME_H
2 #define LIBRARIES_REALTIME_H
4 /*
5 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Includes for realtime.library
9 Lang: English
13 #ifndef EXEC_TYPES_H
14 #include <exec/types.h>
15 #endif
17 #ifndef EXEC_LISTS_H
18 #include <exec/lists.h>
19 #endif
21 #ifndef EXEC_LIBRARIES_H
22 #include <exec/libraries.h>
23 #endif
25 #ifndef UTILITY_TAGITEM_H
26 #include <utility/tagitem.h>
27 #endif
29 #ifndef UTILITY_HOOKS_H
30 #include <utility/hooks.h>
31 #endif
33 #ifndef EXEC_SEMAPHORES_H
34 #include <exec/semaphores.h>
35 #endif
38 /* A conductor is an abstraction that represent a group of applications
39 that want to be syncronized. */
41 /* This structure may ONLY be allocated by realtime.library and it's
42 READ ONLY! */
44 struct Conductor
46 struct Node cdt_Link;
47 UWORD cdt_Reserved0;
48 struct MinList cdt_Players; /* The players linked to this
49 conductor */
50 ULONG cdt_ClockTime;
51 ULONG cdt_StartTime;
52 ULONG cdt_ExternalTime; /* Time from external synchronizer */
53 ULONG cdt_MaxExternalTime;
54 ULONG cdt_Metronome; /* Current musical time */
55 UWORD cdt_Reserved1;
56 UWORD cdt_Flags; /* Conductor flags; see below */
57 UBYTE cdt_State; /* Conductor state; see below */
58 struct Task *cdt_Barrier; /* Private, don't touch */
59 struct SignalSemaphore cdt_Lock; /* Private, don't touch */
62 /* Conductor flags */
64 #define CONDUCTB_EXTERNAL 0 /* Clock is externally driven */
65 #define CONDUCTB_GOTTICK 1 /* First tick from external source
66 received */
67 #define CONDUCTB_METROSET 2 /* Metronome defined */
68 #define CONDUCTB_PRIVATE 3 /* This is a private conductor */
70 #define CONDUCTF_EXTERNAL (1 << CONDUCTB_EXTERNAL)
71 #define CONDUCTF_GOTTICK (1 << CONDUCTB_GOTTICK)
72 #define CONDUCTF_METROSET (1 << CONDUCTB_METROSET)
73 #define CONDUCTF_PRIVATE (1 << CONDUCTB_PRIVATE)
75 /* Conductor states */
77 #define CONDSTATE_STOPPED 0 /* Clock is stopped */
78 #define CONDSTATE_PAUSED 1 /* Clock is paused */
79 #define CONDSTATE_LOCATE 2 /* Switch to RUNNING when ready */
80 #define CONDSTATE_RUNNING 3 /* Clock is running */
82 /* Argument to SetConductorState() -- these are not real conductor states */
84 #define CONDSTATE_METRIC -1 /* Ask high node to locate */
85 #define CONDSTATE_SHUTTLE -2 /* Time changing without clock
86 running. */
87 #define CONDSTATE_LOCATE_SET -3 /* Done locating */
90 /*****************************************************************************/
93 /* The Player structure is the link between an application and a conductor.
94 This structure may ONLY be allocated by realtime.library and is READ
95 ONLY! */
97 struct Player
99 struct Node pl_Link;
100 BYTE pl_Reserved0;
101 BYTE pl_Reserved1;
102 struct Hook *pl_Hook;
103 struct Conductor *pl_Source; /* This player's conductor */
104 struct Task *pl_Task; /* Task to signal for alarm */
105 LONG pl_MetricTime; /* Current time in players
106 metric */
107 LONG pl_AlarmTime; /* Time for alarm */
108 void *pl_UserData;
109 UWORD pl_PlayerID;
110 UWORD pl_Flags; /* Player flags; see below */
113 /* Player flags */
115 #define PLAYERB_READY 0
116 #define PLAYERB_ALARMSET 1 /* The alarm is set */
117 #define PLAYERB_QUIET 2 /* This player is used for sync.
118 only */
119 #define PLAYERB_CONDUCTED 3
120 #define PLAYERB_EXTSYNC 4 /* This player is the external
121 synchronizer */
123 #define PLAYERF_READY (1 << PLAYERB_READY)
124 #define PLAYERF_ALARMSET (1 << PLAYERB_ALARMSET)
125 #define PLAYERF_QUIET (1 << PLAYERB_QUIET)
126 #define PLAYERF_CONDUCTED (1 << PLAYERB_CONDUCTED)
127 #define PLAYERF_EXTSYNC (1 << PLAYERB_EXTSYNC)
130 /*****************************************************************************/
133 /* Tags */
135 enum { PLAYER_Base = TAG_USER + 64,
136 PLAYER_Hook,
137 PLAYER_Name,
138 PLAYER_Priority,
139 PLAYER_Conductor,
140 PLAYER_Ready,
141 PLAYER_AlarmSigTask,
142 PLAYER_Conducted,
143 PLAYER_AlarmSigBit,
144 PLAYER_Quiet,
145 PLAYER_UserData,
146 PLAYER_ID,
147 PLAYER_AlarmTime,
148 PLAYER_Alarm,
149 PLAYER_ExtSync,
150 PLAYER_ErrorCode };
153 /*****************************************************************************/
156 /* Hook message method types */
158 #define PM_TICK 0
159 #define PM_STATE 1
160 #define PM_POSITION 2
161 #define PM_SHUTTLE 3
163 /* Structure used by the methods PM_TICK, PM_POSITION and PM_SHUTTLE. */
165 struct pmTime
167 ULONG pmt_Method; /* The actual method */
168 ULONG pmt_Time;
171 /* Structure used by the method PM_STATE. */
173 struct pmState
175 ULONG pms_Method; /* The actual method */
176 ULONG pms_OldState; /* The state previous to the state
177 change */
181 /*****************************************************************************/
184 enum { RT_CONDUCTORS = 0, RT_MAXLOCK };
187 /* Note that all fields are READ ONLY! */
189 struct RealTimeBase
191 struct Library rtb_LibNode;
192 UBYTE rtb_Reserved0[2];
194 ULONG rtb_Time;
195 ULONG rtb_TimeFrac;
196 UWORD rtb_Reserved1;
197 WORD rtb_TickErr;
200 /* The actual length of a tick is: 1/TICK_FREQ + rtb_TickErr * 1e-9 */
202 /* These two are hardware dependent... */
203 #define RealTime_TickErr_Min -705
204 #define RealTime_TickErr_Max 705
207 /* Error codes */
209 enum { RTE_NOMEMORY = 801, /* Allocation of memory failed */
210 RTE_NOCONDUCTOR, /* Player has no conductor */
211 RTE_NOTIMER, /* Allocation of timer failed */
212 RTE_PLAYING }; /* Unable to shuttle while playing */
216 #endif /* LIBRARIES_REALTIME_H */