You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
oniStreamReadFrame returns a ByteBuffer pointing to volatile memory. To fix this I returned a byte[] by changing
jobject buffer = env->NewDirectByteBuffer(pOniFrame->data, pOniFrame->dataSize);
fieldID = env->GetFieldID(videoFrameRefCls, "mData", "Ljava/nio/ByteBuffer;");
env->SetObjectField(videoFrameRefObj,fieldID, buffer);
to
jbyteArray buffer = env->NewByteArray(pOniFrame->dataSize);
env->SetByteArrayRegion(buffer, 0, pOniFrame->dataSize, (jbyte*) pOniFrame->data);
fieldID = env->GetFieldID(videoFrameRefCls, "mData", "[B");
env->SetObjectField(videoFrameRefObj, fieldID, buffer);
and made the mData field a byte[] in java.
The end oniStreamReadFrame calls oniFrameRelease. Calling this function again from java causes a fatal error. The finalize function in java for the VideoFrameRef class calls oniFrameRelease resulting in a fatal error when the garbage collector comes through, assuming it bothers to call the finalize function. To fix this I commented out a line as seen below.
JNIEnv g_env;
JNIEXPORT void JNICALL Java_org_openni_NativeMethods_oniFrameRelease
(JNIEnv *, jclass, jlong frame) {
//oniFrameRelease((OniFrame)frame);
}
I also commented out oniFrameAddRef in java
private VideoFrameRef(long handle) {
//NativeMethods.oniFrameAddRef(handle);
mFrameHandle = handle;
}
but i'm not sure if that was necessary.
The text was updated successfully, but these errors were encountered:
oniStreamReadFrame returns a ByteBuffer pointing to volatile memory. To fix this I returned a byte[] by changing
jobject buffer = env->NewDirectByteBuffer(pOniFrame->data, pOniFrame->dataSize);
fieldID = env->GetFieldID(videoFrameRefCls, "mData", "Ljava/nio/ByteBuffer;");
env->SetObjectField(videoFrameRefObj,fieldID, buffer);
to
jbyteArray buffer = env->NewByteArray(pOniFrame->dataSize);
env->SetByteArrayRegion(buffer, 0, pOniFrame->dataSize, (jbyte*) pOniFrame->data);
fieldID = env->GetFieldID(videoFrameRefCls, "mData", "[B");
env->SetObjectField(videoFrameRefObj, fieldID, buffer);
and made the mData field a byte[] in java.
The end oniStreamReadFrame calls oniFrameRelease. Calling this function again from java causes a fatal error. The finalize function in java for the VideoFrameRef class calls oniFrameRelease resulting in a fatal error when the garbage collector comes through, assuming it bothers to call the finalize function. To fix this I commented out a line as seen below.
JNIEnv g_env;
JNIEXPORT void JNICALL Java_org_openni_NativeMethods_oniFrameRelease
(JNIEnv *, jclass, jlong frame) {
//oniFrameRelease((OniFrame)frame);
}
I also commented out oniFrameAddRef in java
private VideoFrameRef(long handle) {
//NativeMethods.oniFrameAddRef(handle);
mFrameHandle = handle;
}
but i'm not sure if that was necessary.
The text was updated successfully, but these errors were encountered: