2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
6 #include <proto/utility.h>
7 #include <proto/exec.h>
9 #include "camd_intern.h"
14 # include AROS_DEBUG_H_FILE
17 /*****************************************************************************
21 AROS_LH2(BOOL
, SetMidiLinkAttrsA
,
24 AROS_LHA(struct MidiLink
*, midilink
, A0
),
25 AROS_LHA(struct TagItem
*, tags
, A1
),
28 struct CamdBase
*, CamdBase
, 16, Camd
)
31 Remind me to fill in things here later.
38 - If the midilink is not owned by yourself, please lock
39 camd to ensure it wont go away.
41 - Allthough you are able to modify midilinks owned by
42 others, please avoid it, its normally "non of your buziness",
43 and may lead to crashes and other "unexpected" behaviours.
44 However, if you have full control of the owner of the
45 midilink (f.ex when both you and the owner belongs to the
46 same probram and you are absolutely shure you know what
47 you are doing), there is no problem.
49 - Warning! If another task have locked Camd and is waiting
50 for you to finish, there will be a deadlock if you try
51 to change priority or change/set cluster.
62 *****************************************************************************/
67 struct TagItem
*tstate
=tags
;
71 int type
=midilink
->ml_Node
.ln_Type
;
72 struct MyMidiCluster
*mycluster
;
73 struct DriverData
*driverdata
=NULL
;
75 ULONG
*ErrorCode
= (ULONG
*)GetTagData(MLINK_ErrorCode
, (IPTR
) NULL
,tags
);
77 while((tag
=NextTagItem(&tstate
))){
80 midilink
->ml_Node
.ln_Name
=(char *)tag
->ti_Data
;
84 case MLINK_ChannelMask
:
85 midilink
->ml_ChannelMask
=tag
->ti_Data
;
88 midilink
->ml_EventTypeMask
=tag
->ti_Data
;
91 midilink
->ml_UserData
=(void *)tag
->ti_Data
;
94 // Not implemented because it's not used.
98 midilink
->ml_PortID
=tag
->ti_Data
;
101 midilink
->ml_Flags
|=MLF_PrivateLink
*tag
->ti_Data
;
104 mycluster
=(struct MyMidiCluster
*)midilink
->ml_Location
;
106 ObtainSemaphore(CB(CamdBase
)->CLSemaphore
);
107 if(type
==NT_USER
-MLTYPE_Receiver
){
108 ObtainSemaphore(&mycluster
->semaphore
);
111 Remove(&midilink
->ml_Node
);
112 midilink
->ml_Node
.ln_Pri
=tag
->ti_Data
;
113 if(type
==NT_USER
-MLTYPE_Receiver
){
114 Enqueue(&midilink
->ml_Location
->mcl_Receivers
,&midilink
->ml_Node
);
116 Enqueue(&midilink
->ml_Location
->mcl_Senders
,&midilink
->ml_Node
);
118 if(type
==NT_USER
-MLTYPE_Receiver
){
119 ReleaseSemaphore(&mycluster
->semaphore
);
121 ReleaseSemaphore(CB(CamdBase
)->CLSemaphore
);
123 midilink
->ml_Node
.ln_Pri
=tag
->ti_Data
;
126 case MLINK_SysExFilter
:
127 midilink
->ml_SysExFilter
.sxf_Packed
=0xffffff & tag
->ti_Data
;
129 case MLINK_SysExFilterX
:
130 midilink
->ml_SysExFilter
.sxf_Packed
=0x01000000 | tag
->ti_Data
;
133 driverdata
=AllocMem(sizeof(struct DriverData
),MEMF_ANY
|MEMF_CLEAR
|MEMF_PUBLIC
);
134 if(driverdata
==NULL
){
136 *ErrorCode
=CME_NoMem
;
141 driverdata
->Input_Treat
=Receiver_init
;
143 case MLINK_ErrorCode
:
151 clustername
= (char *) GetTagData(MLINK_Location
, (IPTR
) NULL
, tags
);
152 if(clustername
!=NULL
){
153 ObtainSemaphore(CB(CamdBase
)->CLSemaphore
);
154 if(SetClusterForLink(midilink
,clustername
,ErrorCode
,CamdBase
)==FALSE
){
157 ReleaseSemaphore(CB(CamdBase
)->CLSemaphore
);
161 if(driverdata
!=NULL
&& midilink
->ml_Location
!=NULL
){
162 driverdata
->incluster
=(struct MyMidiCluster
*)midilink
->ml_Location
;
163 midilink
->ml_ParserData
=driverdata
;
165 midilink
->ml_ParserData
=NULL
;
175 BOOL VARARGS68K
SetMidiLinkAttrs(
176 struct CamdIFace
*Self
,
177 struct MidiLink
* ml
,
182 struct TagItem
* varargs
;
183 va_startlinear(ap
, ml
);
184 varargs
= va_getlinearva(ap
, struct TagItem
*);
185 return Self
->SetMidiLinkAttrsA(