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(), GetPlayerAttrsA()
61 ******************************************************************************/
67 const struct TagItem
*tl
= tagList
;
71 error
= (LONG
*)GetTagData(PLAYER_ErrorCode
, NULL
, tl
);
73 while ((tag
= NextTagItem(&tl
)) != NULL
)
78 player
->pl_Link
.ln_Name
= (APTR
)tag
->ti_Data
;
82 player
->pl_Hook
= (struct Hook
*)tag
->ti_Data
;
86 player
->pl_Link
.ln_Pri
= (BYTE
)tag
->ti_Data
;
88 if (player
->pl_Link
.ln_Succ
!= NULL
)
90 /* If this node has been (is) inserted before, then remove it
91 and put it in the right place. */
93 /* Is this player attached to a conductor? */
94 if (player
->pl_Source
!= NULL
)
96 lock
= LockRealTime(RT_CONDUCTORS
);
97 Remove((struct Node
*)player
);
98 Enqueue((struct List
*)&player
->pl_Source
->cdt_Players
,
99 (struct Node
*)player
);
100 UnlockRealTime(lock
);
106 *error
= RTE_NOCONDUCTOR
;
115 case PLAYER_Conductor
:
116 if (tag
->ti_Data
== NULL
)
118 player
->pl_Source
= NULL
;
122 struct Conductor
*conductor
;
124 lock
= LockRealTime(RT_CONDUCTORS
);
125 conductor
= FindConductor((STRPTR
)tag
->ti_Data
);
126 UnlockRealTime(lock
);
128 if (conductor
== NULL
)
132 *error
= RTE_NOCONDUCTOR
;
142 if ((BOOL
)tag
->ti_Data
)
144 struct Conductor
*conductor
= player
->pl_Source
;
146 player
->pl_Flags
|= PLAYERF_READY
;
148 if (conductor
!= NULL
)
150 ObtainSemaphoreShared(&conductor
->cdt_Lock
);
152 if (conductor
->cdt_Barrier
!= NULL
)
154 Signal(conductor
->cdt_Barrier
, SIGF_SINGLE
);
157 ReleaseSemaphore(&conductor
->cdt_Lock
);
162 player
->pl_Flags
&= ~PLAYERF_READY
;
167 case PLAYER_AlarmTime
:
168 player
->pl_Flags
|= PLAYERF_ALARMSET
;
169 player
->pl_AlarmTime
= (LONG
)tag
->ti_Data
;
173 if ((BOOL
)tag
->ti_Data
)
175 player
->pl_Flags
|= PLAYERF_ALARMSET
;
179 player
->pl_Flags
&= ~PLAYERF_ALARMSET
;
184 case PLAYER_AlarmSigTask
:
185 if ((struct Task
*)tag
->ti_Data
== NULL
)
187 player
->pl_Flags
&= ~PLAYERF_ALARMSET
;
190 player
->pl_Task
= (struct Task
*)tag
->ti_Data
;
193 case PLAYER_AlarmSigBit
:
194 if ((BYTE
)tag
->ti_Data
== -1)
196 player
->pl_Flags
&= ~PLAYERF_ALARMSET
;
199 /* We could use player->pl_Link.ln_Type here */
200 player
->pl_Reserved0
= (BYTE
)tag
->ti_Data
; /* NOTE! */
204 if ((BOOL
)tag
->ti_Data
)
206 player
->pl_Flags
|= PLAYERF_QUIET
;
210 player
->pl_Flags
&= ~PLAYERF_QUIET
;
215 case PLAYER_UserData
:
216 player
->pl_UserData
= (APTR
)tag
->ti_Data
;
220 player
->pl_PlayerID
= (UWORD
)tag
->ti_Data
;
223 case PLAYER_Conducted
:
224 if ((BOOL
)tag
->ti_Data
)
226 player
->pl_Flags
|= PLAYERF_CONDUCTED
;
230 player
->pl_Flags
&= ~PLAYERF_CONDUCTED
;
236 lock
= LockRealTime(RT_CONDUCTORS
);
238 if ((BOOL
)tag
->ti_Data
)
240 if (player
->pl_Source
->cdt_Flags
& CONDUCTF_EXTERNAL
)
242 /* Only one external synchronizer at a time, please */
243 UnlockRealTime(lock
);
248 player
->pl_Source
->cdt_Flags
|= CONDUCTF_EXTERNAL
;
249 player
->pl_Flags
|= PLAYERF_EXTSYNC
;
253 /* If this player was the external synchronizer, we
255 if (player
->pl_Flags
& PLAYERF_EXTSYNC
)
257 player
->pl_Source
->cdt_Flags
&= ~CONDUCTF_EXTERNAL
;
258 player
->pl_Source
->cdt_Flags
&= ~CONDUCTF_GOTTICK
;
261 player
->pl_Flags
&= ~PLAYERF_EXTSYNC
;
264 UnlockRealTime(lock
);
270 /* Consistency checks */
271 if (player
->pl_Task
== NULL
)
273 player
->pl_Flags
&= ~PLAYERF_ALARMSET
;
279 } /* SetPlayerAttrsA */