wow, this actually works! (Scott Ruda, take note :-)
wow, this actually works! (Scott Ruda, take note :-)
- Subject: wow, this actually works! (Scott Ruda, take note :-)
- From: Kenneth Welch <email@hidden>
- Date: Tue, 28 May 2002 15:51:10 -0400
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.