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 *****************************************************************************/
68 const struct TagItem
*tstate
=tags
;
72 int type
=midilink
->ml_Node
.ln_Type
;
73 struct MyMidiCluster
*mycluster
;
74 struct DriverData
*driverdata
=NULL
;
76 ULONG
*ErrorCode
= (ULONG
*)GetTagData(MLINK_ErrorCode
, (IPTR
) NULL
,tags
);
78 while((tag
=NextTagItem(&tstate
))){
81 midilink
->ml_Node
.ln_Name
=(char *)tag
->ti_Data
;
85 case MLINK_ChannelMask
:
86 midilink
->ml_ChannelMask
=tag
->ti_Data
;
89 midilink
->ml_EventTypeMask
=tag
->ti_Data
;
92 midilink
->ml_UserData
=(void *)tag
->ti_Data
;
95 // Not implemented because it's not used.
99 midilink
->ml_PortID
=tag
->ti_Data
;
102 midilink
->ml_Flags
|=MLF_PrivateLink
*tag
->ti_Data
;
105 mycluster
=(struct MyMidiCluster
*)midilink
->ml_Location
;
107 ObtainSemaphore(CB(CamdBase
)->CLSemaphore
);
108 if(type
==NT_USER
-MLTYPE_Receiver
){
109 ObtainSemaphore(&mycluster
->semaphore
);
112 Remove(&midilink
->ml_Node
);
113 midilink
->ml_Node
.ln_Pri
=tag
->ti_Data
;
114 if(type
==NT_USER
-MLTYPE_Receiver
){
115 Enqueue(&midilink
->ml_Location
->mcl_Receivers
,&midilink
->ml_Node
);
117 Enqueue(&midilink
->ml_Location
->mcl_Senders
,&midilink
->ml_Node
);
119 if(type
==NT_USER
-MLTYPE_Receiver
){
120 ReleaseSemaphore(&mycluster
->semaphore
);
122 ReleaseSemaphore(CB(CamdBase
)->CLSemaphore
);
124 midilink
->ml_Node
.ln_Pri
=tag
->ti_Data
;
127 case MLINK_SysExFilter
:
128 midilink
->ml_SysExFilter
.sxf_Packed
=0xffffff & tag
->ti_Data
;
130 case MLINK_SysExFilterX
:
131 midilink
->ml_SysExFilter
.sxf_Packed
=0x01000000 | tag
->ti_Data
;
134 driverdata
=AllocMem(sizeof(struct DriverData
),MEMF_ANY
|MEMF_CLEAR
|MEMF_PUBLIC
);
135 if(driverdata
==NULL
){
137 *ErrorCode
=CME_NoMem
;
142 driverdata
->Input_Treat
=Receiver_init
;
144 case MLINK_ErrorCode
:
152 clustername
= (char *) GetTagData(MLINK_Location
, (IPTR
) NULL
, tags
);
153 if(clustername
!=NULL
){
154 ObtainSemaphore(CB(CamdBase
)->CLSemaphore
);
155 if(SetClusterForLink(midilink
,clustername
,ErrorCode
,CamdBase
)==FALSE
){
158 ReleaseSemaphore(CB(CamdBase
)->CLSemaphore
);
162 if(driverdata
!=NULL
&& midilink
->ml_Location
!=NULL
){
163 driverdata
->incluster
=(struct MyMidiCluster
*)midilink
->ml_Location
;
164 midilink
->ml_ParserData
=driverdata
;
166 midilink
->ml_ParserData
=NULL
;
176 BOOL VARARGS68K
SetMidiLinkAttrs(
177 struct CamdIFace
*Self
,
178 struct MidiLink
* ml
,
183 struct TagItem
* varargs
;
184 va_startlinear(ap
, ml
);
185 varargs
= va_getlinearva(ap
, struct TagItem
*);
186 return Self
->SetMidiLinkAttrsA(