Skip to content

Commit

Permalink
StandardExtensions are null checked now. Bump extension version numbers.
Browse files Browse the repository at this point in the history
They can be missing from aap_manifest.xml, and the default UI should not
crash because of that.
  • Loading branch information
atsushieno committed Nov 6, 2023
1 parent c58e79d commit aa2d33b
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 44 deletions.
60 changes: 41 additions & 19 deletions include/aap/core/aapxs/standard-extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,40 +127,62 @@ namespace aap::xs {
}

// MIDI
int32_t getMidiMappingPolicy() override { return midi->get_mapping_policy(midi, plugin); }
int32_t getMidiMappingPolicy() override { return midi ? midi->get_mapping_policy(midi, plugin) : 0; }

// Parameters
int32_t getParameterCount() override { return parameters->get_parameter_count(parameters, plugin); }
aap_parameter_info_t getParameter(int32_t index) override { return parameters->get_parameter(parameters, plugin, index); }
double getParameterProperty(int32_t index, int32_t propertyId) override { return parameters->get_parameter_property(parameters, plugin, index, propertyId); }
int32_t getEnumerationCount(int32_t index) override { return parameters->get_enumeration_count(parameters, plugin, index); }
aap_parameter_enum_t getEnumeration(int32_t index, int32_t enumIndex) override { return parameters->get_enumeration(parameters, plugin, index, enumIndex); }
int32_t getParameterCount() override { return parameters ? parameters->get_parameter_count(parameters, plugin) : 0; }
aap_parameter_info_t getParameter(int32_t index) override { return parameters ? parameters->get_parameter(parameters, plugin, index) : aap_parameter_info_t{}; }
double getParameterProperty(int32_t index, int32_t propertyId) override { return parameters ? parameters->get_parameter_property(parameters, plugin, index, propertyId) : 0.0; }
int32_t getEnumerationCount(int32_t index) override { return parameters ? parameters->get_enumeration_count(parameters, plugin, index) : 0; }
aap_parameter_enum_t getEnumeration(int32_t index, int32_t enumIndex) override { return parameters ? parameters->get_enumeration(parameters, plugin, index, enumIndex) : aap_parameter_enum_t{}; }

// Presets
int32_t getPresetCount() override { return presets->get_preset_count(presets, plugin); }
void getPreset(int32_t index, aap_preset_t& preset) override { presets->get_preset(presets, plugin, index, &preset, nullptr, nullptr); }
int32_t getPresetCount() override { return presets ? presets->get_preset_count(presets, plugin) : 0; }
void getPreset(int32_t index, aap_preset_t& preset) override { if (presets) presets->get_preset(presets, plugin, index, &preset, nullptr, nullptr); }
std::string getPresetName(int32_t index) override {
if (!presets)
return "";
aap_preset_t preset;
getPreset(index, preset);
return preset.name;
}
int32_t getCurrentPresetIndex() override { return presets->get_preset_index(presets, plugin); }
void setCurrentPresetIndex(int32_t index) override { presets->set_preset_index(presets, plugin, index); }
int32_t getCurrentPresetIndex() override { return presets ? presets->get_preset_index(presets, plugin) : 0; }
void setCurrentPresetIndex(int32_t index) override { if (presets) presets->set_preset_index(presets, plugin, index); }

// State
int32_t getStateSize() override { return state->get_state_size(state, plugin); }
int32_t getStateSize() override { return state ? state->get_state_size(state, plugin) : 0; }
aap_state_t getState() override {
aap_state_t stateToSave;
state->get_state(state, plugin, &stateToSave);
aap_state_t stateToSave{};
if (state)
state->get_state(state, plugin, &stateToSave);
return stateToSave;
}
void setState(aap_state_t& stateToLoad) override { state->set_state(state, plugin, &stateToLoad); }
void setState(aap_state_t& stateToLoad) override { if (state) state->set_state(state, plugin, &stateToLoad); }

// Gui
aap_gui_instance_id createGui(std::string pluginId, int32_t instanceId, void* audioPluginView) override { return gui->create(gui, plugin, pluginId.c_str(), instanceId, audioPluginView); }
int32_t showGui(aap_gui_instance_id guiInstanceId) override { return gui->show(gui, plugin, guiInstanceId); }
int32_t hideGui(aap_gui_instance_id guiInstanceId) override { gui->hide(gui, plugin, guiInstanceId); return 0; }
int32_t resizeGui(aap_gui_instance_id guiInstanceId, int32_t width, int32_t height) override { return gui->resize(gui, plugin, guiInstanceId, width, height); }
int32_t destroyGui(aap_gui_instance_id guiInstanceId) override { gui->destroy(gui, plugin, guiInstanceId); return 0; }
aap_gui_instance_id createGui(std::string pluginId, int32_t instanceId, void* audioPluginView) override { return gui ? gui->create(gui, plugin, pluginId.c_str(), instanceId, audioPluginView) : -1; }
int32_t showGui(aap_gui_instance_id guiInstanceId) override { return gui ? gui->show ? gui->show(gui, plugin, guiInstanceId) : AAP_GUI_ERROR_NO_SHOW_DEFINED : AAP_GUI_ERROR_NO_GUI_DEFINED; }
int32_t hideGui(aap_gui_instance_id guiInstanceId) override {
if (gui)
if (gui->hide)
gui->hide(gui, plugin, guiInstanceId);
else
return AAP_GUI_ERROR_NO_HIDE_DEFINED;
else
return AAP_GUI_ERROR_NO_GUI_DEFINED;
return 0;
}
int32_t resizeGui(aap_gui_instance_id guiInstanceId, int32_t width, int32_t height) override { return gui ? gui->resize ? gui->resize(gui, plugin, guiInstanceId, width, height) : AAP_GUI_ERROR_NO_RESIZE_DEFINED : AAP_GUI_ERROR_NO_GUI_DEFINED; }
int32_t destroyGui(aap_gui_instance_id guiInstanceId) override {
if (gui)
if (gui->destroy)
gui->destroy(gui, plugin, guiInstanceId);
else
return AAP_GUI_ERROR_NO_DESTROY_DEFINED;
else
return AAP_GUI_ERROR_NO_GUI_DEFINED;
return 0;
}
};

class StandardHostExtensions {
Expand Down
2 changes: 1 addition & 1 deletion include/aap/ext/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
extern "C" {
#endif

#define AAP_GUI_EXTENSION_URI "urn://androidaudioplugin.org/extensions/gui/v2"
#define AAP_GUI_EXTENSION_URI "urn://androidaudioplugin.org/extensions/gui/v3"

typedef int32_t aap_gui_instance_id;

Expand Down
2 changes: 1 addition & 1 deletion include/aap/ext/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
extern "C" {
#endif

#define AAP_PARAMETERS_EXTENSION_URI "urn://androidaudioplugin.org/extensions/parameters/v2.1"
#define AAP_PARAMETERS_EXTENSION_URI "urn://androidaudioplugin.org/extensions/parameters/v3"
#define AAP_PARAMETERS_XMLNS_URI "urn://androidaudioplugin.org/extensions/parameters"

#define AAP_MAX_PARAMETER_NAME_CHARS 64
Expand Down
2 changes: 1 addition & 1 deletion include/aap/ext/port-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern "C" {
#include "../android-audio-plugin.h"
#include <stdint.h>

#define AAP_PORT_CONFIG_EXTENSION_URI "urn://androidaudioplugin.org/extensions/port-config/v2"
#define AAP_PORT_CONFIG_EXTENSION_URI "urn://androidaudioplugin.org/extensions/port-config/v3"

#define AAP_PORT_CONFIG_DEFAULT_INSTRUMENT "urn://androidaudioplugin.org/port-config/default/instrument/v1"
#define AAP_PORT_CONFIG_DEFAULT_EFFECT "urn://androidaudioplugin.org/port-config/default/effect/v1"
Expand Down
2 changes: 1 addition & 1 deletion include/aap/ext/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern "C" {
#include "../android-audio-plugin.h"
#include "stdint.h"

#define AAP_STATE_EXTENSION_URI "urn://androidaudioplugin.org/extensions/state/v2"
#define AAP_STATE_EXTENSION_URI "urn://androidaudioplugin.org/extensions/state/v3"

typedef struct {
void* data;
Expand Down
20 changes: 4 additions & 16 deletions samples/aapbarebonepluginsample/src/main/res/xml/aap_metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,10 @@
gui:ui-view-factory="org.androidaudioplugin.ui.compose.ComposeAudioPluginViewFactory"
xmlns:gui="urn://androidaudioplugin.org/extensions/gui">
<extensions>
<extension uri="urn://androidaudioplugin.org/extensions/midi2/v2" />
<extension uri="urn://androidaudioplugin.org/extensions/parameters/v2.1" />
<extension uri="urn://androidaudioplugin.org/extensions/port-config/v2" />
<extension uri="urn://androidaudioplugin.org/extensions/gui/v2" />
<extension uri="urn://androidaudioplugin.org/extensions/midi2/v3" />
<extension uri="urn://androidaudioplugin.org/extensions/parameters/v3" />
<extension uri="urn://androidaudioplugin.org/extensions/port-config/v3" />
<extension uri="urn://androidaudioplugin.org/extensions/gui/v3" />
</extensions>
<!--
<parameters xmlns="urn://androidaudioplugin.org/extensions/parameters">
<parameter id="0" name="Output Volume L" default="0.5" minimum="0" maximum="1" />
<parameter id="1" name="Output Volume R" default="0.5" minimum="0" maximum="1" />
<parameter id="2" name="Delay L" default="0" minimum="0" maximum="2048" />
<parameter id="3" name="Delay R" default="256" minimum="0" maximum="2048" />
<parameter id="11" name="Stub Parameter 4" default="50" minimum="0" maximum="100" />
<parameter id="12" name="Stub Parameter 5" default="50" minimum="0" maximum="100" />
<parameter id="13" name="Stub Parameter 6" default="50" minimum="0" maximum="100" />
<parameter id="14" name="Stub Parameter 7" default="50" minimum="0" maximum="100" />
</parameters>
-->
</plugin>
</plugins>
6 changes: 3 additions & 3 deletions samples/aapinstrumentsample/src/main/res/xml/aap_metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<extensions>
<extension uri="urn://androidaudioplugin.org/extensions/presets/v3" />
<extension uri="urn://androidaudioplugin.org/extensions/midi2/v3" />
<extension uri="urn://androidaudioplugin.org/extensions/parameters/v2.1" />
<extension uri="urn://androidaudioplugin.org/extensions/port-config/v2" />
<extension uri="urn://androidaudioplugin.org/extensions/gui/v2" />
<extension uri="urn://androidaudioplugin.org/extensions/parameters/v3" />
<extension uri="urn://androidaudioplugin.org/extensions/port-config/v3" />
<extension uri="urn://androidaudioplugin.org/extensions/gui/v3" />
</extensions>

<!-- All ports are created implicitly now. -->
Expand Down
4 changes: 2 additions & 2 deletions samples/aapxssample/src/main/res/xml/aap_metadata.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<plugins xmlns="urn:org.androidaudioplugin.core">
<plugin name="AAPXS Sample" category="Effect" developer="AAP Developers" unique-id="urn:org.androidaudioplugin/samples/aapxssample/InstrumentSample" library="libaapxssample.so">
<extensions>
<extension uri="urn://androidaudioplugin.org/extensions/midi2/v2" />
<extension uri="urn://androidaudioplugin.org/extensions/port-config/v2" />
<extension uri="urn://androidaudioplugin.org/extensions/midi2/v3" />
<extension uri="urn://androidaudioplugin.org/extensions/port-config/v3" />
</extensions>

<!-- All ports are created implicitly now. -->
Expand Down

0 comments on commit aa2d33b

Please sign in to comment.