revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / camd / goodputmidi.c
blob35570db9cff56c6b3250678d393050d270a1bee1
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <proto/exec.h>
11 #include "camd_intern.h"
15 /*****************************************************************************
17 NAME */
19 AROS_LH3(APTR, GoodPutMidi,
21 /* SYNOPSIS */
22 AROS_LHA(struct MidiLink *, midilink, A0),
23 AROS_LHA(ULONG, msg, D0),
24 AROS_LHA(ULONG, maxbuff, D1),
26 /* LOCATION */
27 struct CamdBase *, CamdBase, 39, Camd)
29 /* FUNCTION
30 This is a private function, and will probably be obsolete. Please don`t use.
32 INPUTS
34 RESULT
35 NULL if success, driverdata if not.
37 NOTES
39 EXAMPLE
41 BUGS
43 SEE ALSO
44 PutMidi(), PutMidiMsg(), Midi2Driver()
46 INTERNALS
48 HISTORY
50 2001-07-14 ksvalast first created
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
56 int len=GetMsgLen(msg);
57 struct Node *node;
58 struct DriverData *driverdata=NULL;
59 struct MyMidiCluster *mycluster=(struct MyMidiCluster *)midilink->ml_Location;
60 struct MyMidiMessage2 msg2;
61 struct MidiLink *midilink2;
62 struct MyMidiNode *mymidinode;
64 if(len==3) return NULL; //Illegal message.
66 ObtainSemaphoreShared(&mycluster->semaphore);
68 if( ! (IsListEmpty(&mycluster->cluster.mcl_Receivers))){
70 msg2.status=msg>>24;
71 msg2.data1=0x7f&(msg>>16);
72 msg2.data2=0x7f&(msg>>8);
73 msg2.len=(len&3)+1;
75 node=mycluster->cluster.mcl_Receivers.lh_Head;
77 while(node->ln_Succ!=NULL){
78 if(node->ln_Type==NT_USER-MLTYPE_NTypes){
79 driverdata=Midi2Driver_internal((struct DriverData *)node,msg,maxbuff)?NULL:(struct DriverData *)node;
80 }else{
81 midilink2=(struct MidiLink *)node;
82 mymidinode=(struct MyMidiNode *)midilink2->ml_MidiNode;
83 ObtainSemaphore(&mymidinode->receiversemaphore);
84 PutMidi2Link(midilink2,&msg2,*mymidinode->midinode.mi_TimeStamp);
85 ReleaseSemaphore(&mymidinode->receiversemaphore);
86 if(driverdata!=NULL){
87 driverdata=Midi2Driver_internal(driverdata,msg,maxbuff)?NULL:driverdata;
90 node=node->ln_Succ;
94 ReleaseSemaphore(&mycluster->semaphore);
96 return driverdata;
99 AROS_LIBFUNC_EXIT