Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / camd / setmidilinkattrsa.c
blob5822999fd03868dd33e5eba1d901f7ce17e7c799
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/utility.h>
7 #include <proto/exec.h>
9 #include "camd_intern.h"
11 # undef DEBUG
12 # define DEBUG 1
13 #ifndef __amigaos4__
14 # include AROS_DEBUG_H_FILE
15 #endif
17 /*****************************************************************************
19 NAME */
21 AROS_LH2(BOOL, SetMidiLinkAttrsA,
23 /* SYNOPSIS */
24 AROS_LHA(struct MidiLink *, midilink, A0),
25 AROS_LHA(struct TagItem *, tags, A1),
27 /* LOCATION */
28 struct CamdBase *, CamdBase, 16, Camd)
30 /* FUNCTION
31 Remind me to fill in things here later.
33 INPUTS
35 RESULT
37 NOTES
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.
53 EXAMPLE
55 BUGS
57 SEE ALSO
58 GetMidiLinkAttrsA()
60 INTERNALS
62 *****************************************************************************/
64 AROS_LIBFUNC_INIT
66 struct TagItem *tag;
68 const struct TagItem *tstate=tags;
70 BOOL ret=TRUE;
71 char *clustername;
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))){
79 switch(tag->ti_Tag){
80 case MLINK_Name:
81 midilink->ml_Node.ln_Name=(char *)tag->ti_Data;
82 break;
83 case MLINK_Location:
84 break;
85 case MLINK_ChannelMask:
86 midilink->ml_ChannelMask=tag->ti_Data;
87 break;
88 case MLINK_EventMask:
89 midilink->ml_EventTypeMask=tag->ti_Data;
90 break;
91 case MLINK_UserData:
92 midilink->ml_UserData=(void *)tag->ti_Data;
93 break;
94 case MLINK_Comment:
95 // Not implemented because it's not used.
96 // if(midilink
97 break;
98 case MLINK_PortID:
99 midilink->ml_PortID=tag->ti_Data;
100 break;
101 case MLINK_Private:
102 midilink->ml_Flags|=MLF_PrivateLink*tag->ti_Data;
103 break;
104 case MLINK_Priority:
105 mycluster=(struct MyMidiCluster *)midilink->ml_Location;
106 if(mycluster!=NULL){
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);
116 }else{
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);
123 }else{
124 midilink->ml_Node.ln_Pri=tag->ti_Data;
126 break;
127 case MLINK_SysExFilter:
128 midilink->ml_SysExFilter.sxf_Packed=0xffffff & tag->ti_Data;
129 break;
130 case MLINK_SysExFilterX:
131 midilink->ml_SysExFilter.sxf_Packed=0x01000000 | tag->ti_Data;
132 break;
133 case MLINK_Parse:
134 driverdata=AllocMem(sizeof(struct DriverData),MEMF_ANY|MEMF_CLEAR|MEMF_PUBLIC);
135 if(driverdata==NULL){
136 if(ErrorCode!=NULL){
137 *ErrorCode=CME_NoMem;
139 ret=FALSE;
140 break;
142 driverdata->Input_Treat=Receiver_init;
143 break;
144 case MLINK_ErrorCode:
145 break;
146 default:
147 break;
151 if(ret!=FALSE){
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){
156 ret=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;
165 }else{
166 midilink->ml_ParserData=NULL;
169 return ret;
171 AROS_LIBFUNC_EXIT
174 #ifdef __amigaos4__
175 #include <stdarg.h>
176 BOOL VARARGS68K SetMidiLinkAttrs(
177 struct CamdIFace *Self,
178 struct MidiLink * ml,
182 va_list ap;
183 struct TagItem * varargs;
184 va_startlinear(ap, ml);
185 varargs = va_getlinearva(ap, struct TagItem *);
186 return Self->SetMidiLinkAttrsA(
188 varargs);
190 #endif