grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / camd / setmidiattrsa.c
blob9c6799f9c9bce2363ff07b79d974431991a56b91
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
7 #include <proto/utility.h>
8 #include <proto/exec.h>
10 #include "camd_intern.h"
13 /*****************************************************************************
15 NAME */
17 AROS_LH2(BOOL, SetMidiAttrsA,
19 /* SYNOPSIS */
20 AROS_LHA(struct MidiNode *, midinode, A0),
21 AROS_LHA(struct TagItem *, tags, A1),
23 /* LOCATION */
24 struct CamdBase *, CamdBase, 9, Camd)
26 /* FUNCTION
28 INPUTS
29 tagList -- pointer to an array of tags describing the player's
30 attributes or NULL.
32 TAGS
33 MIDI_Name (STRPTR) -- The name of the midinode; default is NULL or a pointer to a string.
35 MIDI_SignalTask (struct Task *) -- Task to signal whenever a midimessage is arriving to the node;
36 default is the task of the caller of this function. (FindTask(NULL))
38 MIDI_RecvHook (struct Hook *) -- Function to call whenever a midimessage is arriving to the node.
39 You should get the midimessage as the first argument in the function,
40 however, that has not yet been implemented. Default is NULL.
42 MIDI_PartHook (struct Hook *) -- Don't really know what this one is for. Have to check amigos-autodocs.
43 It does not currently do anything.
45 MIDI_RecvSignal (BYTE) -- Signal bit to use when signalling a task whenever a midimessage is
46 arriving at the node, or -1 to disable signalling. Default is -1.
48 MIDI_PartSignal (BYTE) -- Signal bit to use when signalling a task when..... Default is -1.
50 MIDI_MsgQueue (ULONG) -- Number of messages the messagequeue is able to hold.
52 MIDI_TimeStamp (ULONG *) -- Pointer to an ULONG value which value is copied directly into the timestamp
53 attribute in midimessages whenever a new message is received at the node.
56 MIDI_ErrFilter (UBYTE) -- Filters out the errors you don't want to see.
59 MIDI_ClientType (UWORD) -- What sort of application you that owns this node.
61 MIDI_Image (struct Image *) -- Pointer to an image representing this node.
63 MIDI_ErrorCode (ULONG *) -- Pointer to an ULONG which will be set if something went wrong.
66 RESULT
67 TRUE if everything went okey, FALSE if not. Errorcode
68 is put in an ULONG pointed to by the MIDI_ErrorCode tag,
69 if supplied.
71 NOTES
72 - If the midinode is not owned by yourself, please lock
73 camd to ensure it wont go away.
75 - Allthough you are able to modify midinodes owned by
76 others, please avoid it, its normally "non of your buziness",
77 and may lead to crashes and other "unexpected" behaviors.
78 However, if you have full control of the owner of the
79 midinode (f.ex when both you and the owner belongs to the
80 same probram and you are absolutely shure you know what
81 you are doing), there is no problem.
84 EXAMPLE
86 BUGS
88 SEE ALSO
89 GetMidiAttrsA()
91 INTERNALS
93 *****************************************************************************/
95 AROS_LIBFUNC_INIT
97 struct TagItem *tag;
98 struct TagItem *tstate=tags;
99 MidiMsg *temp;
100 UBYTE *temp2;
101 BOOL ret=TRUE;
103 struct MyMidiNode *mymidinode=(struct MyMidiNode *)midinode;
105 ULONG *ErrorCode = (ULONG *) GetTagData(MIDI_ErrorCode, (IPTR) NULL, tags);
107 ObtainSemaphore(CB(CamdBase)->CLSemaphore);
109 while((tag=NextTagItem(&tstate))){
110 switch(tag->ti_Tag){
111 case MIDI_Name:
112 midinode->mi_Node.ln_Name=(char *)tag->ti_Data;
113 break;
114 case MIDI_SignalTask:
115 midinode->mi_SigTask=(struct Task *)tag->ti_Data;
116 break;
117 case MIDI_RecvHook:
118 midinode->mi_ReceiveHook=(struct Hook *)tag->ti_Data;
119 break;
120 case MIDI_PartHook:
121 midinode->mi_ParticipantHook=(struct Hook *)tag->ti_Data;
122 break;
123 case MIDI_RecvSignal:
124 midinode->mi_ReceiveSigBit=(BYTE)tag->ti_Data;
125 break;
126 case MIDI_PartSignal:
127 midinode->mi_ParticipantSigBit=(BYTE)tag->ti_Data;
128 break;
129 case MIDI_MsgQueue:
130 temp=AllocVec(sizeof(MidiMsg)*(tag->ti_Data+1),MEMF_ANY | MEMF_PUBLIC);
131 if(temp==NULL){
132 if(ErrorCode!=NULL){
133 *ErrorCode=CME_NoMem;
135 ret=FALSE;
136 break;
138 ObtainSemaphore(&mymidinode->receiversemaphore);
139 midinode->mi_MsgQueueSize=(ULONG)tag->ti_Data;
140 if(mymidinode->in_start!=NULL){
141 FreeVec(mymidinode->in_start);
143 mymidinode->in_start=temp;
144 mymidinode->in_end=mymidinode->in_start+midinode->mi_MsgQueueSize;
145 mymidinode->unpicked=0;
146 mymidinode->in_curr=mymidinode->in_start;
147 mymidinode->in_curr_get=mymidinode->in_start;
148 ReleaseSemaphore(&mymidinode->receiversemaphore);
149 break;
150 case MIDI_SysExSize:
151 temp2=AllocVec(tag->ti_Data+1,MEMF_ANY|MEMF_PUBLIC);
152 if(temp2==NULL){
153 if(ErrorCode!=NULL){
154 *ErrorCode=CME_NoMem;
156 ret=FALSE;
157 break;
159 ReleaseSemaphore(CB(CamdBase)->CLSemaphore);
160 ObtainSemaphore(&mymidinode->sysexsemaphore2);
161 ObtainSemaphore(&mymidinode->sysexsemaphore);
162 midinode->mi_SysExQueueSize=tag->ti_Data;
163 if(mymidinode->sysex_start!=NULL){
164 FreeVec(mymidinode->sysex_start);
166 mymidinode->sysex_start=temp2;
167 mymidinode->sysex_write=mymidinode->sysex_start;
168 mymidinode->sysex_end=mymidinode->sysex_start+midinode->mi_SysExQueueSize;
169 mymidinode->sysex_read=mymidinode->sysex_start;
170 ReleaseSemaphore(&mymidinode->sysexsemaphore2);
171 ReleaseSemaphore(&mymidinode->sysexsemaphore);
172 ObtainSemaphore(CB(CamdBase)->CLSemaphore);
173 break;
174 case MIDI_TimeStamp:
175 midinode->mi_TimeStamp=(ULONG *)tag->ti_Data;
176 break;
177 case MIDI_ErrFilter:
178 midinode->mi_ErrFilter=(UBYTE)tag->ti_Data;
179 break;
180 case MIDI_ClientType:
181 midinode->mi_ClientType=(UWORD)tag->ti_Data;
182 break;
183 case MIDI_Image:
184 midinode->mi_Image=(struct Image *)tag->ti_Data;
185 break;
186 default:
187 break;
191 ReleaseSemaphore(CB(CamdBase)->CLSemaphore);
193 return ret;
196 AROS_LIBFUNC_EXIT
199 #ifdef __amigaos4__
200 #include <stdarg.h>
201 BOOL VARARGS68K SetMidiAttrs(
202 struct CamdIFace *Self,
203 struct MidiNode * mi,
207 va_list ap;
208 struct TagItem * varargs;
209 va_startlinear(ap, mi);
210 varargs = va_getlinearva(ap, struct TagItem *);
211 return SetMidiAttrsA(Self,
213 varargs);
215 #endif