2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
5 #include <proto/exec.h>
6 #include <proto/utility.h>
7 #include <proto/realtime.h>
8 #include <exec/lists.h>
9 #include "realtime_intern.h"
11 /*****************************************************************************
15 #include <utility/tagitem.h>
16 #include <libraries/realtime.h>
18 AROS_LH2(BOOL
, SetPlayerAttrsA
,
22 AROS_LHA(struct Player
*, player
, A0
),
23 AROS_LHA(struct TagItem
*, tagList
, A1
),
27 struct Library
*, RealTimeBase
, 9, RealTime
)
31 Sets the attributes of a player. An attribute not specified in the array
32 of tags is unchanged after this procedure.
36 player -- The player the attributes of which to set.
37 tagList -- Pointer to an array of tags describing the player's
42 The same tags as for CreatePlayerA().
46 Success/failure indicator. If failure, then, in case the PLAYER_ErrorCode
47 is provided, more information can be obtained via that pointer.
57 DeletePlayer(), GetPlayerAttrs(), SetPlayerAttrs()
61 ******************************************************************************/
67 struct TagItem
*tag
, *tl
= tagList
;
70 error
= (LONG
*)GetTagData(PLAYER_ErrorCode
, NULL
, tl
);
72 while ((tag
= NextTagItem(&tl
)) != NULL
)
77 player
->pl_Link
.ln_Name
= (APTR
)tag
->ti_Data
;
81 player
->pl_Hook
= (struct Hook
*)tag
->ti_Data
;
85 player
->pl_Link
.ln_Pri
= (BYTE
)tag
->ti_Data
;
87 if (player
->pl_Link
.ln_Succ
!= NULL
)
89 /* If this node has been (is) inserted before, then remove it
90 and put it in the right place. */
92 /* Is this player attached to a conductor? */
93 if (player
->pl_Source
!= NULL
)
95 lock
= LockRealTime(RT_CONDUCTORS
);
96 Remove((struct Node
*)player
);
97 Enqueue((struct List
*)&player
->pl_Source
->cdt_Players
,
98 (struct Node
*)player
);
105 *error
= RTE_NOCONDUCTOR
;
114 case PLAYER_Conductor
:
115 if (tag
->ti_Data
== NULL
)
117 player
->pl_Source
= NULL
;
121 struct Conductor
*conductor
;
123 lock
= LockRealTime(RT_CONDUCTORS
);
124 conductor
= FindConductor((STRPTR
)tag
->ti_Data
);
125 UnlockRealTime(lock
);
127 if (conductor
== NULL
)
131 *error
= RTE_NOCONDUCTOR
;
141 if ((BOOL
)tag
->ti_Data
)
143 struct Conductor
*conductor
= player
->pl_Source
;
145 player
->pl_Flags
|= PLAYERF_READY
;
147 if (conductor
!= NULL
)
149 ObtainSemaphoreShared(&conductor
->cdt_Lock
);
151 if (conductor
->cdt_Barrier
!= NULL
)
153 Signal(conductor
->cdt_Barrier
, SIGF_SINGLE
);
156 ReleaseSemaphore(&conductor
->cdt_Lock
);
161 player
->pl_Flags
&= ~PLAYERF_READY
;
166 case PLAYER_AlarmTime
:
167 player
->pl_Flags
|= PLAYERF_ALARMSET
;
168 player
->pl_AlarmTime
= (LONG
)tag
->ti_Data
;
172 if ((BOOL
)tag
->ti_Data
)
174 player
->pl_Flags
|= PLAYERF_ALARMSET
;
178 player
->pl_Flags
&= ~PLAYERF_ALARMSET
;
183 case PLAYER_AlarmSigTask
:
184 if ((struct Task
*)tag
->ti_Data
== NULL
)
186 player
->pl_Flags
&= ~PLAYERF_ALARMSET
;
189 player
->pl_Task
= (struct Task
*)tag
->ti_Data
;
192 case PLAYER_AlarmSigBit
:
193 if ((BYTE
)tag
->ti_Data
== -1)
195 player
->pl_Flags
&= ~PLAYERF_ALARMSET
;
198 /* We could use player->pl_Link.ln_Type here */
199 player
->pl_Reserved0
= (BYTE
)tag
->ti_Data
; /* NOTE! */
203 if ((BOOL
)tag
->ti_Data
)
205 player
->pl_Flags
|= PLAYERF_QUIET
;
209 player
->pl_Flags
&= ~PLAYERF_QUIET
;
214 case PLAYER_UserData
:
215 player
->pl_UserData
= (APTR
)tag
->ti_Data
;
219 player
->pl_PlayerID
= (UWORD
)tag
->ti_Data
;
222 case PLAYER_Conducted
:
223 if ((BOOL
)tag
->ti_Data
)
225 player
->pl_Flags
|= PLAYERF_CONDUCTED
;
229 player
->pl_Flags
&= ~PLAYERF_CONDUCTED
;
235 lock
= LockRealTime(RT_CONDUCTORS
);
237 if ((BOOL
)tag
->ti_Data
)
239 if (player
->pl_Source
->cdt_Flags
& CONDUCTF_EXTERNAL
)
241 /* Only one external synchronizer at a time, please */
242 UnlockRealTime(lock
);
247 player
->pl_Source
->cdt_Flags
|= CONDUCTF_EXTERNAL
;
248 player
->pl_Flags
|= PLAYERF_EXTSYNC
;
252 /* If this player was the external synchronizer, we
254 if (player
->pl_Flags
& PLAYERF_EXTSYNC
)
256 player
->pl_Source
->cdt_Flags
&= ~CONDUCTF_EXTERNAL
;
257 player
->pl_Source
->cdt_Flags
&= ~CONDUCTF_GOTTICK
;
260 player
->pl_Flags
&= ~PLAYERF_EXTSYNC
;
263 UnlockRealTime(lock
);
269 /* Consistency checks */
270 if (player
->pl_Task
== NULL
)
272 player
->pl_Flags
&= ~PLAYERF_ALARMSET
;
278 } /* SetPlayerAttrsA */