2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
7 #include <proto/utility.h>
8 #include <proto/exec.h>
10 #include "camd_intern.h"
13 /*****************************************************************************
17 AROS_LH2(BOOL
, SetMidiAttrsA
,
20 AROS_LHA(struct MidiNode
*, midinode
, A0
),
21 AROS_LHA(struct TagItem
*, tags
, A1
),
24 struct CamdBase
*, CamdBase
, 9, Camd
)
29 tagList -- pointer to an array of tags describing the player's
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.
67 TRUE if everything went okey, FALSE if not. Errorcode
68 is put in an ULONG pointed to by the MIDI_ErrorCode tag,
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.
93 *****************************************************************************/
98 struct TagItem
*tstate
=tags
;
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
))){
112 midinode
->mi_Node
.ln_Name
=(char *)tag
->ti_Data
;
114 case MIDI_SignalTask
:
115 midinode
->mi_SigTask
=(struct Task
*)tag
->ti_Data
;
118 midinode
->mi_ReceiveHook
=(struct Hook
*)tag
->ti_Data
;
121 midinode
->mi_ParticipantHook
=(struct Hook
*)tag
->ti_Data
;
123 case MIDI_RecvSignal
:
124 midinode
->mi_ReceiveSigBit
=(BYTE
)tag
->ti_Data
;
126 case MIDI_PartSignal
:
127 midinode
->mi_ParticipantSigBit
=(BYTE
)tag
->ti_Data
;
130 temp
=AllocVec(sizeof(MidiMsg
)*(tag
->ti_Data
+1),MEMF_ANY
| MEMF_PUBLIC
);
133 *ErrorCode
=CME_NoMem
;
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
);
151 temp2
=AllocVec(tag
->ti_Data
+1,MEMF_ANY
|MEMF_PUBLIC
);
154 *ErrorCode
=CME_NoMem
;
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
);
175 midinode
->mi_TimeStamp
=(ULONG
*)tag
->ti_Data
;
178 midinode
->mi_ErrFilter
=(UBYTE
)tag
->ti_Data
;
180 case MIDI_ClientType
:
181 midinode
->mi_ClientType
=(UWORD
)tag
->ti_Data
;
184 midinode
->mi_Image
=(struct Image
*)tag
->ti_Data
;
191 ReleaseSemaphore(CB(CamdBase
)->CLSemaphore
);
201 BOOL VARARGS68K
SetMidiAttrs(
202 struct CamdIFace
*Self
,
203 struct MidiNode
* mi
,
208 struct TagItem
* varargs
;
209 va_startlinear(ap
, mi
);
210 varargs
= va_getlinearva(ap
, struct TagItem
*);
211 return SetMidiAttrsA(Self
,