1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| JNIEXPORT jobjectArray JNICALL Java_SetSampleRate_GetAPIDevicesInfos (JNIEnv *env, jclass cls, jint size)
{
jobjectArray result;
PaHostApiIndex i;
const PaHostApiInfo * info;
jclass PaHostApiInfoCls = env->FindClass("PaHostApiInfo");
if (PaHostApiInfoCls == NULL) return NULL; /* exception thrown */
result = env->NewObjectArray((jsize) size, PaHostApiInfoCls, NULL);
if (result == NULL) return NULL; /* out of memory error thrown */
jmethodID constructorID = env->GetMethodID(PaHostApiInfoCls, "PaHostApiInfo", "(IILjava/lang/String;III)V");
for (i=0; i<size; i++)
{
info = Pa_GetHostApiInfo(i);
jobject jInfo = env->NewObject(PaHostApiInfoCls, constructorID, (jint) info->structVersion,
(jint) info->type, env->NewStringUTF(info->name), (jint) info->deviceCount,
(jint) info->defaultInputDevice, (jint) info->defaultOutputDevice);
if (jInfo == NULL) return NULL; /* exception thrown */
env->SetObjectArrayElement(result, i, jInfo);
env->DeleteLocalRef(jInfo);
}
return result;
} |
Partager