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:
36
package/cpp/MutableRawBuffer.cpp
Normal file
36
package/cpp/MutableRawBuffer.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// MutableRawBuffer.cpp
|
||||
// VisionCamera
|
||||
//
|
||||
// Created by Marc Rousavy on 17.01.24.
|
||||
// Copyright © 2024 mrousavy. All rights reserved.
|
||||
//
|
||||
|
||||
#include "MutableRawBuffer.h"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace vision {
|
||||
|
||||
MutableRawBuffer::MutableRawBuffer(uint8_t* data, size_t size, std::function<void()> cleanup)
|
||||
: _data(data), _size(size), _cleanup(std::move(cleanup)) {}
|
||||
|
||||
MutableRawBuffer::MutableRawBuffer(size_t size) {
|
||||
_size = size;
|
||||
_data = (uint8_t*)malloc(size * sizeof(uint8_t));
|
||||
_cleanup = [=]() { free(_data); };
|
||||
}
|
||||
|
||||
MutableRawBuffer::~MutableRawBuffer() {
|
||||
_cleanup();
|
||||
}
|
||||
|
||||
size_t MutableRawBuffer::size() const {
|
||||
return _size;
|
||||
}
|
||||
|
||||
uint8_t* MutableRawBuffer::data() {
|
||||
return _data;
|
||||
}
|
||||
|
||||
} // namespace vision
|
||||
Reference in New Issue
Block a user