feat: Use JSI's ArrayBuffer instead of TypedArray (#2408)
* feat: Use JSI's `ArrayBuffer` instead of `TypedArray` * fix: Fix move memory * feat: Implement iOS * Format * Update JSIJNIConversion.cpp * fix: Fix Android `toArrayBuffer` and other * Catch FP call errors * Update return type * Use `CPU_READ_OFTEN` flag as well * CPU flag * Run destructors under `jni::ThreadScope` * Update FrameProcessorPluginHostObject.cpp * fix: Fix `toArrayBuffer()` crash * Update Frame.ts
This commit is contained in:
33
package/android/src/main/cpp/MutableJByteBuffer.cpp
Normal file
33
package/android/src/main/cpp/MutableJByteBuffer.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// Created by Marc Rousavy on 17.01.24.
|
||||
//
|
||||
|
||||
#include "MutableJByteBuffer.h"
|
||||
|
||||
#include <fbjni/ByteBuffer.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
||||
namespace vision {
|
||||
|
||||
MutableJByteBuffer::MutableJByteBuffer(jni::alias_ref<jni::JByteBuffer> byteBuffer) {
|
||||
_byteBuffer = jni::make_global(byteBuffer);
|
||||
}
|
||||
|
||||
MutableJByteBuffer::~MutableJByteBuffer() noexcept {
|
||||
jni::ThreadScope::WithClassLoader([&] { _byteBuffer.reset(); });
|
||||
}
|
||||
|
||||
uint8_t* MutableJByteBuffer::data() {
|
||||
return _byteBuffer->getDirectBytes();
|
||||
}
|
||||
|
||||
size_t MutableJByteBuffer::size() const {
|
||||
return _byteBuffer->getDirectSize();
|
||||
}
|
||||
|
||||
jni::global_ref<jni::JByteBuffer> MutableJByteBuffer::getByteBuffer() {
|
||||
return _byteBuffer;
|
||||
}
|
||||
|
||||
} // namespace vision
|
||||
Reference in New Issue
Block a user