Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refactored deconstructors on Android #139

Merged
merged 4 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,4 @@ void AudioBuffer::setChannelData(int channel, const float *data) const {
method(javaPart_, channel, jArray.get());
}

void AudioBuffer::prepareForDeconstruction() {
javaPart_.reset();
}

} // namespace audioapi
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class AudioBuffer : public jni::HybridClass<AudioBuffer> {
int getNumberOfChannels() const;
float *getChannelData(int channel) const;
void setChannelData(int channel, const float *data) const;
void prepareForDeconstruction();

public:
friend HybridBase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,4 @@ void AudioNode::disconnect(const AudioNode *node) {
method(javaPart_.get(), node->javaPart_.get());
}

void AudioNode::resetJavaPart() {
javaPart_.reset();
}
} // namespace audioapi
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class AudioNode : public jni::HybridClass<AudioNode> {
std::string getChannelInterpretation();
void connect(const AudioNode *node);
void disconnect(const AudioNode *node);
void resetJavaPart();

protected:
friend HybridBase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,4 @@ void AudioParam::exponentialRampToValueAtTime(double value, double endTime) {
method(javaPart_.get(), value, endTime);
}

void AudioParam::prepareForDeconstruction() {
javaPart_.reset();
}
} // namespace audioapi
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class AudioParam : public jni::HybridClass<AudioParam> {
void setValueAtTime(double value, double startTime);
void linearRampToValueAtTime(double value, double endTime);
void exponentialRampToValueAtTime(double value, double endTime);
void prepareForDeconstruction();

protected:
friend HybridBase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ void AudioScheduledSourceNode::stop(double time) {
static const auto method = javaClassLocal()->getMethod<void(jdouble)>("stop");
method(javaPart_.get(), time);
}

} // namespace audioapi
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,4 @@ void OscillatorNode::setWaveType(const std::string &waveType) {
method(javaPart_.get(), *make_jstring(waveType));
}

void OscillatorNode::prepareForDeconstruction() {
static const auto method =
javaClassLocal()->getMethod<void()>("prepareForDeconstruction");
method(javaPart_.get());
AudioNode::resetJavaPart();
}
} // namespace audioapi
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ class OscillatorNode
AudioParam *getDetuneParam();
std::string getWaveType();
void setWaveType(const std::string &waveType);
void prepareForDeconstruction();
};
} // namespace audioapi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class AudioBufferWrapper {
AudioBuffer *audioBuffer_;

explicit AudioBufferWrapper(AudioBuffer *audioBuffer);
~AudioBufferWrapper();
#else

public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ AudioBufferWrapper::AudioBufferWrapper(AudioBuffer *audioBuffer) {
numberOfChannels = audioBuffer->getNumberOfChannels();
}

AudioBufferWrapper::~AudioBufferWrapper() {
audioBuffer_->prepareForDeconstruction();
}

int AudioBufferWrapper::getSampleRate() const {
return sampleRate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class AudioNodeWrapper {

public:
explicit AudioNodeWrapper(AudioNode *node);
virtual ~AudioNodeWrapper();
#else

public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifdef ANDROID
#include "AudioNodeWrapper.h"
#include <android/log.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, I forgot to remove it ;//


namespace audioapi {

Expand All @@ -8,10 +9,6 @@ AudioNodeWrapper::AudioNodeWrapper(AudioNode *node) : node_(node) {
numberOfOutputs_ = node->getNumberOfOutputs();
}

AudioNodeWrapper::~AudioNodeWrapper() {
node_->resetJavaPart();
}

int AudioNodeWrapper::getNumberOfInputs() const {
return numberOfInputs_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class AudioParamWrapper {

public:
explicit AudioParamWrapper(AudioParam *param);
~AudioParamWrapper();
#else

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ AudioParamWrapper::AudioParamWrapper(AudioParam *param) : param_(param) {
maxValue_ = param->getMaxValue();
}

AudioParamWrapper::~AudioParamWrapper() {
param_->prepareForDeconstruction();
}

double AudioParamWrapper::getValue() {
return param_->getValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class OscillatorNodeWrapper : public AudioScheduledSourceNodeWrapper {

public:
explicit OscillatorNodeWrapper(OscillatorNode *oscillator);
~OscillatorNodeWrapper() override;
#else

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ OscillatorNodeWrapper::OscillatorNodeWrapper(OscillatorNode *oscillator)
detuneParam_ = std::make_shared<AudioParamWrapper>(detuneParam);
}

OscillatorNodeWrapper::~OscillatorNodeWrapper() {
auto oscillatorNode_ = getOscillatorNodeFromAudioNode();
oscillatorNode_->prepareForDeconstruction();
}

std::shared_ptr<AudioParamWrapper> OscillatorNodeWrapper::getFrequencyParam()
const {
return frequencyParam_;
Expand Down
Loading