2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
10 #include <proto/exec.h>
11 #include <proto/camd.h>
12 #include <proto/utility.h>
14 #include "camd_intern.h"
18 BOOL
InitCamd(struct CamdIFace
*ICamd
){
19 CAMD_LIBBASE_DECL(struct CamdBase
*,CamdBase
)
21 BOOL
InitCamd(struct CamdBase
*CamdBase
){
23 struct FileInfoBlock fib
;
27 CB(CamdBase
)->CLSemaphore
=AllocMem(sizeof(struct SignalSemaphore
),MEMF_ANY
|MEMF_CLEAR
|MEMF_PUBLIC
);
28 if(CB(CamdBase
)->CLSemaphore
==NULL
){
31 InitSemaphore(CB(CamdBase
)->CLSemaphore
);
33 NEWLIST(&CB(CamdBase
)->mymidinodes
);
34 NEWLIST(&CB(CamdBase
)->midiclusters
);
35 NEWLIST(&CB(CamdBase
)->clusnotifynodes
);
37 NEWLIST(CB(CamdBase
)->mymidinodes
);
38 NEWLIST(CB(CamdBase
)->midiclusters
);
39 NEWLIST(CB(CamdBase
)->clusnotifynodes
);
41 if(InitCamdTimer()==FALSE
) return FALSE
;
42 lock
=Lock("devs:Midi",ACCESS_READ
);
46 if(Examine(lock
,&fib
)==FALSE
){
50 while(ExNext(lock
,&fib
)!=FALSE
){
51 mysprintf(CamdBase
,temp
,"devs:Midi/%s",fib
.fib_FileName
);
53 LoadDriver(temp
,ICamd
);
55 LoadDriver(temp
,CamdBase
);
63 void UninitCamd(struct CamdIFace
*ICamd
){
64 CAMD_LIBBASE_DECL(struct CamdBase
*,CamdBase
)
66 void UninitCamd(struct CamdBase
*CamdBase
){
68 struct Drivers
*driver
=CB(CamdBase
)->drivers
,*temp2
;
69 struct Node
*node
,*temp
;
70 struct MidiCluster
*midicluster
;
71 struct DriverData
*driverdata
;
73 if( ! IsListEmpty(&CB(CamdBase
)->midiclusters
)){
74 node
=CB(CamdBase
)->midiclusters
.lh_Head
;
75 while(node
->ln_Succ
!=NULL
){
77 midicluster
=(struct MidiCluster
*)node
;
78 driverdata
=FindSenderDriverInCluster(midicluster
);
80 driverdata
=FindReceiverDriverInCluster(midicluster
);
83 if(driverdata
->isInOpen
==TRUE
|| driverdata
->isOutOpen
==TRUE
){
84 driverdata
->isInOpen
=FALSE
;
85 driverdata
->isOutOpen
=FALSE
;
86 CloseDriver(driverdata
,CamdBase
);
89 RemoveCluster((struct MidiCluster
*)node
,CamdBase
); //Clients should have do this, but..
97 (*driver
->mididevicedata
->Expunge
)();
98 FreeDriverData(driver
,CamdBase
);
99 CloseMidiDevice(driver
->mididevicedata
);
103 if(CB(CamdBase
)->CLSemaphore
!=NULL
)
104 FreeMem(CB(CamdBase
)->CLSemaphore
,sizeof(struct SignalSemaphore
));