Re: Calling Java code from an audio or Midi callback
Re: Calling Java code from an audio or Midi callback
- Subject: Re: Calling Java code from an audio or Midi callback
- From: Bill Stewart <email@hidden>
- Date: Mon, 15 Apr 2002 10:56:45 -0700
The CAJava code will dispatch into your Java code from the callback in the
thread that it is running on.
The only overhead incurred in this is the overhead of crossing the context
into Java - we use variants of the JNI calls env->CallIntMethodV (I
think...)
Taking a lock is a "bad idea" in the I/O threads - I you end up waiting
you'll miss the I/O cycle.
Aside from the special priveleges in terms of runtime scheduling the real
time threads are just threads and there's nothing "special" about them, so
you can just call your Java code directly...
You could use the CAJava callbacks directly and have them do this work for
you - then your Java code will just run when the I/O cycle fires.
Bill
on 15/4/02 1:59 AM, Stephane Letz wrote:
>
Hi,
>
>
I just discovered that the CoreAudio audio or Midi callback can be used in
>
Java and was wondering how this was implemented. It seems that the Java
>
code runs directly inside the real-time thread.
>
>
We need to do the same thing (calling back Java code inside a realtime IO
>
proc). I tried to make a "suspensive" native call from the Java side that
>
is "resumed" from the IO callback using a condition variable (
>
pthread_cond_wait and pthread_cond_signal API)
>
The calling Java thread is also made real-time using thread_policy_set.
>
Thus I have 2 real-time threads running, and if works quite well.
>
>
I was wondering if the need for the second real-time thread could be
>
avoided, by calling back the Java code directly inside the Core Midi IO
>
proc.
>
>
- is is safe to callback the JVM?
>
- if yes any ideas of how this can be done?
>
>
Thanks for any advice.
>
>
Stephane Letz
>
>
>
>
>
>
Grame: Centre National de creation musicale
>
9, Rue du Garet
>
69001 Lyon
>
Tel: 04-72-07-37-00
>
Fax: 04-72-07-37-01
>
Web: www.grame.fr
>
_______________________________________________
>
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.