2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
9 #include <proto/exec.h>
10 #include <proto/dos.h>
12 #include "camd_intern.h"
15 /*****************************************************************************
19 AROS_LH2(void, PutSysEx
,
22 AROS_LHA(struct MidiLink
*, midilink
, A0
),
23 AROS_LHA(UBYTE
*, buffer
, A1
),
26 struct CamdBase
*, CamdBase
, 26, Camd
)
29 Distributes a SysEx message. First sends the message to the hardware
30 and all midinodes connected to the midilinks cluster, then waits
31 for the complete message to be sent to the hardware, if any. If
32 a midinodes sysex-buffer is to small to carry the message, it will
33 not be sent. If the buffer is big enough, but there is not enough
34 room, a sysex-full-error will be set to the node. The message is
35 sent to hardware regardless of transmit buffer size.
38 midilink - pointer to link.
39 buffer - message to send, must start with 0xf0 and end with 0xf7.
40 No bytes higher than 0x7f are allowed in the message.
56 2001-01-12 ksvalast first created
58 *****************************************************************************/
63 struct DriverData
*driverdata
=NULL
;
64 struct MyMidiCluster
*mycluster
=(struct MyMidiCluster
*)midilink
->ml_Location
;
65 BOOL driversuccess
=TRUE
;
68 ObtainSemaphoreShared(&mycluster
->semaphore
);
70 if( ! (IsListEmpty(&midilink
->ml_Location
->mcl_Receivers
))){
72 node
=midilink
->ml_Location
->mcl_Receivers
.lh_Head
;
74 while(node
->ln_Succ
!=NULL
){
75 if(node
->ln_Type
==NT_USER
-MLTYPE_NTypes
){
77 driverdata
=(struct DriverData
*)node
;
78 ObtainSemaphore(&driverdata
->sysexsemaphore
);
80 driverdata
->buffer_sx
=buffer
;
81 driverdata
->buffercurrsend_sx
=0;
82 driverdata
->issending_sx
=1;
84 driversuccess
=SysEx2Driver(driverdata
,buffer
);
88 while(PutSysEx2Link((struct MidiLink
*)node
,*buffer2
)==TRUE
){
97 if(driversuccess
==FALSE
){
98 while(SysEx2Driver(driverdata
,buffer
)==FALSE
) CamdWait();
101 // Not a very good way to wait for the data to be sent, but it should
102 // hopefully quite seldom be very important.
103 while(driverdata
->issending_sx
!=0) CamdWait();
105 ReleaseSemaphore(&driverdata
->sysexsemaphore
);
109 ReleaseSemaphore(&mycluster
->semaphore
);