revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / realtime / createplayera.c
blob7b019581f80562c918c0305cf6411680cf157c1a
1 /*
2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
3 $Id$
4 */
5 # define DEBUG 0
6 # include <aros/debug.h>
8 #include <proto/exec.h>
9 #include <proto/realtime.h>
10 #include <proto/utility.h>
11 #include <exec/memory.h>
12 #include <utility/tagitem.h>
13 #include "realtime_intern.h"
15 /*****************************************************************************
17 NAME */
18 #include <libraries/realtime.h>
20 AROS_LH1(struct Player *, CreatePlayerA,
22 /* SYNOPSIS */
24 AROS_LHA(struct TagItem *, tagList, A0),
26 /* LOCATION */
28 struct Library *, RealTimeBase, 7, RealTime)
30 /* FUNCTION
32 Create a player.
34 INPUTS
36 tagList -- pointer to an array of tags describing the player's
37 attributes or NULL.
39 TAGS
41 PLAYER_Name (STRPTR) -- The name of the player; default is no
42 name.
44 PLAYER_Hook (struct Hook *) -- Function to call every time the time
45 changes; default is none. The hook is
46 called with
48 a0 -- address of Hook structure
49 a1 -- message (see <libraries/realtime.h>)
50 a2 -- address of Player structure
52 Be aware of that the function is not
53 necessarily called TICK_FREQ times per
54 second: this is the upper limit of times
55 it may be called.
57 PLAYER_Priority (BYTE) -- The priority of the player; default is 0.
59 PLAYER_Conductor (STRPTR) -- The name of the conductor to link the
60 player to. If the conductor doesn't exist,
61 it's created automatically. Passing ~0
62 creates a private conductor.
64 PLAYER_Ready (BOOL) -- Set / clear the ready flag; default is
65 TRUE.
67 PLAYER_AlarmTime (LONG) -- Set player's alarm time; implies setting
68 the PLAYERF_ALARMSET flag.
70 PLAYER_Alarm (BOOL) -- Set / clear the PLAYERF_ALARMSET flag;
71 default is FALSE.
73 PLAYER_AlarmSigTask (struct Task *)
74 -- The task to signal when the alarm goes
75 off; default is no task. If no task is
76 specified PLAYERF_ALARMSET is turned
77 off.
79 PLAYER_AlarmSigBit (BYTE) -- Signal bit to use for the alarm or -1
80 to disable signalling; default is -1.
82 PLAYER_Quiet (BOOL) -- Specify whether this player should be
83 ignored or not; default is FALSE.
84 Generally only used by external sync
85 applications.
87 PLAYER_UserData (VOID *) -- Set pointer to user specific data;
88 default is NULL.
90 PLAYER_ID (UWORD) -- Set the player's ID; default is 0.
92 PLAYER_Conducted (BOOL) -- Set / clear the PLAYERF_CONDUCTED flag;
93 default is FALSE.
95 PLAYER_ExtSync (BOOL) -- If TRUE, this player attempts to become
96 the external sync source.
98 PLAYER_ErrorCode (LONG *) -- Optional pointer to a LONG that will
99 contain an error code if the function
100 fails. Possible error values are:
102 RTE_NOMEMORY -- memory allocation failed
103 RTE_NOTIMER -- timer allocation failed
105 RESULT
107 A pointer to a player structure or NULL if failure. In case of a failure
108 additional information may be retreived from the LONG variable pointed
109 to by PLAYER_ErrorCode if you have specified that tag.
111 NOTES
113 EXAMPLE
115 BUGS
117 SEE ALSO
119 DeletePlayer(), GetPlayerAttrsA(), SetPlayerAttrsA()
121 INTERNALS
123 ******************************************************************************/
126 AROS_LIBFUNC_INIT
128 struct Player *player = AllocMem(sizeof(struct Player),
129 MEMF_PUBLIC | MEMF_CLEAR);
130 LONG *error;
132 D(bug("Entering CreatePlayerA()\n"));
134 error = (LONG *) GetTagData(PLAYER_ErrorCode, (IPTR) NULL, tagList);
136 if (player == NULL)
138 if (error != NULL)
140 *error = RTE_NOMEMORY;
143 return NULL;
146 /* Set default values */
147 player->pl_Reserved0 = -1; /* AlarmSigBit */
148 player->pl_Flags |= PLAYERF_READY;
150 D(bug("Calling SetPlayerAttrsA()\n"));
152 if (SetPlayerAttrsA(player, tagList))
154 return player;
156 else
158 return NULL;
161 AROS_LIBFUNC_EXIT
162 } /* CreatePlayerA */