Re: wow, this actually works!
Re: wow, this actually works!
- Subject: Re: wow, this actually works!
- From: Bill Stewart <email@hidden>
- Date: Wed, 29 May 2002 00:46:56 -0700
Yes ...
But its only the first call into CoreMIDI that matters....
So I was taking the code that was already done"
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) {
}
}
}
}
}
Then - at the botttow of the while loop put your thread into the wait state
and forget about it - you should be fine from then on, as you're app has
signed into CoreMIDI (with getting caught up by java's run loop mess)...
I don't think you need to make every call into CM from this thread...
Then you should be able to just do your stuff in your normal threads
My comments were trying to clear up the previous comments that you could
just do this stuff then let the thread exit - that won't work, because
CoreMIDI will have lost its run loop to call you back on when it needs to...
Bill
on 29/5/02 12:35 AM, Scott Ruda wrote:
>
Joshua Strickon <email@hidden> wrote:
>
>
> The trick that got everything to work was to put any native routine
>
> that opens
>
> or closes a midi port into a new thread.
>
>
Bill Stewart <email@hidden> wrote:
>
>
> Your thread doesn't have to do anything - you should be able to just
>
> put it
>
> into a wait state. CoreMIDI will wake it up through its run loop - then
>
> when
>
> its done its work it should just go back into wait...
>
>
>
> while (true)
>
> {
>
> synchronized (this)
>
> {
>
> wait();
>
> }
>
> }
>
>
Let me see if I've grokked this. The workaround is to do any CoreMIDI
>
call in a new Thread instead of doing it in the Java dispatch thread,
>
right? Could this then be the basic model:
>
>
public void doCoreMIDIThing() {
>
>
Thread t = new Thread(new Runnable() {
>
public void run() {
>
// do actual CoreMIDI call here...
>
}
>
});
>
t.start();
>
>
// I want the call to be synchronous, so wait until the CoreMIDI
>
call is complete
>
try { t.join(); } catch (InterruptedException ie) {}
>
}
>
>
I didn't quite understand what Bill meant when he said 'the thread
>
doesn't have to do anything'. Doesn't the new thread have to do the
>
CoreMIDI call within it's run implementation?
>
>
Scott
>
_______________________________________________
>
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.