diff --git a/androidaudioplugin/src/main/cpp/android/AudioPluginNatives_jni.cpp b/androidaudioplugin/src/main/cpp/android/AudioPluginNatives_jni.cpp index 1a3ef730..a43de938 100644 --- a/androidaudioplugin/src/main/cpp/android/AudioPluginNatives_jni.cpp +++ b/androidaudioplugin/src/main/cpp/android/AudioPluginNatives_jni.cpp @@ -578,7 +578,7 @@ Java_org_androidaudioplugin_hosting_NativeRemotePluginInstance_00024Companion_se jboolean isCopy{false}; auto uriChars = env->GetStringUTFChars(uri, &isCopy); auto src = (uint8_t*) env->GetDirectBufferAddress(buffer); - instance->getAAPXSDispatcher().sendExtensionRequest(uriChars, opcode, src + offset, length, instance->aapxsRequestIdSerial()); + instance->sendAAPXSRequest(uriChars, opcode, src + offset, length, instance->aapxsRequestIdSerial()); if (isCopy) env->ReleaseStringChars(uri, (const jchar*) uriChars); } diff --git a/androidaudioplugin/src/main/cpp/core/aapxs/aapxs-runtime.cpp b/androidaudioplugin/src/main/cpp/core/aapxs/aapxs-runtime.cpp index 70ac3e0a..c3de0399 100644 --- a/androidaudioplugin/src/main/cpp/core/aapxs/aapxs-runtime.cpp +++ b/androidaudioplugin/src/main/cpp/core/aapxs/aapxs-runtime.cpp @@ -3,148 +3,100 @@ #include "aap/core/aapxs/aapxs-runtime.h" aap::AAPXSClientDispatcher::AAPXSClientDispatcher( - aap::AAPXSClientFeatureRegistry *registry) /*: registry(registry)*/ { + aap::AAPXSDefinitionClientRegistry *registry) /*: registry(registry)*/ { } aap::AAPXSServiceDispatcher::AAPXSServiceDispatcher( - aap::AAPXSServiceFeatureRegistry *registry) { + aap::AAPXSDefinitionServiceRegistry *registry) { } // Client setup -void aap::AAPXSClientDispatcher::setupInstances(aap::AAPXSClientFeatureRegistry *registry, + +void aap::AAPXSClientDispatcher::setupInstances(aap::AAPXSDefinitionClientRegistry *registry, AAPXSSerializationContext *serialization, - initiator_get_new_request_id_func initiatorGetNewRequestId, - recipient_get_new_request_id_func recipientGetNewRequestId) { - std::for_each(registry->begin(), registry->end(), [&](AAPXSFeatureVNext* f) { + aap::aapxs_initiator_send_func sendAAPXSRequest, + aap::aapxs_initiator_receive_func processIncomingAAPXSReply, + aap::aapxs_recipient_receive_func processIncomingAAPXSRequest, + aap::aapxs_recipient_send_func sendAAPXSReply, + aap::initiator_get_new_request_id_func initiatorGetNewRequestId, + aap::recipient_get_new_request_id_func recipientGetNewRequestId) { + std::for_each(registry->begin(), registry->end(), [&](AAPXSDefinition* f) { // plugin extensions - addInitiator(populateAAPXSInitiatorInstance(serialization, initiatorGetNewRequestId), f->uri); + addInitiator(populateAAPXSInitiatorInstance(serialization, sendAAPXSRequest, processIncomingAAPXSReply, initiatorGetNewRequestId), f->uri); // host extensions - addRecipient(populateAAPXSRecipientInstance(serialization, recipientGetNewRequestId), f->uri); + addRecipient(populateAAPXSRecipientInstance(serialization, processIncomingAAPXSRequest, sendAAPXSReply, recipientGetNewRequestId), f->uri); }); } -AAPXSInitiatorInstance aap::AAPXSClientDispatcher::populateAAPXSInitiatorInstance(AAPXSSerializationContext* serialization, initiator_get_new_request_id_func getNewRequestId) { +AAPXSInitiatorInstance aap::AAPXSClientDispatcher::populateAAPXSInitiatorInstance( + AAPXSSerializationContext* serialization, + aap::aapxs_initiator_send_func sendAAPXSRequest, + aap::aapxs_initiator_receive_func processIncomingAAPXSReply, + initiator_get_new_request_id_func getNewRequestId) { AAPXSInitiatorInstance instance{this, serialization, getNewRequestId, - staticSendAAPXSRequest, - staticProcessIncomingAAPXSReply}; + sendAAPXSRequest, + processIncomingAAPXSReply}; return instance; } -AAPXSRecipientInstance aap::AAPXSClientDispatcher::populateAAPXSRecipientInstance( - AAPXSSerializationContext *serialization, recipient_get_new_request_id_func getNewRequestId) { +AAPXSRecipientInstance +aap::AAPXSClientDispatcher::populateAAPXSRecipientInstance( + AAPXSSerializationContext *serialization, + aap::aapxs_recipient_receive_func processIncomingAapxsRequest, + aap::aapxs_recipient_send_func sendAapxsReply, + aap::recipient_get_new_request_id_func getNewRequestId) { AAPXSRecipientInstance instance{this, serialization, getNewRequestId, - staticProcessIncomingAAPXSRequest, - staticSendAAPXSReply}; + processIncomingAapxsRequest, + sendAapxsReply}; return instance; } -// Client send/receive -void -aap::AAPXSClientDispatcher::sendExtensionRequest(const char* uri, int32_t opcode, void *data, int32_t dataSize, uint32_t newRequestId) { - auto aapxs = getPluginAAPXSByUri(uri); - AAPXSRequestContext context{nullptr, nullptr, aapxs.serialization, uri, newRequestId, opcode}; - assert(aapxs.serialization->data_capacity >= dataSize); - memcpy(aapxs.serialization->data, data, dataSize); - aapxs.serialization->data_size = dataSize; - aapxs.send_aapxs_request(&aapxs, &context); -} - -void -aap::AAPXSClientDispatcher::processExtensionReply(const char *uri, int32_t opcode, void* data, int32_t dataSize, uint32_t requestId) { - auto aapxs = getPluginAAPXSByUri(uri); - AAPXSRequestContext context{nullptr, nullptr, aapxs.serialization, uri, requestId, opcode}; - aapxs.process_incoming_aapxs_reply(&aapxs, &context); -} - -void -aap::AAPXSClientDispatcher::processHostExtensionRequest(const char *uri, int32_t opcode, void* data, int32_t dataSize, uint32_t requestId) { - auto aapxs = getHostAAPXSByUri(uri); - AAPXSRequestContext context{nullptr, nullptr, aapxs.serialization, uri, requestId, opcode}; - aapxs.process_incoming_aapxs_request(&aapxs, &context); -} - -void -aap::AAPXSClientDispatcher::sendHostExtensionReply(const char *uri, int32_t opcode, void *data, int32_t dataSize, uint32_t requestId) { - auto aapxs = getHostAAPXSByUri(uri); - AAPXSRequestContext context{nullptr, nullptr, aapxs.serialization, uri, requestId, opcode}; - assert(aapxs.serialization->data_capacity >= dataSize); - memcpy(aapxs.serialization->data, data, dataSize); - aapxs.serialization->data_size = dataSize; - aapxs.send_aapxs_reply(&aapxs, &context); -} - -// Service send/receive +// Service setup -// setup -void aap::AAPXSServiceDispatcher::setupInstances(aap::AAPXSServiceFeatureRegistry *registry, +void aap::AAPXSServiceDispatcher::setupInstances(aap::AAPXSDefinitionServiceRegistry *registry, AAPXSSerializationContext *serialization, - initiator_get_new_request_id_func initiatorGetNewRequestId, - recipient_get_new_request_id_func recipientGetNewRequestId) { - std::for_each(registry->begin(), registry->end(), [&](AAPXSFeatureVNext* f) { + aap::aapxs_initiator_send_func sendAAPXSRequest, + aap::aapxs_initiator_receive_func processIncomingAAPXSReply, + aap::aapxs_recipient_receive_func processIncomingAapxsRequest, + aap::aapxs_recipient_send_func sendAapxsReply, + aap::initiator_get_new_request_id_func initiatorGetNewRequestId, + aap::recipient_get_new_request_id_func recipientGetNewRequestId) { + std::for_each(registry->begin(), registry->end(), [&](AAPXSDefinition* f) { // host extensions - addInitiator(populateAAPXSInitiatorInstance(serialization, initiatorGetNewRequestId), f->uri); + addInitiator(populateAAPXSInitiatorInstance(serialization, sendAAPXSRequest, processIncomingAAPXSReply, initiatorGetNewRequestId), f->uri); // plugin extensions - addRecipient(populateAAPXSRecipientInstance(serialization, recipientGetNewRequestId), f->uri); + addRecipient(populateAAPXSRecipientInstance(serialization, processIncomingAapxsRequest, sendAapxsReply, recipientGetNewRequestId), f->uri); }); } - AAPXSRecipientInstance aap::AAPXSServiceDispatcher::populateAAPXSRecipientInstance( - AAPXSSerializationContext *serialization, recipient_get_new_request_id_func getNewRequestId) { + AAPXSSerializationContext *serialization, + aap::aapxs_recipient_receive_func processIncomingAAPXSRequest, + aap::aapxs_recipient_send_func sendAAPXSReply, + recipient_get_new_request_id_func getNewRequestId) { AAPXSRecipientInstance instance{this, serialization, getNewRequestId, - staticProcessIncomingAAPXSRequest, - staticSendAAPXSReply}; + processIncomingAAPXSRequest, + sendAAPXSReply}; return instance; } AAPXSInitiatorInstance aap::AAPXSServiceDispatcher::populateAAPXSInitiatorInstance( - AAPXSSerializationContext *serialization, initiator_get_new_request_id_func getNewRequestId) { + AAPXSSerializationContext *serialization, + aapxs_initiator_send_func sendHostAAPXSRequest, + aapxs_initiator_receive_func processIncomingHostAAPXSReply, + initiator_get_new_request_id_func getNewRequestId) { AAPXSInitiatorInstance instance{this, serialization, getNewRequestId, - staticSendHostAAPXSRequest, - staticProcessIncomingHostAAPXSReply}; + sendHostAAPXSRequest, + processIncomingHostAAPXSReply}; return instance; } - -// send/receive -void -aap::AAPXSServiceDispatcher::processExtensionRequest(const char *uri, int32_t opcode, uint32_t requestId) { - auto aapxs = getPluginAAPXSByUri(uri); - AAPXSRequestContext context{nullptr, nullptr, aapxs.serialization, uri, requestId, opcode}; - aapxs.process_incoming_aapxs_request(&aapxs, &context); -} - -void -aap::AAPXSServiceDispatcher::sendExtensionReply(const char *uri, int32_t opcode, void *data, int32_t dataSize, uint32_t requestId) { - auto aapxs = getPluginAAPXSByUri(uri); - AAPXSRequestContext context{nullptr, nullptr, aapxs.serialization, uri, requestId, opcode}; - assert(aapxs.serialization->data_capacity >= dataSize); - memcpy(aapxs.serialization->data, data, dataSize); - aapxs.serialization->data_size = dataSize; - aapxs.send_aapxs_reply(&aapxs, &context); -} - -void -aap::AAPXSServiceDispatcher::sendHostExtensionRequest(const char* uri, int32_t opcode, void *data, int32_t dataSize, uint32_t newRequestId) { - auto aapxs = getHostAAPXSByUri(uri); - AAPXSRequestContext context{nullptr, nullptr, aapxs.serialization, uri, newRequestId, opcode}; - assert(aapxs.serialization->data_capacity >= dataSize); - memcpy(aapxs.serialization->data, data, dataSize); - aapxs.serialization->data_size = dataSize; - aapxs.send_aapxs_request(&aapxs, &context); -} - -void aap::AAPXSServiceDispatcher::processHostExtensionReply(const char *uri, int32_t opcode, uint32_t requestId) { - auto aapxs = getHostAAPXSByUri(uri); - AAPXSRequestContext context{nullptr, nullptr, aapxs.serialization, uri, requestId, opcode}; - aapxs.process_incoming_aapxs_reply(&aapxs, &context); -} diff --git a/androidaudioplugin/src/main/cpp/core/aapxs/presets-aapxs.cpp b/androidaudioplugin/src/main/cpp/core/aapxs/presets-aapxs.cpp index 0dc457fc..3390f94c 100644 --- a/androidaudioplugin/src/main/cpp/core/aapxs/presets-aapxs.cpp +++ b/androidaudioplugin/src/main/cpp/core/aapxs/presets-aapxs.cpp @@ -4,7 +4,7 @@ #include "aap/core/aapxs/aapxs-runtime.h" void aap::AAPXSFeaturePresets::aapxs_presets_process_incoming_plugin_aapxs_request( - struct AAPXSFeatureVNext *feature, AAPXSRecipientInstance *aapxsInstance, + struct AAPXSDefinition *feature, AAPXSRecipientInstance *aapxsInstance, AndroidAudioPlugin *plugin, AAPXSRequestContext *context) { auto ext = (aap_presets_extension_t*) plugin->get_extension(plugin, AAP_PRESETS_EXTENSION_URI); switch(context->opcode) { @@ -57,7 +57,7 @@ void aap::AAPXSFeaturePresets::aapxs_presets_process_incoming_plugin_aapxs_reque } void aap::AAPXSFeaturePresets::aapxs_presets_process_incoming_host_aapxs_request( - struct AAPXSFeatureVNext *feature, AAPXSRecipientInstance *aapxsInstance, + struct AAPXSDefinition *feature, AAPXSRecipientInstance *aapxsInstance, AndroidAudioPluginHost *host, AAPXSRequestContext *context) { auto ext = (aap_presets_host_extension_t*) host->get_extension(host, AAP_PRESETS_EXTENSION_URI); switch(context->opcode) { @@ -75,14 +75,14 @@ void aap::AAPXSFeaturePresets::aapxs_presets_process_incoming_host_aapxs_request } void aap::AAPXSFeaturePresets::aapxs_presets_process_incoming_plugin_aapxs_reply( - struct AAPXSFeatureVNext *feature, AAPXSInitiatorInstance *aapxsInstance, + struct AAPXSDefinition *feature, AAPXSInitiatorInstance *aapxsInstance, AndroidAudioPlugin *plugin, AAPXSRequestContext *request) { if (request->callback != nullptr) request->callback(request->callback_user_data, plugin, request->request_id); } void aap::AAPXSFeaturePresets::aapxs_presets_process_incoming_host_aapxs_reply( - struct AAPXSFeatureVNext *feature, AAPXSInitiatorInstance *aapxsInstance, + struct AAPXSDefinition *feature, AAPXSInitiatorInstance *aapxsInstance, AndroidAudioPluginHost *host, AAPXSRequestContext *context) { //auto ext = (aap_presets_host_extension_t*) host->get_extension(host, AAP_PRESETS_EXTENSION_URI); switch(context->opcode) { @@ -95,7 +95,7 @@ void aap::AAPXSFeaturePresets::aapxs_presets_process_incoming_host_aapxs_reply( } } -// Strongly-typed client implementation +// Strongly-typed client implementation (plugin extension functions) void aap::PresetsClientAAPXS::getPresetIntCallback(void* callbackContext, AndroidAudioPlugin* plugin, int32_t requestId) { auto callbackData = (WithPromise*) callbackContext; @@ -134,6 +134,7 @@ void aap::PresetsClientAAPXS::getPresetCallback(void* callbackContext, AndroidAu } void aap::PresetsClientAAPXS::getPreset(int32_t index, aap_preset_t &preset) { + // FIXME: use spinlock instead of std::promise and std::future, as getPresetCount() and getPresetIndex() must be RT_SAFE. std::promise promise{}; uint32_t requestId = initiatorInstance->get_new_request_id(initiatorInstance); auto future = promise.get_future(); @@ -161,16 +162,16 @@ void aap::PresetsClientAAPXS::setPresetIndex(int32_t index) { initiatorInstance->send_aapxs_request(initiatorInstance, &request); } -// Strongly-typed service implementation +// Strongly-typed service implementation (host extension functions) void aap::PresetsServiceAAPXS::notifyPresetLoaded() { - uint32_t requestId = recipientInstance->get_new_request_id(recipientInstance); + uint32_t requestId = initiatorInstance->get_new_request_id(initiatorInstance); AAPXSRequestContext context{nullptr, nullptr, serialization, AAP_PRESETS_EXTENSION_URI, requestId, OPCODE_NOTIFY_PRESET_LOADED}; - recipientInstance->process_incoming_aapxs_request(recipientInstance, &context); + initiatorInstance->send_aapxs_request(initiatorInstance, &context); } void aap::PresetsServiceAAPXS::notifyPresetsUpdated() { - uint32_t requestId = recipientInstance->get_new_request_id(recipientInstance); + uint32_t requestId = initiatorInstance->get_new_request_id(initiatorInstance); AAPXSRequestContext context{nullptr, nullptr, serialization, AAP_PRESETS_EXTENSION_URI, requestId, OPCODE_NOTIFY_PRESET_UPDATED}; - recipientInstance->process_incoming_aapxs_request(recipientInstance, &context); + initiatorInstance->send_aapxs_request(initiatorInstance, &context); } diff --git a/androidaudioplugin/src/main/cpp/core/aapxs/presets-aapxs.h b/androidaudioplugin/src/main/cpp/core/aapxs/presets-aapxs.h index 8be08fad..88c00835 100644 --- a/androidaudioplugin/src/main/cpp/core/aapxs/presets-aapxs.h +++ b/androidaudioplugin/src/main/cpp/core/aapxs/presets-aapxs.h @@ -23,7 +23,7 @@ namespace aap { protected: AAPXSFeatureImpl() {} public: - virtual AAPXSFeatureVNext* asPublic() = 0; + virtual AAPXSDefinition* asPublic() = 0; template static T correlate(AAPXSRequestContext request, std::function(std::promise promiseInner)> registerCallback, std::function getResult) { @@ -41,37 +41,37 @@ namespace aap { : public AAPXSFeatureImpl { static void aapxs_presets_process_incoming_plugin_aapxs_request( - struct AAPXSFeatureVNext* feature, + struct AAPXSDefinition* feature, AAPXSRecipientInstance* aapxsInstance, AndroidAudioPlugin* plugin, AAPXSRequestContext* context); static void aapxs_presets_process_incoming_host_aapxs_request( - struct AAPXSFeatureVNext* feature, + struct AAPXSDefinition* feature, AAPXSRecipientInstance* aapxsInstance, AndroidAudioPluginHost* host, AAPXSRequestContext* context); static void aapxs_presets_process_incoming_plugin_aapxs_reply( - struct AAPXSFeatureVNext* feature, + struct AAPXSDefinition* feature, AAPXSInitiatorInstance* aapxsInstance, AndroidAudioPlugin* plugin, AAPXSRequestContext* context); static void aapxs_presets_process_incoming_host_aapxs_reply( - struct AAPXSFeatureVNext* feature, + struct AAPXSDefinition* feature, AAPXSInitiatorInstance* aapxsInstance, AndroidAudioPluginHost* host, AAPXSRequestContext* context); - AAPXSFeatureVNext aapxs_presets{AAP_PRESETS_EXTENSION_URI, - nullptr, - PRESETS_SHARED_MEMORY_SIZE, - aapxs_presets_process_incoming_plugin_aapxs_request, - aapxs_presets_process_incoming_host_aapxs_request, - aapxs_presets_process_incoming_plugin_aapxs_reply, - aapxs_presets_process_incoming_host_aapxs_reply + AAPXSDefinition aapxs_presets{AAP_PRESETS_EXTENSION_URI, + nullptr, + PRESETS_SHARED_MEMORY_SIZE, + aapxs_presets_process_incoming_plugin_aapxs_request, + aapxs_presets_process_incoming_host_aapxs_request, + aapxs_presets_process_incoming_plugin_aapxs_reply, + aapxs_presets_process_incoming_host_aapxs_reply }; public: - AAPXSFeatureVNext * asPublic() override { + AAPXSDefinition * asPublic() override { return &aapxs_presets; } }; @@ -96,12 +96,12 @@ namespace aap { }; class PresetsServiceAAPXS { - AAPXSRecipientInstance *recipientInstance; + AAPXSInitiatorInstance *initiatorInstance; AAPXSSerializationContext *serialization; public: - PresetsServiceAAPXS(AAPXSRecipientInstance* instance, AAPXSSerializationContext* serialization) - : recipientInstance(instance), serialization(serialization) { + PresetsServiceAAPXS(AAPXSInitiatorInstance* instance, AAPXSSerializationContext* serialization) + : initiatorInstance(instance), serialization(serialization) { } void notifyPresetLoaded(); diff --git a/androidaudioplugin/src/main/cpp/core/hosting/AAPXSMidi2ClientSession.cpp b/androidaudioplugin/src/main/cpp/core/hosting/AAPXSMidi2ClientSession.cpp index b8558f40..756c47d7 100644 --- a/androidaudioplugin/src/main/cpp/core/hosting/AAPXSMidi2ClientSession.cpp +++ b/androidaudioplugin/src/main/cpp/core/hosting/AAPXSMidi2ClientSession.cpp @@ -27,8 +27,9 @@ std::future aap::AAPXSMidi2ClientSession::addSession( void* addMidi2EventUserData, int32_t group, int32_t requestId, - AAPXSClientInstance *aapxsInstance, - int32_t messageSize, + const char* uri, + void* data, + int32_t dataSize, int32_t opcode, std::promise promise) { size_t size = aap_midi2_generate_aapxs_sysex8((uint32_t*) aapxs_rt_midi_buffer, @@ -37,10 +38,10 @@ std::future aap::AAPXSMidi2ClientSession::addSession( midi_buffer_size, group, requestId, - aapxsInstance->uri, + uri, opcode, - (uint8_t*) aapxsInstance->data, - messageSize); + (uint8_t*) data, + dataSize); addMidi2Event(this, addMidi2EventUserData, size); promises[requestId] = std::move(promise); return promises[requestId].get_future(); diff --git a/androidaudioplugin/src/main/cpp/core/hosting/PluginInstance.Local.cpp b/androidaudioplugin/src/main/cpp/core/hosting/PluginInstance.Local.cpp index 7feb8480..0b610e94 100644 --- a/androidaudioplugin/src/main/cpp/core/hosting/PluginInstance.Local.cpp +++ b/androidaudioplugin/src/main/cpp/core/hosting/PluginInstance.Local.cpp @@ -21,7 +21,7 @@ aap::LocalPluginInstance::LocalPluginInstance(PluginHost *host, aapxs_registry(aapxsRegistry), aapxsServiceInstances([&]() { return getPlugin(); }), standards(this), - feature_registry(new AAPXSFeatureRegistryServiceImpl(this)), + feature_registry(new AAPXSDefinitionServiceRegistryImpl(this)), aapxs_dispatcher(AAPXSServiceDispatcher(feature_registry.get())) { shared_memory_store = new aap::ServicePluginSharedMemoryStore(); instance_id = instanceId; @@ -182,9 +182,49 @@ void aap::LocalPluginInstance::process(int32_t frameCount, int32_t timeoutInNano } // ---- AAPXS v2 +static inline void staticSendAAPXSRequest(AAPXSInitiatorInstance* instance, AAPXSRequestContext* context) { + ((aap::RemotePluginInstance*) instance->host_context)->sendAAPXSRequest(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, context->request_id); +} +static inline void staticProcessIncomingAAPXSReply(AAPXSInitiatorInstance* instance, AAPXSRequestContext* context) { + ((aap::RemotePluginInstance*) instance->host_context)->processAAPXSReply(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, context->request_id); +} +static inline void staticProcessIncomingAAPXSRequest(AAPXSRecipientInstance* instance, AAPXSRequestContext* context) { + ((aap::RemotePluginInstance*) instance->host_context)->processHostAAPXSRequest(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, context->request_id); +} +static inline void staticSendAAPXSReply(AAPXSRecipientInstance* instance, AAPXSRequestContext* context) { + ((aap::RemotePluginInstance*) instance->host_context)->sendHostAAPXSReply(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, context->request_id); +} + +void aap::LocalPluginInstance::setupAAPXSInstances(aap::AAPXSDefinitionServiceRegistry *registry, + AAPXSSerializationContext *serialization) { + aapxs_dispatcher.setupInstances(registry, serialization, + staticSendAAPXSRequest, + staticProcessIncomingAAPXSReply, + staticProcessIncomingAAPXSRequest, + staticSendAAPXSReply, + staticGetNewRequestId, + staticGetNewRequestId); +} + +void +aap::LocalPluginInstance::processAAPXSRequest(const char* uri, int32_t opcode, void *data, int32_t dataSize, uint32_t requestId) { + // FIXME: implement correctly + controlExtension(uri, opcode); +} +void +aap::LocalPluginInstance::sendAAPXSReply(const char* uri, int32_t opcode, void *data, int32_t dataSize, uint32_t newRequestId) { + // FIXME: implement + throw std::runtime_error("FIXME: implement"); +} + +void +aap::LocalPluginInstance::sendHostAAPXSRequest(const char* uri, int32_t opcode, void *data, int32_t dataSize, uint32_t newRequestId) { + // FIXME: implement + throw std::runtime_error("FIXME: implement"); +} -// initialization -void aap::LocalPluginInstance::setupAAPXSInstances(aap::AAPXSServiceFeatureRegistry *registry, - AAPXSSerializationContext *serialization) { - aapxs_dispatcher.setupInstances(registry, serialization, staticGetNewRequestId, staticGetNewRequestId); +void +aap::LocalPluginInstance::processHostAAPXSReply(const char* uri, int32_t opcode, void *data, int32_t dataSize, uint32_t requestId) { + // FIXME: implement + throw std::runtime_error("FIXME: implement"); } diff --git a/androidaudioplugin/src/main/cpp/core/hosting/PluginInstance.Remote.cpp b/androidaudioplugin/src/main/cpp/core/hosting/PluginInstance.Remote.cpp index 81bce722..8a034fd1 100644 --- a/androidaudioplugin/src/main/cpp/core/hosting/PluginInstance.Remote.cpp +++ b/androidaudioplugin/src/main/cpp/core/hosting/PluginInstance.Remote.cpp @@ -16,7 +16,7 @@ aap::RemotePluginInstance::RemotePluginInstance(PluginClient* client, standards(this), aapxs_manager(std::make_unique(this)), aapxs_session(eventMidi2InputBufferSize), - feature_registry(new AAPXSFeatureRegistryClientImpl(this)), + feature_registry(new AAPXSDefinitionClientRegistryImpl(this)), aapxs_dispatcher(AAPXSClientDispatcher(feature_registry.get())) { shared_memory_store = new ClientPluginSharedMemoryStore(); @@ -74,7 +74,7 @@ void aap::RemotePluginInstance::sendExtensionMessage(const char *uri, int32_t me int32_t group = 0; // will we have to give special semantics on it? int32_t requestId = aapxsRequestIdSerial(); std::promise promise; - auto future = aapxs_session.addSession(aapxsSessionAddEventUmpInput, this, group, requestId, aapxsInstance, messageSize, opcode, std::move(promise)); + auto future = aapxs_session.addSession(aapxsSessionAddEventUmpInput, this, group, requestId, uri, aapxsInstance->data, messageSize, opcode, std::move(promise)); // This is a synchronous function, so we have to wait for the result... future.wait(); } else { @@ -253,9 +253,71 @@ aap::RemoteAAPXSManager::staticProcessExtensionReply(AAPXSClientInstance *client } // ---- AAPXS v2 +static inline void staticSendAAPXSRequest(AAPXSInitiatorInstance* instance, AAPXSRequestContext* context) { + ((aap::RemotePluginInstance*) instance->host_context)->sendAAPXSRequest(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, context->request_id); +} +static inline void staticProcessIncomingAAPXSReply(AAPXSInitiatorInstance* instance, AAPXSRequestContext* context) { + ((aap::RemotePluginInstance*) instance->host_context)->processAAPXSReply(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, context->request_id); +} +static inline void staticProcessIncomingAAPXSRequest(AAPXSRecipientInstance* instance, AAPXSRequestContext* context) { + ((aap::RemotePluginInstance*) instance->host_context)->processHostAAPXSRequest(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, context->request_id); +} +static inline void staticSendAAPXSReply(AAPXSRecipientInstance* instance, AAPXSRequestContext* context) { + ((aap::RemotePluginInstance*) instance->host_context)->sendHostAAPXSReply(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, context->request_id); +} -// initialization -void aap::RemotePluginInstance::setupAAPXSInstances(aap::AAPXSClientFeatureRegistry *registry, +void aap::RemotePluginInstance::setupAAPXSInstances(aap::AAPXSDefinitionClientRegistry *registry, AAPXSSerializationContext *serialization) { - aapxs_dispatcher.setupInstances(registry, serialization, staticGetNewRequestId, staticGetNewRequestId); + aapxs_dispatcher.setupInstances(registry, serialization, + staticSendAAPXSRequest, + staticProcessIncomingAAPXSReply, + staticProcessIncomingAAPXSRequest, + staticSendAAPXSReply, + staticGetNewRequestId, + staticGetNewRequestId); +} + +void +aap::RemotePluginInstance::sendAAPXSRequest(const char* uri, int32_t opcode, void *data, int32_t dataSize, uint32_t newRequestId) { + auto aapxsInstance = aapxs_dispatcher.getPluginAAPXSByUri(uri); + + // If it is at ACTIVE state it has to switch to AAPXS SysEx8 MIDI messaging mode, + // otherwise it goes to the Binder route. + if (instantiation_state == PLUGIN_INSTANTIATION_STATE_ACTIVE) { + // aapxsInstance already contains binary data here, so we retrieve data from there. + int32_t group = 0; // will we have to give special semantics on it? + int32_t requestId = aapxsRequestIdSerial(); + std::promise promise; + aapxs_session.addSession(aapxsSessionAddEventUmpInput, this, group, requestId, uri, aapxsInstance.serialization->data, dataSize, opcode, std::move(promise)); + // This is an synchronous function, so we do not wait for the result. + } else { + // Here we have to get a native plugin instance and send extension message. + // It is kind af annoying because we used to implement Binder-specific part only within the + // plugin API (binder-client-as-plugin.cpp)... + // So far, instead of rewriting a lot of code to do so, we let AAPClientContext + // assign its implementation details that handle Binder messaging as a std::function. + ipc_send_extension_message_impl(plugin->plugin_specific, uri, getInstanceId(), dataSize, opcode); + } +} + +void +aap::RemotePluginInstance::processAAPXSReply(const char* uri, int32_t opcode, void *data, int32_t dataSize, uint32_t requestId) { + if (instantiation_state == PLUGIN_INSTANTIATION_STATE_ACTIVE) { + aapxs_session.promises[requestId].set_value(0); + aapxs_session.promises.erase(requestId); + } else { + // nothing to do when non-realtime mode; extension functions are called synchronously. + } } + +void +aap::RemotePluginInstance::sendHostAAPXSReply(const char* uri, int32_t opcode, void *data, int32_t dataSize, uint32_t newRequestId) { + // FIXME: implement + throw std::runtime_error("FIXME: implement"); +} + +void +aap::RemotePluginInstance::processHostAAPXSRequest(const char* uri, int32_t opcode, void *data, int32_t dataSize, uint32_t requestId) { + // FIXME: implement + throw std::runtime_error("FIXME: implement"); +} \ No newline at end of file diff --git a/androidaudioplugin/src/main/cpp/core/hosting/PluginInstance.cpp b/androidaudioplugin/src/main/cpp/core/hosting/PluginInstance.cpp index a852a3ab..ba3850c8 100644 --- a/androidaudioplugin/src/main/cpp/core/hosting/PluginInstance.cpp +++ b/androidaudioplugin/src/main/cpp/core/hosting/PluginInstance.cpp @@ -244,12 +244,12 @@ uint32_t aap::PluginInstance::aapxsRequestIdSerial() { } void -aap::AAPXSFeatureRegistryClientImpl::setupClientInstances( +aap::AAPXSDefinitionClientRegistryImpl::setupClientInstances( aap::AAPXSClientDispatcher *client, AAPXSSerializationContext* serialization) { instance->setupAAPXSInstances(this, serialization); } -void aap::AAPXSFeatureRegistryServiceImpl::setupServiceInstances( +void aap::AAPXSDefinitionServiceRegistryImpl::setupServiceInstances( aap::AAPXSServiceDispatcher *service, AAPXSSerializationContext* serialization) { instance->setupAAPXSInstances(this, serialization); } diff --git a/include/aap/core/AAPXSMidi2ClientSession.h b/include/aap/core/AAPXSMidi2ClientSession.h index 588cbafe..5a24dfdc 100644 --- a/include/aap/core/AAPXSMidi2ClientSession.h +++ b/include/aap/core/AAPXSMidi2ClientSession.h @@ -31,8 +31,9 @@ namespace aap { void* addMidi2EventUserData, int32_t group, int32_t requestId, - AAPXSClientInstance *aapxsInstance, - int32_t messageSize, + const char* uri, + void* data, + int32_t dataSize, int32_t opcode, std::promise promise); diff --git a/include/aap/core/aapxs/aapxs-runtime.h b/include/aap/core/aapxs/aapxs-runtime.h index f5dc9ea8..14290064 100644 --- a/include/aap/core/aapxs/aapxs-runtime.h +++ b/include/aap/core/aapxs/aapxs-runtime.h @@ -61,16 +61,16 @@ namespace aap { }; template - class AAPXSFeatureMapVNext { + class AAPXSUridMapping { UridMapping urid_mapping{}; std::vector items{}; bool frozen{false}; public: - AAPXSFeatureMapVNext() { + AAPXSUridMapping() { items.resize(UINT8_MAX); } - virtual ~AAPXSFeatureMapVNext() {} + virtual ~AAPXSUridMapping() {} UridMapping* getUridMapping() { return &urid_mapping; } @@ -99,14 +99,18 @@ namespace aap { const_iterator end() const { return items.end(); } }; - class AAPXSInitiatorInstanceMap : public AAPXSFeatureMapVNext {}; - class AAPXSRecipientInstanceMap : public AAPXSFeatureMapVNext {}; + class AAPXSInitiatorInstanceMap : public AAPXSUridMapping {}; + class AAPXSRecipientInstanceMap : public AAPXSUridMapping {}; - class AAPXSClientFeatureRegistry; - class AAPXSServiceFeatureRegistry; + class AAPXSDefinitionClientRegistry; + class AAPXSDefinitionServiceRegistry; typedef uint32_t (*initiator_get_new_request_id_func) (AAPXSInitiatorInstance* instance); typedef uint32_t (*recipient_get_new_request_id_func) (AAPXSRecipientInstance* instance); + typedef void (*aapxs_initiator_send_func) (AAPXSInitiatorInstance* instance, AAPXSRequestContext* context); + typedef void (*aapxs_initiator_receive_func) (AAPXSInitiatorInstance* instance, AAPXSRequestContext* context); + typedef void (*aapxs_recipient_send_func) (AAPXSRecipientInstance* instance, AAPXSRequestContext* context); + typedef void (*aapxs_recipient_receive_func) (AAPXSRecipientInstance* instance, AAPXSRequestContext* context); class AAPXSDispatcher { protected: @@ -118,96 +122,73 @@ namespace aap { }; class AAPXSClientDispatcher : public AAPXSDispatcher { - AAPXSInitiatorInstance - populateAAPXSInitiatorInstance(AAPXSSerializationContext *serialization, initiator_get_new_request_id_func initiatorGetNewRequestId); + populateAAPXSInitiatorInstance(AAPXSSerializationContext *serialization, + aapxs_initiator_send_func sendAAPXSRequest, + aapxs_initiator_receive_func processIncomingAAPXSReply, + initiator_get_new_request_id_func getNewRequestId); AAPXSRecipientInstance - populateAAPXSRecipientInstance(AAPXSSerializationContext *serialization, recipient_get_new_request_id_func recipientGetNewRequestId); - - static inline void staticSendAAPXSRequest(AAPXSInitiatorInstance* instance, AAPXSRequestContext* context) { - auto manager = (AAPXSClientDispatcher*) instance->host_context; - manager->sendExtensionRequest(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, instance->get_new_request_id(instance)); - } - static inline void staticProcessIncomingAAPXSReply(AAPXSInitiatorInstance* instance, AAPXSRequestContext* context) { - auto manager = (AAPXSClientDispatcher*) instance->host_context; - manager->processExtensionReply(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, context->request_id); - } - static inline void staticProcessIncomingAAPXSRequest(AAPXSRecipientInstance* instance, AAPXSRequestContext* context) { - auto manager = (AAPXSClientDispatcher*) instance->host_context; - manager->processHostExtensionRequest(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, context->request_id); - } - static inline void staticSendAAPXSReply(AAPXSRecipientInstance* instance, AAPXSRequestContext* context) { - auto manager = (AAPXSClientDispatcher*) instance->host_context; - manager->sendHostExtensionReply(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, context->request_id); - } + populateAAPXSRecipientInstance(AAPXSSerializationContext *serialization, + aapxs_recipient_receive_func processIncomingAapxsRequest, + aapxs_recipient_send_func sendAapxsReply, + recipient_get_new_request_id_func recipientGetNewRequestId); public: - AAPXSClientDispatcher(AAPXSClientFeatureRegistry* registry); + AAPXSClientDispatcher(AAPXSDefinitionClientRegistry* registry); inline AAPXSInitiatorInstance& getPluginAAPXSByUri(const char* uri) { return initiators.getByUri(uri); } inline AAPXSInitiatorInstance& getPluginAAPXSByUrid(uint8_t urid) { return initiators.getByUrid(urid); }; inline AAPXSRecipientInstance& getHostAAPXSByUri(const char* uri) { return recipients.getByUri(uri); } inline AAPXSRecipientInstance& getHostAAPXSByUrid(uint8_t urid) { return recipients.getByUrid(urid); }; - void sendExtensionRequest(const char* uri, int32_t opcode, void *data, int32_t dataSize, uint32_t newRequestId); - void processExtensionReply(const char *uri, int32_t opcode, void* data, int32_t dataSize, uint32_t requestId); - void processHostExtensionRequest(const char *uri, int32_t opcode, void* data, int32_t dataSize, uint32_t requestId); - void sendHostExtensionReply(const char *uri, int32_t opcode, void *data, int32_t dataSize, uint32_t requestId); - void - setupInstances(AAPXSClientFeatureRegistry *registry, + setupInstances(AAPXSDefinitionClientRegistry *registry, AAPXSSerializationContext *serialization, + aapxs_initiator_send_func sendAAPXSRequest, + aapxs_initiator_receive_func processIncomingAAPXSReply, + aapxs_recipient_receive_func processIncomingAAPXSRequestFunc, + aapxs_recipient_send_func sendAAPXSReplyFunc, initiator_get_new_request_id_func initiatorGetNewRequestId, recipient_get_new_request_id_func recipientGetNewRequestId); }; class AAPXSServiceDispatcher : public AAPXSDispatcher { - AAPXSInitiatorInstance populateAAPXSInitiatorInstance(AAPXSSerializationContext* serialization, initiator_get_new_request_id_func getNewRequestId); - AAPXSRecipientInstance populateAAPXSRecipientInstance(AAPXSSerializationContext* serialization, recipient_get_new_request_id_func getNewRequestId); - - static inline void staticSendHostAAPXSRequest(AAPXSInitiatorInstance* instance, AAPXSRequestContext* context) { - auto manager = (AAPXSServiceDispatcher*) instance->host_context; - manager->sendHostExtensionRequest(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, instance->get_new_request_id(instance)); - } - static inline void staticProcessIncomingAAPXSRequest(AAPXSRecipientInstance* instance, AAPXSRequestContext* context) { - auto manager = (AAPXSServiceDispatcher*) instance->host_context; - manager->processExtensionRequest(context->uri, context->opcode, context->request_id); - } - static inline void staticProcessIncomingHostAAPXSReply(AAPXSInitiatorInstance* instance, AAPXSRequestContext* context) { - auto manager = (AAPXSServiceDispatcher*) instance->host_context; - manager->processHostExtensionReply(context->uri, context->opcode, context->request_id); - } - static inline void staticSendAAPXSReply(AAPXSRecipientInstance* instance, AAPXSRequestContext* context) { - auto manager = (AAPXSServiceDispatcher*) instance->host_context; - manager->sendExtensionReply(context->uri, context->opcode, context->serialization->data, context->serialization->data_size, context->request_id); - } + AAPXSInitiatorInstance populateAAPXSInitiatorInstance( + AAPXSSerializationContext* serialization, + aapxs_initiator_send_func sendHostAAPXSRequest, + aapxs_initiator_receive_func processIncomingHostAAPXSReply, + initiator_get_new_request_id_func getNewRequestId); + AAPXSRecipientInstance populateAAPXSRecipientInstance( + AAPXSSerializationContext* serialization, + aap::aapxs_recipient_receive_func processIncomingAAPXSRequest, + aap::aapxs_recipient_send_func sendAAPXSReply, + recipient_get_new_request_id_func getNewRequestId); public: - AAPXSServiceDispatcher(AAPXSServiceFeatureRegistry* registry); + AAPXSServiceDispatcher(AAPXSDefinitionServiceRegistry* registry); AAPXSRecipientInstance& getPluginAAPXSByUri(const char* uri) { return recipients.getByUri(uri); } AAPXSRecipientInstance& getPluginAAPXSByUrid(uint8_t urid) { return recipients.getByUrid(urid); }; AAPXSInitiatorInstance& getHostAAPXSByUri(const char* uri) { return initiators.getByUri(uri); } AAPXSInitiatorInstance& getHostAAPXSByUrid(uint8_t urid) { return initiators.getByUrid(urid); }; - void processExtensionRequest(const char *uri, int32_t opcode, uint32_t requestId); - void sendHostExtensionRequest(const char* uri, int32_t opcode, void *data, int32_t dataSize, uint32_t newRequestId); - void processHostExtensionReply(const char *uri, int32_t opcode, uint32_t requestId); - void sendExtensionReply(const char* uri, int32_t opcode, void* data, int32_t dataSize, uint32_t requestId); - void - setupInstances(AAPXSServiceFeatureRegistry *registry, + setupInstances(AAPXSDefinitionServiceRegistry *registry, AAPXSSerializationContext *serialization, + aapxs_initiator_send_func sendAAPXSRequest, + aapxs_initiator_receive_func processIncomingAAPXSReply, + aapxs_recipient_receive_func processIncomingAapxsRequest, + aapxs_recipient_send_func sendAapxsReply, initiator_get_new_request_id_func initiatorGetNewRequestId, recipient_get_new_request_id_func recipientGetNewRequestId); }; - class AAPXSClientFeatureRegistry : public AAPXSFeatureMapVNext { + class AAPXSDefinitionClientRegistry : public AAPXSUridMapping { public: virtual void setupClientInstances(aap::AAPXSClientDispatcher *client, AAPXSSerializationContext* serialization) = 0; }; - class AAPXSServiceFeatureRegistry : public AAPXSFeatureMapVNext { + class AAPXSDefinitionServiceRegistry : public AAPXSUridMapping { public: virtual void setupServiceInstances(aap::AAPXSServiceDispatcher *client, AAPXSSerializationContext* serialization) = 0; }; diff --git a/include/aap/core/host/plugin-instance.h b/include/aap/core/host/plugin-instance.h index 61c4475c..346ee68c 100644 --- a/include/aap/core/host/plugin-instance.h +++ b/include/aap/core/host/plugin-instance.h @@ -23,8 +23,8 @@ namespace aap { class PluginHost; class PluginClient; - class AAPXSFeatureRegistryClientImpl; - class AAPXSFeatureRegistryServiceImpl; + class AAPXSDefinitionClientRegistryImpl; + class AAPXSDefinitionServiceRegistryImpl; /** * The common basis for client RemotePluginInstance and service LocalPluginInstance. @@ -235,10 +235,13 @@ namespace aap { // AAPXS v2 AAPXSServiceDispatcher& getAAPXSDispatcher() { return aapxs_dispatcher; } - void setupAAPXSInstances(AAPXSServiceFeatureRegistry *registry, - AAPXSSerializationContext *serialization); + void setupAAPXSInstances(AAPXSDefinitionServiceRegistry *registry, AAPXSSerializationContext *serialization); + void processAAPXSRequest(const char *uri, int32_t opcode, void *data, int32_t dataSize, uint32_t requestId); + void sendAAPXSReply(const char *uri, int32_t opcode, void *data, int32_t dataSize, uint32_t newRequestId); + void sendHostAAPXSRequest(const char *uri, int32_t opcode, void *data, int32_t dataSize, uint32_t newRequestId); + void processHostAAPXSReply(const char *uri, int32_t opcode, void *data, int32_t dataSize, uint32_t requestId); private: - std::unique_ptr feature_registry; + std::unique_ptr feature_registry; AAPXSServiceDispatcher aapxs_dispatcher; }; @@ -347,11 +350,13 @@ namespace aap { // AAPXS v2 inline AAPXSClientDispatcher& getAAPXSDispatcher() { return aapxs_dispatcher; } - // delegated implementation for AAPXSFeatureRegistryClientImpl - void setupAAPXSInstances(aap::AAPXSClientFeatureRegistry *registry, - AAPXSSerializationContext *serialization); + void setupAAPXSInstances(aap::AAPXSDefinitionClientRegistry *registry, AAPXSSerializationContext *serialization); + void sendAAPXSRequest(const char *uri, int32_t opcode, void *data, int32_t dataSize, uint32_t newRequestId); + void processAAPXSReply(const char *uri, int32_t opcode, void *data, int32_t dataSize, uint32_t requestId); + void sendHostAAPXSReply(const char *uri, int32_t opcode, void *data, int32_t dataSize, uint32_t newRequestId); + void processHostAAPXSRequest(const char *uri, int32_t opcode, void *data, int32_t dataSize, uint32_t requestId); private: - std::unique_ptr feature_registry; + std::unique_ptr feature_registry; AAPXSClientDispatcher aapxs_dispatcher; }; @@ -379,18 +384,18 @@ namespace aap { AAPXSClientInstance *setupAAPXSInstance(AAPXSFeature *feature, int32_t dataSize) override; }; - class AAPXSFeatureRegistryClientImpl : public AAPXSClientFeatureRegistry { + class AAPXSDefinitionClientRegistryImpl : public AAPXSDefinitionClientRegistry { RemotePluginInstance* instance; public: - AAPXSFeatureRegistryClientImpl(RemotePluginInstance* instance) : instance(instance) {} + AAPXSDefinitionClientRegistryImpl(RemotePluginInstance* instance) : instance(instance) {} void setupClientInstances(aap::AAPXSClientDispatcher *client, AAPXSSerializationContext* serialization) override; }; - class AAPXSFeatureRegistryServiceImpl : public AAPXSServiceFeatureRegistry { + class AAPXSDefinitionServiceRegistryImpl : public AAPXSDefinitionServiceRegistry { LocalPluginInstance* instance; public: - AAPXSFeatureRegistryServiceImpl(LocalPluginInstance* instance) : instance(instance) {} + AAPXSDefinitionServiceRegistryImpl(LocalPluginInstance* instance) : instance(instance) {} void setupServiceInstances(aap::AAPXSServiceDispatcher *client, AAPXSSerializationContext* serialization) override; }; diff --git a/include/aap/unstable/aapxs-vnext.h b/include/aap/unstable/aapxs-vnext.h index f793acfe..cadd509e 100644 --- a/include/aap/unstable/aapxs-vnext.h +++ b/include/aap/unstable/aapxs-vnext.h @@ -58,8 +58,8 @@ typedef struct AAPXSRecipientInstance { // - FIXME: this may become framework reference implementation uint32_t (*get_new_request_id) (AAPXSRecipientInstance* instance); - // assigned by: AAPXS developer - // invoked by: framework reference implementation + // assigned by: framework reference implementation + // invoked by: AAPXS developer void (*process_incoming_aapxs_request) (AAPXSRecipientInstance* instance, AAPXSRequestContext* context); // assigned by: framework reference implementation @@ -67,30 +67,59 @@ typedef struct AAPXSRecipientInstance { void (*send_aapxs_reply) (AAPXSRecipientInstance* instance, AAPXSRequestContext* context); } AAPXSRecipientInstance; -typedef struct AAPXSFeatureVNext { +/** + * The "untyped" AAPXS definition (in the public API surface). + * Each AAPXS needs to provide an instance of this type so that host framework (reference + * implementation) can register at its AAPXS map. + * + * This type provides a handful of handler functions to deal with AAPXS requests and replies, for + * both the "plugin extension" and the "host extension". + * They are implemented and assigned by each AAPXS implementation, and invoked by the host framework + * (reference implementation) that would delegate to each strongly-typed AAPXS function (which is + * hidden behind `aapxs_context` opaque pointer). + */ +typedef struct AAPXSDefinition { + /** The extension URI */ const char *uri; + /** An opaque pointer to the AAPXS developers' context. + * It should be assigned and used only by the AAPXS developers of the extension. + */ void *aapxs_context; - int32_t data_size; - + /** + * The data capacity that is used to allocate shared memory for the binary transfer storage (Binder/SysEx8). + */ + int32_t data_capacity; + + /** Invoked when a plugin extension request has arrived at the service. + * Assigned by the host framework (reference implementation). + * Invoked by each AAPXS implementation. + * + * The parameter `definition` provides access to aapxs_context to help AAPXS developers encapsulate the implementation details. + * + * @param definition The containing AAPXSDefinition. + * @param aapxsInstance + * @param plugin The target plugin + * @param context The request context that provides access to data, opcode, request ID, etc. + */ void (*process_incoming_plugin_aapxs_request) ( - struct AAPXSFeatureVNext* feature, + struct AAPXSDefinition* definition, AAPXSRecipientInstance* aapxsInstance, AndroidAudioPlugin* plugin, AAPXSRequestContext* context); void (*process_incoming_host_aapxs_request) ( - struct AAPXSFeatureVNext* feature, + struct AAPXSDefinition* definition, AAPXSRecipientInstance* aapxsInstance, AndroidAudioPluginHost* host, AAPXSRequestContext* context); void (*process_incoming_plugin_aapxs_reply) ( - struct AAPXSFeatureVNext* feature, + struct AAPXSDefinition* definition, AAPXSInitiatorInstance* aapxsInstance, AndroidAudioPlugin* plugin, AAPXSRequestContext* context); void (*process_incoming_host_aapxs_reply) ( - struct AAPXSFeatureVNext* feature, + struct AAPXSDefinition* definition, AAPXSInitiatorInstance* aapxsInstance, AndroidAudioPluginHost* host, AAPXSRequestContext* context);