1 #ifndef LIBRARIES_REALTIME_H
2 #define LIBRARIES_REALTIME_H
5 Copyright © 1995-2001, 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>
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
48 struct MinList cdt_Players
; /* The players linked to this
52 ULONG cdt_ExternalTime
; /* Time from external synchronizer */
53 ULONG cdt_MaxExternalTime
;
54 ULONG cdt_Metronome
; /* Current musical time */
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 */
64 #define CONDUCTB_EXTERNAL 0 /* Clock is externally driven */
65 #define CONDUCTB_GOTTICK 1 /* First tick from external source
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
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
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
107 LONG pl_AlarmTime
; /* Time for alarm */
110 UWORD pl_Flags
; /* Player flags; see below */
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.
119 #define PLAYERB_CONDUCTED 3
120 #define PLAYERB_EXTSYNC 4 /* This player is the external
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 /*****************************************************************************/
135 enum { PLAYER_Base
= TAG_USER
+ 64,
153 /*****************************************************************************/
156 /* Hook message method types */
160 #define PM_POSITION 2
163 /* Structure used by the methods PM_TICK, PM_POSITION and PM_SHUTTLE. */
167 ULONG pmt_Method
; /* The actual method */
171 /* Structure used by the method PM_STATE. */
175 ULONG pms_Method
; /* The actual method */
176 ULONG pms_OldState
; /* The state previous to the state
181 /*****************************************************************************/
184 enum { RT_CONDUCTORS
= 0, RT_MAXLOCK
};
187 /* Note that all fields are READ ONLY! */
191 struct Library rtb_LibNode
;
192 UBYTE rtb_Reserved0
[2];
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
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 */