1 #ifndef LIBRARIES_REALTIME_H
2 #define LIBRARIES_REALTIME_H
5 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
8 Desc: Includes for realtime.library
14 #include <exec/types.h>
18 #include <exec/lists.h>
21 #ifndef EXEC_LIBRARIES_H
22 #include <exec/libraries.h>
25 #ifndef UTILITY_TAGITEM_H
26 #include <utility/tagitem.h>
29 #ifndef UTILITY_HOOKS_H
30 #include <utility/hooks.h>
33 #ifndef EXEC_SEMAPHORES_H
34 #include <exec/semaphores.h>
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
50 struct MinList cdt_Players
; /* The players linked to this
54 ULONG cdt_ExternalTime
; /* Time from external synchronizer */
55 ULONG cdt_MaxExternalTime
;
56 ULONG cdt_Metronome
; /* Current musical time */
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 */
66 #define CONDUCTB_EXTERNAL 0 /* Clock is externally driven */
67 #define CONDUCTB_GOTTICK 1 /* First tick from external source
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
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
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
109 LONG pl_AlarmTime
; /* Time for alarm */
112 UWORD pl_Flags
; /* Player flags; see below */
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.
121 #define PLAYERB_CONDUCTED 3
122 #define PLAYERB_EXTSYNC 4 /* This player is the external
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 /*****************************************************************************/
137 enum { PLAYER_Base
= TAG_USER
+ 64,
155 /*****************************************************************************/
158 /* Hook message method types */
162 #define PM_POSITION 2
165 /* Structure used by the methods PM_TICK, PM_POSITION and PM_SHUTTLE. */
169 STACKED ULONG pmt_Method
; /* The actual method */
170 STACKED ULONG pmt_Time
;
173 /* Structure used by the method PM_STATE. */
177 STACKED ULONG pms_Method
; /* The actual method */
178 STACKED ULONG pms_OldState
; /* The state previous to the state
183 /*****************************************************************************/
186 enum { RT_CONDUCTORS
= 0, RT_MAXLOCK
};
189 /* Note that all fields are READ ONLY! */
193 struct Library rtb_LibNode
;
194 UBYTE rtb_Reserved0
[2];
203 /* These two are hardware dependent... */
204 #define RealTime_TickErr_Min -705
205 #define RealTime_TickErr_Max 705
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 */