revert between 56095 -> 55830 in arch
[AROS.git] / compiler / include / libraries / realtime.h
blobb5f5a593c9ddeb8f551a3b9da7ff1d5e36254593
1 #ifndef LIBRARIES_REALTIME_H
2 #define LIBRARIES_REALTIME_H
4 /*
5 Copyright © 1995-2016, 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
37 /* The actual length of a tick is: 1/TICK_FREQ + rtb_TickErr * 1e-9 */
38 #define TICK_FREQ 1200
40 /* A conductor is an abstraction that represent a group of applications
41 that want to be syncronized. */
43 /* This structure may ONLY be allocated by realtime.library and it's
44 READ ONLY! */
46 struct Conductor
48 struct Node cdt_Link;
49 UWORD cdt_Reserved0;
50 struct MinList cdt_Players; /* The players linked to this
51 conductor */
52 ULONG cdt_ClockTime;
53 ULONG cdt_StartTime;
54 ULONG cdt_ExternalTime; /* Time from external synchronizer */
55 ULONG cdt_MaxExternalTime;
56 ULONG cdt_Metronome; /* Current musical time */
57 UWORD cdt_Reserved1;
58 UWORD cdt_Flags; /* Conductor flags; see below */
59 UBYTE cdt_State; /* Conductor state; see below */
60 struct Task *cdt_Barrier; /* Private, don't touch */
61 struct SignalSemaphore cdt_Lock; /* Private, don't touch */
64 /* Conductor flags */
66 #define CONDUCTB_EXTERNAL 0 /* Clock is externally driven */
67 #define CONDUCTB_GOTTICK 1 /* First tick from external source
68 received */
69 #define CONDUCTB_METROSET 2 /* Metronome defined */
70 #define CONDUCTB_PRIVATE 3 /* This is a private conductor */
72 #define CONDUCTF_EXTERNAL (1 << CONDUCTB_EXTERNAL)
73 #define CONDUCTF_GOTTICK (1 << CONDUCTB_GOTTICK)
74 #define CONDUCTF_METROSET (1 << CONDUCTB_METROSET)
75 #define CONDUCTF_PRIVATE (1 << CONDUCTB_PRIVATE)
77 /* Conductor states */
79 #define CONDSTATE_STOPPED 0 /* Clock is stopped */
80 #define CONDSTATE_PAUSED 1 /* Clock is paused */
81 #define CONDSTATE_LOCATE 2 /* Switch to RUNNING when ready */
82 #define CONDSTATE_RUNNING 3 /* Clock is running */
84 /* Argument to SetConductorState() -- these are not real conductor states */
86 #define CONDSTATE_METRIC -1 /* Ask high node to locate */
87 #define CONDSTATE_SHUTTLE -2 /* Time changing without clock
88 running. */
89 #define CONDSTATE_LOCATE_SET -3 /* Done locating */
92 /*****************************************************************************/
95 /* The Player structure is the link between an application and a conductor.
96 This structure may ONLY be allocated by realtime.library and is READ
97 ONLY! */
99 struct Player
101 struct Node pl_Link;
102 BYTE pl_Reserved0;
103 BYTE pl_Reserved1;
104 struct Hook *pl_Hook;
105 struct Conductor *pl_Source; /* This player's conductor */
106 struct Task *pl_Task; /* Task to signal for alarm */
107 LONG pl_MetricTime; /* Current time in players
108 metric */
109 LONG pl_AlarmTime; /* Time for alarm */
110 void *pl_UserData;
111 UWORD pl_PlayerID;
112 UWORD pl_Flags; /* Player flags; see below */
115 /* Player flags */
117 #define PLAYERB_READY 0
118 #define PLAYERB_ALARMSET 1 /* The alarm is set */
119 #define PLAYERB_QUIET 2 /* This player is used for sync.
120 only */
121 #define PLAYERB_CONDUCTED 3
122 #define PLAYERB_EXTSYNC 4 /* This player is the external
123 synchronizer */
125 #define PLAYERF_READY (1 << PLAYERB_READY)
126 #define PLAYERF_ALARMSET (1 << PLAYERB_ALARMSET)
127 #define PLAYERF_QUIET (1 << PLAYERB_QUIET)
128 #define PLAYERF_CONDUCTED (1 << PLAYERB_CONDUCTED)
129 #define PLAYERF_EXTSYNC (1 << PLAYERB_EXTSYNC)
132 /*****************************************************************************/
135 /* Tags */
137 enum { PLAYER_Base = TAG_USER + 64,
138 PLAYER_Hook,
139 PLAYER_Name,
140 PLAYER_Priority,
141 PLAYER_Conductor,
142 PLAYER_Ready,
143 PLAYER_AlarmSigTask,
144 PLAYER_Conducted,
145 PLAYER_AlarmSigBit,
146 PLAYER_Quiet,
147 PLAYER_UserData,
148 PLAYER_ID,
149 PLAYER_AlarmTime,
150 PLAYER_Alarm,
151 PLAYER_ExtSync,
152 PLAYER_ErrorCode };
155 /*****************************************************************************/
158 /* Hook message method types */
160 #define PM_TICK 0
161 #define PM_STATE 1
162 #define PM_POSITION 2
163 #define PM_SHUTTLE 3
165 /* Structure used by the methods PM_TICK, PM_POSITION and PM_SHUTTLE. */
167 struct pmTime
169 STACKED ULONG pmt_Method; /* The actual method */
170 STACKED ULONG pmt_Time;
173 /* Structure used by the method PM_STATE. */
175 struct pmState
177 STACKED ULONG pms_Method; /* The actual method */
178 STACKED ULONG pms_OldState; /* The state previous to the state
179 change */
183 /*****************************************************************************/
186 enum { RT_CONDUCTORS = 0, RT_MAXLOCK };
189 /* Note that all fields are READ ONLY! */
191 struct RealTimeBase
193 struct Library rtb_LibNode;
194 UBYTE rtb_Reserved0[2];
196 ULONG rtb_Time;
197 ULONG rtb_TimeFrac;
198 UWORD rtb_Reserved1;
199 WORD rtb_TickErr;
203 /* These two are hardware dependent... */
204 #define RealTime_TickErr_Min -705
205 #define RealTime_TickErr_Max 705
208 /* Error codes */
210 enum { RTE_NOMEMORY = 801, /* Allocation of memory failed */
211 RTE_NOCONDUCTOR, /* Player has no conductor */
212 RTE_NOTIMER, /* Allocation of timer failed */
213 RTE_PLAYING }; /* Unable to shuttle while playing */
217 #endif /* LIBRARIES_REALTIME_H */