Re: wow, this actually works! (Scott Ruda, take note :-)
Re: wow, this actually works! (Scott Ruda, take note :-)
- Subject: Re: wow, this actually works! (Scott Ruda, take note :-)
- From: Bill Stewart <email@hidden>
- Date: Tue, 28 May 2002 19:09:12 -0700
You'll need to keep this thread around...
CoreMIDI will use the run loop of the thread that you first call it on to do
the notifications, so if that thread dies, your app won't be in too healthy
a state...
We've had some rather lengthy discussions with the java team about this, and
this doesn't look like it is a problem they can fix soon, so this is
something we'll have to live with.
I'm going to do some more investigation on our end to see if I can work
around this in the CAJava side, so client's don't all have to do this...
I'll let you know
Bill
on 28/5/02 12:51 PM, Kenneth Welch wrote:
>
> The illegal monitor exception has to do with the CarbonLock. It
>
> seems that java is doing some nasty stuff once you bring up a window.
>
> The
>
> trick that got everything to work was to put any native routine that
>
> opens
>
> or closes a midi port into a new thread.
>
>
I just tried this; it is a 100% transparent and successful workaround.
>
Thank you Joshua for the info, it's very helpful!
>
>
For Scott -- if you're wondering how to implement Josh's suggestion,
>
here's what I did. Basically you make and .start() a low priority thread
>
on app launch. The thread does an infinite loop that checks a boolean
>
monitor for every group of port-related commands you might ever want to
>
execute. When the app wants to run one of those groups of commands, set
>
the corresponding boolean monitor to true; the thread will find it on
>
its next pass and run the commands. Don't forget to set the monitor back
>
to false when it's done.
>
>
for example:
>
>
public class MIDIActionThread extends Thread {
>
>
public static boolean init = false;
>
public static boolean reset = false;
>
>
public void run() {
>
while (true) {
>
if (init) {
>
try {
>
MIDIPlayback.client = new MIDIClient(new
>
CAFString("App"), null);
>
MIDIPlayback.output =
>
MIDIPlayback.client.outputPortCreate(new CAFString("App Output"));
>
MIDIPlayback.sport = MIDIDevice.getDevice(0);
>
MIDIPlayback.ports =
>
MIDIPlayback.sport.getEntity(0);
>
MIDIPlayback.synth =
>
MIDIPlayback.ports.getDestination(0);
>
init = false;
>
}
>
catch (Exception egg) {
>
}
>
}
>
if (reset) {
>
try {
>
// reset commands here
>
reset = false;
>
}
>
catch (Exception egg) {
>
}
>
}
>
}
>
}
>
>
}
>
_______________________________________________
>
coreaudio-api mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
>
Do not post admin requests to the list. They will be ignored.
mailto:email@hidden
tel: +1 408 974 4056
__________________________________________________________________________
"Thousands of years ago, cats were worshipped as gods. We have never
forgotten this."
__________________________________________________________________________
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.