Skip to content

Commit

Permalink
a bunch of C++ tidy fixups in androidaudioplugin-manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
atsushieno committed Apr 27, 2024
1 parent a4cd454 commit d384428
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ size_t aap::AAPMidiEventTranslator::runThroughMidi2UmpForMidiMapping(uint8_t* by
conversion_helper_buffer,
conversion_helper_buffer_size,
0,
instance->aapxsRequestIdSerial(),
aap::RemotePluginInstance::aapxsRequestIdSerial(),
preset_urid,
AAP_PRESETS_EXTENSION_URI,
OPCODE_SET_PRESET_INDEX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace aap {
int32_t detectEndpointConfigurationMessage(uint8_t* bytes, size_t offset, size_t length);

public:
AAPMidiEventTranslator(RemotePluginInstance* instance, int32_t midiBufferSize = AAP_MANAGER_MIDI_BUFFER_SIZE, int32_t initialMidiProtocol = CMIDI2_PROTOCOL_TYPE_MIDI2);
explicit AAPMidiEventTranslator(RemotePluginInstance* instance, int32_t midiBufferSize = AAP_MANAGER_MIDI_BUFFER_SIZE, int32_t initialMidiProtocol = CMIDI2_PROTOCOL_TYPE_MIDI2);
~AAPMidiEventTranslator();

void setPlugin(RemotePluginInstance* pluginInstance);
Expand Down
2 changes: 1 addition & 1 deletion androidaudioplugin-manager/src/main/cpp/AudioDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace aap {

class AAP_PUBLIC_API AudioDeviceOut {
public:
AudioDeviceOut() {}
AudioDeviceOut() = default;

AAP_PUBLIC_API virtual void startCallback() = 0;
AAP_PUBLIC_API virtual void stopCallback() = 0;
Expand Down
4 changes: 2 additions & 2 deletions androidaudioplugin-manager/src/main/cpp/AudioDeviceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace aap {
// This needs to be implemented for each platform
static AudioDeviceManager* getInstance();

virtual AudioDeviceIn* openDefaultInput(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels) = 0;
virtual AudioDeviceOut* openDefaultOutput(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels) = 0;
virtual AudioDeviceIn* openDefaultInput(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels) = 0;
virtual AudioDeviceOut* openDefaultOutput(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels) = 0;
};
}

Expand Down
18 changes: 9 additions & 9 deletions androidaudioplugin-manager/src/main/cpp/AudioGraphNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ namespace aap {
protected:
AudioGraph* graph;

AudioGraphNode(AudioGraph* ownerGraph) : graph(ownerGraph) {}
explicit AudioGraphNode(AudioGraph* ownerGraph) : graph(ownerGraph) {}

public:
virtual ~AudioGraphNode() {}
virtual ~AudioGraphNode() = default;
virtual bool shouldSkip() { return false; }
virtual void start() = 0;
virtual void pause() = 0;
Expand Down Expand Up @@ -48,7 +48,7 @@ namespace aap {
AudioGraphNode(ownerGraph),
input(input) {
}
virtual ~AudioDeviceInputNode();
~AudioDeviceInputNode() override;

AudioDeviceIn* getDevice() { return input; }

Expand Down Expand Up @@ -81,7 +81,7 @@ namespace aap {
AudioGraphNode(ownerGraph),
output(output) {
}
virtual ~AudioDeviceOutputNode();
~AudioDeviceOutputNode() override;

AudioDeviceOut* getDevice() { return output; }

Expand All @@ -98,7 +98,7 @@ namespace aap {
AudioGraphNode(ownerGraph),
plugin(plugin) {
}
virtual ~AudioPluginNode();
~AudioPluginNode() override;

void setPlugin(RemotePluginInstance* instance) { plugin = instance; }

Expand All @@ -121,7 +121,7 @@ namespace aap {

public:
explicit AudioDataSourceNode(AudioGraph* ownerGraph);
virtual ~AudioDataSourceNode();
~AudioDataSourceNode() override;

void start() override;
void pause() override;
Expand Down Expand Up @@ -166,7 +166,7 @@ namespace aap {
int32_t initialMidiProtocol = CMIDI2_PROTOCOL_TYPE_MIDI2,
int32_t internalBufferSize = AAP_PLUGIN_PLAYER_DEFAULT_MIDI_RING_BUFFER_SIZE);

virtual ~MidiSourceNode();
~MidiSourceNode() override;

void setPlugin(RemotePluginInstance* instance) { translator.setPlugin(instance); }

Expand All @@ -183,9 +183,9 @@ namespace aap {
NanoSleepLock midi_buffer_mutex{};

public:
MidiDestinationNode(AudioGraph* ownerGraph, int32_t internalBufferSize = AAP_PLUGIN_PLAYER_DEFAULT_MIDI_RING_BUFFER_SIZE);
explicit MidiDestinationNode(AudioGraph* ownerGraph, int32_t internalBufferSize = AAP_PLUGIN_PLAYER_DEFAULT_MIDI_RING_BUFFER_SIZE);

virtual ~MidiDestinationNode();
~MidiDestinationNode() override;

void start() override;
void pause() override;
Expand Down
28 changes: 15 additions & 13 deletions androidaudioplugin-manager/src/main/cpp/OboeAudioDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ namespace aap {
protected:
std::shared_ptr<oboe::AudioStream> stream{};
oboe::AudioStreamBuilder builder{};
void* callback_context;
AudioDeviceCallback *aap_callback;
void* callback_context{};
AudioDeviceCallback *aap_callback{};
AudioBuffer aap_buffer;
void* oboe_buffer;

oboe::DataCallbackResult onAudioInputReady(oboe::AudioStream *audioStream, void *audioData, int32_t numFrames);
oboe::DataCallbackResult onAudioOutputReady(oboe::AudioStream *audioStream, void *audioData, int32_t numFrames);

public:
explicit OboeAudioDevice(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels, oboe::Direction direction);
explicit OboeAudioDevice(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels, oboe::Direction direction);

virtual ~OboeAudioDevice() noexcept;
~OboeAudioDevice() noexcept override;

void setCallback(AudioDeviceCallback callback, void* callbackContext);

Expand All @@ -47,7 +47,8 @@ namespace aap {
OboeAudioDevice impl;

public:
OboeAudioDeviceIn(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels);
OboeAudioDeviceIn(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels);
virtual ~OboeAudioDeviceIn() = default;

// required on Android platform
bool isPermissionRequired() override { return true; }
Expand All @@ -68,7 +69,8 @@ namespace aap {
OboeAudioDevice impl;

public:
OboeAudioDeviceOut(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels);
OboeAudioDeviceOut(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels);
virtual ~OboeAudioDeviceOut() = default;

void startCallback() override { impl.startCallback(); }

Expand All @@ -85,15 +87,15 @@ namespace aap {
//--------

aap::AudioDeviceIn *
aap::OboeAudioDeviceManager::openDefaultInput(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels) {
aap::OboeAudioDeviceManager::openDefaultInput(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels) {
// FIXME: this should not be created twice
//assert(input == nullptr);
input = std::make_shared<OboeAudioDeviceIn>(sampleRate, framesPerCallback, numChannels);
return input.get();
}

aap::AudioDeviceOut *
aap::OboeAudioDeviceManager::openDefaultOutput(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels) {
aap::OboeAudioDeviceManager::openDefaultOutput(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels) {
// FIXME: this should not be created twice
//assert(output == nullptr);
output = std::make_shared<OboeAudioDeviceOut>(sampleRate, framesPerCallback, numChannels);
Expand All @@ -102,7 +104,7 @@ aap::OboeAudioDeviceManager::openDefaultOutput(uint32_t sampleRate, uint32_t fra

//--------

aap::OboeAudioDevice::OboeAudioDevice(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels, oboe::Direction direction) :
aap::OboeAudioDevice::OboeAudioDevice(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels, oboe::Direction direction) :
oboe::StabilizedCallback(this),
aap_buffer(numChannels, (int32_t) framesPerCallback) {
builder.setPerformanceMode(oboe::PerformanceMode::LowLatency)
Expand Down Expand Up @@ -233,18 +235,18 @@ void aap::OboeAudioDevice::copyAAPBufferForWriting(AudioBuffer *srcAudioData, in
choc::buffer::copy(aap_buffer.audio.getFrameRange(range), srcAudioData->audio.getView().getFrameRange(range));
}

bool aap::OboeAudioDevice::onError(oboe::AudioStream *stream, oboe::Result result) {
bool aap::OboeAudioDevice::onError(oboe::AudioStream *audioStream, oboe::Result result) {
// Should we log errors here?
return AudioStreamErrorCallback::onError(stream, result);
return AudioStreamErrorCallback::onError(audioStream, result);
}

//--------

aap::OboeAudioDeviceIn::OboeAudioDeviceIn(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels) :
aap::OboeAudioDeviceIn::OboeAudioDeviceIn(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels) :
impl(sampleRate, framesPerCallback, numChannels, oboe::Direction::Input) {
}

aap::OboeAudioDeviceOut::OboeAudioDeviceOut(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels) :
aap::OboeAudioDeviceOut::OboeAudioDeviceOut(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels) :
impl(sampleRate, framesPerCallback, numChannels, oboe::Direction::Output) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace aap {

public:
OboeAudioDeviceManager() {}
AudioDeviceIn * openDefaultInput(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels) override;
AudioDeviceIn * openDefaultInput(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels) override;

AudioDeviceOut * openDefaultOutput(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels) override;
AudioDeviceOut * openDefaultOutput(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels) override;
};
}

Expand Down
2 changes: 1 addition & 1 deletion androidaudioplugin-manager/src/main/cpp/PluginPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void aap::PluginPlayer::enableAudioRecorder() {
}

void
aap::PluginPlayer::addMidiEvents(uint8_t *data, int32_t dataLength, uint64_t timestampInNanoseconds) {
aap::PluginPlayer::addMidiEvents(uint8_t *data, int32_t dataLength, int64_t timestampInNanoseconds) {
graph.addMidiEvent(data, dataLength, timestampInNanoseconds);
}

Expand Down
4 changes: 2 additions & 2 deletions androidaudioplugin-manager/src/main/cpp/PluginPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ namespace aap {
SimpleLinearAudioGraph graph;

public:
PluginPlayer(PluginPlayerConfiguration &configuration);
explicit PluginPlayer(PluginPlayerConfiguration &configuration);

virtual ~PluginPlayer();

SimpleLinearAudioGraph& getGraph() { return graph; }

void setAudioSource(uint8_t *data, int32_t dataLength, const char *filename);

void addMidiEvents(uint8_t* data, int32_t dataLength, uint64_t timestampInNanoseconds);
void addMidiEvents(uint8_t* data, int32_t dataLength, int64_t timestampInNanoseconds);

void startProcessing();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace aap {
class VirtualAudioDeviceIn : public AudioDeviceIn {
bool running{false};
public:
explicit VirtualAudioDeviceIn() {}
virtual ~VirtualAudioDeviceIn() {}
explicit VirtualAudioDeviceIn() = default;
virtual ~VirtualAudioDeviceIn() = default;

void startCallback() override { running = true; }
void stopCallback() override { running = false; }
Expand All @@ -27,8 +27,8 @@ namespace aap {
class VirtualAudioDeviceOut : public AudioDeviceOut {
bool running{false};
public:
explicit VirtualAudioDeviceOut() {}
virtual ~VirtualAudioDeviceOut() {}
explicit VirtualAudioDeviceOut() = default;
virtual ~VirtualAudioDeviceOut() = default;

void startCallback() override { running = true; }
void stopCallback() override { running = false; }
Expand All @@ -50,8 +50,8 @@ namespace aap {
output(std::make_shared<VirtualAudioDeviceOut>()) {
}

AudioDeviceIn * openDefaultInput(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels) override { return input.get(); }
AudioDeviceOut * openDefaultOutput(uint32_t sampleRate, uint32_t framesPerCallback, int32_t numChannels) override { return output.get(); }
AudioDeviceIn * openDefaultInput(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels) override { return input.get(); }
AudioDeviceOut * openDefaultOutput(int32_t sampleRate, int32_t framesPerCallback, int32_t numChannels) override { return output.get(); }
};

}
Expand Down

0 comments on commit d384428

Please sign in to comment.