Skip to content

Commit

Permalink
switch aap-core to async-rt-aapxs branch and implemented client support.
Browse files Browse the repository at this point in the history
Confirmed that aap-juce-hera works. Haven't worked on the hosting side yet.
  • Loading branch information
atsushieno committed Oct 16, 2023
1 parent 8423cd5 commit 418cb0e
Showing 1 changed file with 16 additions and 31 deletions.
47 changes: 16 additions & 31 deletions aap-modules/aap_audio_processors/juceaap_AAPWrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ class JuceAAPWrapper : juce::AudioPlayHead {
}
#endif

AndroidAudioPluginHost& getHost() { return host; }

const char* getPluginId() { return plugin_unique_id; }

juce::OwnedArray<aap_parameter_info_t> aapParams{};
juce::HashMap<int32_t,int32_t> aapParamIdToEnumIndex{};
juce::OwnedArray<aap_parameter_enum_t> aapEnums{};
Expand Down Expand Up @@ -656,30 +660,9 @@ class JuceAAPWrapper : juce::AudioPlayHead {
return juce_processor->getNumPrograms();
}

int32_t getPresetDataSize(int32_t index) {
// There is no way in JUCE to retrieve data size of a preset program without once setting it as current...
auto bak = juce_processor->getCurrentProgram();
juce_processor->setCurrentProgram(index);
MemoryBlock mb{};
juce_processor->getCurrentProgramStateInformation(mb);
auto ret = mb.getSize();
juce_processor->setCurrentProgram(bak);
return ret;
}

void getPreset(int32_t index, bool skipBinary, aap_preset_t* preset) {
// There is no way in JUCE to retrieve data size of a preset program without once setting it as current...
// And we need getcurrentProgramStateInformation() anyways, so skipBinary does not really optimize a lot...
auto bak = juce_processor->getCurrentProgram();
void getPreset(int32_t index, aap_preset_t* preset) {
preset->id = index;
juce_processor->getProgramName(index).copyToUTF8(preset->name, AAP_PRESETS_EXTENSION_MAX_NAME_LENGTH);
juce_processor->setCurrentProgram(index);
MemoryBlock mb{};
juce_processor->getCurrentProgramStateInformation(mb);
if (!skipBinary)
mb.copyTo(preset->data, 0, preset->data_size);
if (preset->data_size > (int32_t) mb.getSize())
preset->data_size = (int32_t) mb.getSize();
juce_processor->setCurrentProgram(bak);
}

int32_t getPresetIndex() {
Expand Down Expand Up @@ -783,14 +766,9 @@ int32_t juce_aap_wrapper_get_preset_count(aap_presets_extension_t* ext, AndroidA
return wrapper->getPresetCount();
}

int32_t juce_aap_wrapper_get_preset_data_size(aap_presets_extension_t* ext, AndroidAudioPlugin* plugin, int32_t index) {
void juce_aap_wrapper_get_preset(aap_presets_extension_t* ext, AndroidAudioPlugin* plugin, int32_t index, aap_preset_t *preset, aapxs_completion_callback, void*) {
auto wrapper = (JuceAAPWrapper*) plugin->plugin_specific;
return wrapper->getPresetDataSize(index);
}

void juce_aap_wrapper_get_preset(aap_presets_extension_t* ext, AndroidAudioPlugin* plugin, int32_t index, bool skipBinary, aap_preset_t *preset) {
auto wrapper = (JuceAAPWrapper*) plugin->plugin_specific;
return wrapper->getPreset(index, skipBinary, preset);
return wrapper->getPreset(index, preset);
}

int32_t juce_aap_wrapper_get_preset_index(aap_presets_extension_t* ext, AndroidAudioPlugin* plugin) {
Expand Down Expand Up @@ -830,6 +808,13 @@ aap_parameter_enum_t juceaap_get_enumeration(aap_parameters_extension_t* ext, An
return wrapper->getAAPEnumeration(parameterId, enumIndex);
}

aap_plugin_info_t juceaap_get_plugin_info(AndroidAudioPlugin* plugin) {
auto wrapper = (JuceAAPWrapper*) plugin->plugin_specific;
auto* host = &wrapper->getHost();
auto hostExt = (aap_host_plugin_info_extension_t*) host->get_extension(host, AAP_PLUGIN_INFO_EXTENSION_URI);
return hostExt->get(hostExt, host, wrapper->getPluginId());
}

aap_parameters_extension_t parameters_ext{nullptr,
juceaap_get_parameter_count,
juceaap_get_parameter,
Expand Down Expand Up @@ -860,7 +845,6 @@ void* juceaap_get_extension(AndroidAudioPlugin *plugin, const char *uri) {
if (!presets_ext_map[plugin]) {
aap_presets_extension_t newInstance{nullptr,
juce_aap_wrapper_get_preset_count,
juce_aap_wrapper_get_preset_data_size,
juce_aap_wrapper_get_preset,
juce_aap_wrapper_get_preset_index,
juce_aap_wrapper_set_preset_index};
Expand Down Expand Up @@ -889,6 +873,7 @@ AndroidAudioPlugin *juceaap_instantiate(
ret->process = juceaap_process;
ret->deactivate = juceaap_deactivate;
ret->get_extension = juceaap_get_extension;
ret->get_plugin_info = juceaap_get_plugin_info;

return ret;
}
Expand Down

0 comments on commit 418cb0e

Please sign in to comment.