fix: Make HardwareBuffers compile optionally (opt-out in minSdkVersion <26) (#1910)

* fix: Make HardwareBuffers compile optionally

* chore: Format C++ code

* fix: Fix if
This commit is contained in:
Marc Rousavy
2023-10-03 13:18:41 +02:00
committed by GitHub
parent 83c0cdb030
commit 8d90dcc476
3 changed files with 13 additions and 4 deletions

View File

@@ -85,6 +85,7 @@ jsi::Value FrameHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pr
if (name == "toArrayBuffer") {
jsi::HostFunctionType toArrayBuffer = [=](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args,
size_t count) -> jsi::Value {
#if __ANDROID_API__ >= 26
AHardwareBuffer* hardwareBuffer = this->frame->getHardwareBuffer();
AHardwareBuffer_Desc bufferDescription;
@@ -120,6 +121,9 @@ jsi::Value FrameHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pr
AHardwareBuffer_release(hardwareBuffer);
return arrayBuffer;
#else
throw jsi::JSError(runtime, "Frame.toArrayBuffer() is only available if minSdkVersion is set to 26 or higher!");
#endif
};
return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "toArrayBuffer"), 0, toArrayBuffer);
}