[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] MIDI questions was: [sc-users] MIDIClient.init not working



Hi Marije, and all !

first concerning the OS X issue, currently prDisposeMIDIClient (in SC_CoreMIDI.cpp) does not call midiCleanUp() (it just dispose the client - leaving a dangling state for the port pointers and report an error even if the client was not inited...)

i think it should call directly midiCleanUp() to leave it in a clean state and not report an error if the client was not inited. (Or may be report an error only if the func fails to dispose the client (wich would mean just changing the midiCleanUp signature ...ect...) but not if there is no MIDIClient)

this will also fix the current problem reported in os x.

-----------------------------------------------------

also currently MIDIClient.disposeClient (on OSX) does not reset its 'initialized' classvar, leaving it as 'true' if it was disposed. Wich mean if you call MIDIIn.connectAll it won't re-create and re- connect sc to midi. To re-connect correctly MIDI seems you have to (after a MIDIClient.disposeClient):

MIDIClient.init(numIns, numOuts); // reset the MIDIClient
MIDIIn.connect(inIndex, outIndex); // re-connect MIDIIn ...ect...

Marije, is it the same behaviour for Linux ? If you do not plan to modify soon the midi code for Linux, we can apply the patch to fix the os x problem ?

any opinion greatly appreciated on this ?

best,
charles

proposition below + patch file attached:
-----------------------------------------------------


Index: source/lang/LangPrimSource/SC_CoreMIDI.cpp
===================================================================
--- source/lang/LangPrimSource/SC_CoreMIDI.cpp	(revision 8169)
+++ source/lang/LangPrimSource/SC_CoreMIDI.cpp	(working copy)
@@ -310,7 +310,7 @@
     }
 }

-void midiCleanUp();
+int midiCleanUp();

 int initMIDI(int numIn, int numOut)
 {
@@ -371,22 +371,34 @@
     return errNone;
 }

-void midiCleanUp()
-{
+int midiCleanUp()
+{	
+	/*
+	 * do not catch errors when disposing ports
+ * disposing the midi client will normally dispose the ports attached to it
+	 * but clean up the pointers in case
+	 */
     for (int i=0; i<gNumMIDIOutPorts; ++i) {
         MIDIPortDispose(gMIDIOutPort[i]);
+		gMIDIOutPort[i] = 0;
     }
 	gNumMIDIOutPorts = 0;
 	
     for (int i=0; i<gNumMIDIInPorts; ++i) {
         MIDIPortDispose(gMIDIInPort[i]);
+		gMIDIInPort[i] = 0;
     }
 	gNumMIDIInPorts = 0;
 	
     if (gMIDIClient) {
-        MIDIClientDispose(gMIDIClient);
+		if( MIDIClientDispose(gMIDIClient) ) {
+			post( "Error: failed to dispose MIDIClient\n" );
+			return errFailed;
+		}
 		gMIDIClient = 0;
     }
+	
+	return errNone;
 }


@@ -594,7 +606,7 @@
 	err = slotIntVal(b, &numIn);
 	if (err) return errWrongType;
 	
-	err = slotIntVal(c, &numOut);
+	err = slotIntVal(c, &numOut);
 	if (err) return errWrongType;
 	
 	return initMIDI(numIn, numOut);
@@ -602,15 +614,7 @@
 int prDisposeMIDIClient(VMGlobals *g, int numArgsPushed);
 int prDisposeMIDIClient(VMGlobals *g, int numArgsPushed)
 {
-    PyrSlot *a;
-    a = g->sp - 1;
-    OSStatus err = MIDIClientDispose(gMIDIClient);
-    if (err) {
-        post("error could not dispose MIDIClient \n");
-        return errFailed;
-    }
-    return errNone;	
-
+	return midiCleanUp();
 }
 int prRestartMIDI(VMGlobals *g, int numArgsPushed);
 int prRestartMIDI(VMGlobals *g, int numArgsPushed)




Attachment: SCCoreMIDI.diff
Description: Binary data




Le 16 déc. 08 à 18:31, Wouter Snoei a écrit :

Hi Marije,

commenting this.disposeClient; out fixes the problem indeed. any chance this will be fixed in the svn version?

cheers & thanks,
Wouter

Op 8 dec 2008, om 14:29 heeft juan sebastián lach lau het volgende geschreven:

Thanks Marije, that did it.
js
On Dec 8, 2008, at 3:17:47, nescivi wrote:

Hiho,

I did make a change in there, that was not tested yet on OSX.

Could you try commenting out
			this.disposeClient;
on line 24 in build/SCClassLibrary/Common/Control/MIDIOut.sc

and report back whether that solves the problem?

sincerely,
Marije


On Sun, Dec 7, 2008 at 3:31 PM, juan sebastián lach lau
<lachjs@xxxxxxxxx> wrote:


Hi all,
There seems to be a bug when initializing midi. First, the error was
'primitive not bound' (_InitMIDI). After updating and doing a clean
recompile the error is 'primitve failed'. Its osx 10.5.5, ppc. (svn rev
8053)
Does it happen to others? I haven't changed my setup in weeks and it worked
fine a few days ago.
Any help much appreciated.
js


error could not dispose MIDIClient
ERROR: Primitive '_DisposeMIDIClient' failed.
Failed.
RECEIVER:
class MIDIClient (052C6E90) {
instance variables [19]
 name : Symbol 'MIDIClient'
 nextclass : class MIDIClockOut (051000D0)
 superclass : Symbol 'Object'
 subclasses : nil
 methods : nil
 instVarNames : nil
 classVarNames : instance of SymbolArray (052C6F50, size=3, set=1)
 iprototype : nil
 cprototype : instance of Array (052C6F90, size=3, set=2)
 constNames : nil
 constValues : nil
 instanceFormat : Integer 0
 instanceFlags : Integer 0
 classIndex : Integer 704
 classFlags : Integer 0
 maxSubclassIndex : Integer 704
 filenameSymbol : Symbol
'/Users/jslach/SuperCollider3/build/SCClassLibrary/Common/Control/ MIDIOut.sc'
 charPos : Integer 213
 classVarIndex : Integer 158
}
CALL STACK:
MethodError:reportError   04BB9DA0
arg this = <instance of PrimitiveFailedError>
Nil:handleError   04BB9D40
arg this = nil
arg error = <instance of PrimitiveFailedError>
Thread:handleError   04BB9CE0
arg this = <instance of Thread>
arg error = <instance of PrimitiveFailedError>
Object:throw   04BB9C80
arg this = <instance of PrimitiveFailedError>
Object:primitiveFailed   04BB9AA0
arg this = class MIDIClient
Meta_MIDIClient:init   04BB9A40
arg this = class MIDIClient
arg inports = 2
arg outports = 2
Interpreter:interpretPrintCmdLine   04F69830
arg this = <instance of Interpreter>
var res = nil
var func = <instance of Function>
var code = "MIDIClient.init"
Process:interpretPrintCmdLine   04BB99E0
arg this = <instance of Main>



_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/