Skip to content

Commit b6adf6c

Browse files
refactor: removed isInitialized and added overrides for canBeDestructed
1 parent 9b984c5 commit b6adf6c

24 files changed

Lines changed: 26 additions & 80 deletions

packages/react-native-audio-api/common/cpp/audioapi/core/AudioNode.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,4 @@ bool AudioNode::requiresTailProcessing() const {
3434
return requiresTailProcessing_;
3535
}
3636

37-
void AudioNode::cleanup() {
38-
isInitialized_.store(false, std::memory_order_release);
39-
}
40-
4137
} // namespace audioapi

packages/react-native-audio-api/common/cpp/audioapi/core/AudioNode.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,7 @@ class AudioNode : public utils::graph::GraphObject, public std::enable_shared_fr
105105
const ChannelInterpretation channelInterpretation_ = ChannelInterpretation::SPEAKERS;
106106
const bool requiresTailProcessing_;
107107

108-
std::atomic<bool> isInitialized_ = false;
109-
110-
virtual void disable() {
111-
cleanup();
112-
};
113-
114108
virtual void processNode(int) = 0;
115-
void cleanup();
116109
};
117110

118111
} // namespace audioapi

packages/react-native-audio-api/common/cpp/audioapi/core/analysis/AnalyserNode.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ AnalyserNode::AnalyserNode(
2121
maxDecibels_(options.maxDecibels),
2222
smoothingTimeConstant_(options.smoothingTimeConstant) {
2323
setFFTSize(options.fftSize);
24-
isInitialized_.store(true, std::memory_order_release);
2524
}
2625

2726
void AnalyserNode::setFFTSize(int fftSize) {

packages/react-native-audio-api/common/cpp/audioapi/core/destinations/AudioDestinationNode.cpp

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/react-native-audio-api/common/cpp/audioapi/core/destinations/AudioDestinationNode.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ class BaseAudioContext;
1313

1414
class AudioDestinationNode : public AudioNode {
1515
public:
16-
explicit AudioDestinationNode(const std::shared_ptr<BaseAudioContext> &context);
16+
explicit AudioDestinationNode(const std::shared_ptr<BaseAudioContext> &context)
17+
: AudioNode(context, AudioDestinationOptions()) {}
18+
19+
bool canBeDestructed() const override {
20+
return false;
21+
}
1722

1823
protected:
19-
// DestinationNode's processNode is never called; graph traversal skips it.
2024
void processNode(int) final {
2125
audioBuffer_->normalize();
2226
};

packages/react-native-audio-api/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ BiquadFilterNode::BiquadFilterNode(
6767
x1_(MAX_CHANNEL_COUNT),
6868
x2_(MAX_CHANNEL_COUNT),
6969
y1_(MAX_CHANNEL_COUNT),
70-
y2_(MAX_CHANNEL_COUNT) {
71-
isInitialized_.store(true, std::memory_order_release);
72-
}
70+
y2_(MAX_CHANNEL_COUNT) {}
7371

7472
void BiquadFilterNode::setType(BiquadFilterType type) {
7573
type_ = type;

packages/react-native-audio-api/common/cpp/audioapi/core/effects/ConvolverNode.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ ConvolverNode::ConvolverNode(
2020
scaleFactor_(1.0f),
2121
intermediateBuffer_(nullptr),
2222
buffer_(nullptr),
23-
internalBuffer_(nullptr) {
24-
isInitialized_.store(true, std::memory_order_release);
25-
}
23+
internalBuffer_(nullptr) {}
2624

2725
void ConvolverNode::setBuffer(
2826
const std::shared_ptr<AudioBuffer> &buffer,
@@ -99,7 +97,6 @@ void ConvolverNode::processNode(int framesToProcess) {
9997
if (remainingSegments_ > 0) {
10098
remainingSegments_--;
10199
} else {
102-
disable();
103100
signalledToStop_ = false;
104101
internalBufferIndex_ = 0;
105102
return;

packages/react-native-audio-api/common/cpp/audioapi/core/effects/DelayNode.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ DelayNode::DelayNode(const std::shared_ptr<BaseAudioContext> &context, const Del
1818
options.maxDelayTime * context->getSampleRate() +
1919
1), // +1 to enable delayTime equal to maxDelayTime
2020
channelCount_,
21-
context->getSampleRate())) {
22-
isInitialized_.store(true, std::memory_order_release);
23-
}
21+
context->getSampleRate())) {}
2422

2523
std::shared_ptr<AudioParam> DelayNode::getDelayTimeParam() const {
2624
return delayTimeParam_;
@@ -71,7 +69,6 @@ void DelayNode::processNode(int framesToProcess) {
7169
// handling tail processing
7270
if (signalledToStop_) {
7371
if (remainingFrames_ <= 0) {
74-
disable();
7572
signalledToStop_ = false;
7673
return;
7774
}

packages/react-native-audio-api/common/cpp/audioapi/core/effects/GainNode.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ GainNode::GainNode(const std::shared_ptr<BaseAudioContext> &context, const GainO
1515
options.gain,
1616
MOST_NEGATIVE_SINGLE_FLOAT,
1717
MOST_POSITIVE_SINGLE_FLOAT,
18-
context)) {
19-
isInitialized_.store(true, std::memory_order_release);
20-
}
18+
context)) {}
2119

2220
std::shared_ptr<AudioParam> GainNode::getGainParam() const {
2321
return gainParam_;

packages/react-native-audio-api/common/cpp/audioapi/core/effects/IIRFilterNode.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ IIRFilterNode::IIRFilterNode(
4242
feedback_(createNormalizedArray(options.feedback, options.feedback[0])),
4343
xBuffers_(bufferLength, MAX_CHANNEL_COUNT, context->getSampleRate()),
4444
yBuffers_(bufferLength, MAX_CHANNEL_COUNT, context->getSampleRate()),
45-
bufferIndices_(bufferLength) {
46-
isInitialized_.store(true, std::memory_order_release);
47-
}
45+
bufferIndices_(bufferLength) {}
4846

4947
// Compute Z-transform of the filter
5048
//

0 commit comments

Comments
 (0)