Skip to content

Commit 3f47076

Browse files
committed
refactor: moved key function to base audio context ho
1 parent 7bc81ca commit 3f47076

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

.github/actions/spelling/allow.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ audiodocs
4141
Doxygen
4242
mjs
4343
UMD
44+
audioapi

packages/custom-node-generator/templates/basic/shared/NativeAudioProcessingModule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <iostream>
44
#include <functional>
55
#include <memory>
6-
#include <audioapi/HostObjects/AudioContextHostObject.h>
6+
#include <audioapi/HostObjects/BaseAudioContextHostObject.h>
77
#include "MyProcessorNode.h"
88

99
namespace facebook::react {
@@ -23,7 +23,7 @@ jsi::Function NativeAudioProcessingModule::createInstaller(jsi::Runtime &runtime
2323
0,
2424
[](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *args, size_t count) {
2525
auto object = args[0].getObject(runtime);
26-
auto context = object.getHostObject<audioapi::AudioContextHostObject>(runtime);
26+
auto context = object.getHostObject<audioapi::BaseAudioContextHostObject>(runtime);
2727
if (context != nullptr) {
2828
auto node = std::make_shared<audioapi::MyProcessorNode>(context->context_.get());
2929
auto nodeHostObject = std::make_shared<audioapi::MyProcessorNodeHostObject>(node);

packages/react-native-audio-api/common/cpp/audioapi/HostObjects/AudioContextHostObject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class AudioContextHostObject : public BaseAudioContextHostObject {
2424
JSI_EXPORT_FUNCTION(AudioContextHostObject, suspend));
2525
}
2626

27-
~AudioContextHostObject() override;
28-
2927
JSI_HOST_FUNCTION(close) {
3028
auto promise = promiseVendor_->createPromise([this](std::shared_ptr<Promise> promise) {
3129
std::thread([this, promise = std::move(promise)]() {
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#include <audioapi/HostObjects/AudioContextHostObject.h>
1+
#include <audioapi/HostObjects/BaseAudioContextHostObject.h>
22

33
// Explicitly define destructors here, as they to exist in order to act as a
44
// "key function" for the audio classes - this allow for RTTI to work
55
// properly across dynamic library boundaries (i.e. dynamic_cast that is used by
66
// isHostObject method), android specific issue
77
namespace audioapi {
8-
AudioContextHostObject::~AudioContextHostObject() = default;
8+
BaseAudioContextHostObject::~BaseAudioContextHostObject() = default;
99
}

packages/react-native-audio-api/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class BaseAudioContextHostObject : public JsiHostObject {
5353
JSI_EXPORT_FUNCTION(BaseAudioContextHostObject, decodePCMAudioDataInBase64));
5454
}
5555

56+
~BaseAudioContextHostObject() override;
57+
5658
JSI_PROPERTY_GETTER(destination) {
5759
auto destination = std::make_shared<AudioDestinationNodeHostObject>(
5860
context_->getDestination());

0 commit comments

Comments
 (0)