From 6300df0be037da173f2d4affd1d8159b1f5b831a Mon Sep 17 00:00:00 2001 From: Iscle Date: Tue, 23 Aug 2022 07:47:06 +0000 Subject: [PATCH] Add name and implementor to descriptor struct --- src/cpp/viper.cpp | 87 ++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/src/cpp/viper.cpp b/src/cpp/viper.cpp index c894486..13e82ce 100644 --- a/src/cpp/viper.cpp +++ b/src/cpp/viper.cpp @@ -1,10 +1,12 @@ #include -#include "Effect.h" #include "ProcessUnit_FX.h" #include "constants.h" #include "log.h" +#define EFFECT_NAME "ViPER4Android Reworked [" VERSION_STRING "]" +#define EFFECT_IMPLEMENTOR "ViPER.WYF, Martmists, Iscle" + static effect_descriptor_t viper_descriptor = { // Identical type/uuid to original ViPER4Android .type = {0x00000000, 0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}, @@ -13,118 +15,117 @@ static effect_descriptor_t viper_descriptor = { .flags = EFFECT_FLAG_OUTPUT_BOTH | EFFECT_FLAG_INPUT_BOTH | EFFECT_FLAG_INSERT_LAST | EFFECT_FLAG_TYPE_INSERT, .cpuLoad = 8, // In 0.1 MIPS units as estimated on an ARM9E core (ARMv5TE) with 0 WS .memoryUsage = 1, // In KB and includes only dynamically allocated memory + .name = EFFECT_NAME, + .implementor = EFFECT_IMPLEMENTOR }; extern "C" { struct ViperContext { - const struct effect_interface_s *interface; + const struct effect_interface_s *interface; // Should always be the first struct member ProcessUnit_FX *effect; - effect_descriptor_t *descriptor; }; -static int32_t viper_process(effect_handle_t self, audio_buffer_t *in, audio_buffer_t *out) { +static int32_t ViperProcess(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer) { auto pContext = (ViperContext *) self; if (pContext == nullptr) { - v4a_printf(ANDROID_LOG_ERROR, "viper_process(), Error [pContext = NULL]"); + v4a_printf(ANDROID_LOG_ERROR, "ViperProcess(), Error [pContext = NULL]"); return -EINVAL; } - if (in == nullptr) { - v4a_printf(ANDROID_LOG_ERROR, "viper_process(), Error [in = NULL]"); + if (inBuffer == nullptr) { + v4a_printf(ANDROID_LOG_ERROR, "ViperProcess(), Error [inBuffer = NULL]"); return -EINVAL; } - if (out == nullptr) { - v4a_printf(ANDROID_LOG_ERROR, "viper_process(), Error [out = NULL]"); + if (outBuffer == nullptr) { + v4a_printf(ANDROID_LOG_ERROR, "ViperProcess(), Error [outBuffer = NULL]"); return -EINVAL; } - return pContext->effect->process(in, out); + return pContext->effect->process(inBuffer, outBuffer); } static int32_t -viper_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, +ViperCommand(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData) { auto pContext = (ViperContext *) self; if (pContext == nullptr) { - v4a_printf(ANDROID_LOG_ERROR, "viper_command(), Error [pContext = NULL]"); + v4a_printf(ANDROID_LOG_ERROR, "ViperCommand(), Error [pContext = NULL]"); return -EINVAL; } return pContext->effect->command(cmdCode, cmdSize, pCmdData, replySize, pReplyData); } -static int32_t viper_get_descriptor(effect_handle_t self, effect_descriptor_t *pDescriptor) { +static int32_t ViperGetDescriptor(effect_handle_t self, effect_descriptor_t *pDescriptor) { auto *pContext = (ViperContext *) self; if (pContext == nullptr) { - v4a_printf(ANDROID_LOG_ERROR, "viper_get_descriptor(), Error [pContext = NULL]"); + v4a_printf(ANDROID_LOG_ERROR, "ViperGetDescriptor(), Error [pContext = NULL]"); return -EINVAL; } if (pDescriptor == nullptr) { - v4a_print(ANDROID_LOG_ERROR, "viper_get_descriptor(), Error [pDescriptor = NULL]"); + v4a_print(ANDROID_LOG_ERROR, "ViperGetDescriptor(), Error [pDescriptor = NULL]"); return -EINVAL; } - *pDescriptor = *pContext->descriptor; + *pDescriptor = viper_descriptor; return 0; } const effect_interface_s viper_interface = { - .process = viper_process, - .command = viper_command, - .get_descriptor = viper_get_descriptor + .process = ViperProcess, + .command = ViperCommand, + .get_descriptor = ViperGetDescriptor }; -int32_t viper_effect_create(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle) { - v4a_print(ANDROID_LOG_INFO, "Enter viper_effect_create()"); +int32_t ViperEffectCreate(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle) { + v4a_print(ANDROID_LOG_INFO, "Enter ViperEffectCreate()"); if (uuid == nullptr) { - v4a_printf(ANDROID_LOG_ERROR, "viper_effect_create(), Error [uuid = NULL]"); + v4a_printf(ANDROID_LOG_ERROR, "ViperEffectCreate(), Error [uuid = NULL]"); return -EINVAL; } if (pHandle == nullptr) { - v4a_printf(ANDROID_LOG_ERROR, "viper_effect_create(), Error [pHandle = NULL]"); + v4a_printf(ANDROID_LOG_ERROR, "ViperEffectCreate(), Error [pHandle = NULL]"); return -EINVAL; } if (memcmp(uuid, &viper_descriptor.uuid, sizeof(effect_uuid_t)) != 0) { - v4a_print(ANDROID_LOG_ERROR, "viper_effect_create(), Error [effect not found]"); + v4a_print(ANDROID_LOG_ERROR, "ViperEffectCreate(), Error [effect not found]"); return -EINVAL; } - v4a_printf(ANDROID_LOG_INFO, "viper_effect_create(), uuid = %08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x", + v4a_printf(ANDROID_LOG_INFO, "ViperEffectCreate(), uuid = %08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x", uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion, uuid->clockSeq, uuid->node[0], uuid->node[1], uuid->node[2], uuid->node[3], uuid->node[4], uuid->node[5]); - v4a_print(ANDROID_LOG_INFO, "viper_effect_create(), v4a standard effect (normal), Constructing ProcessUnit_FX"); + v4a_print(ANDROID_LOG_INFO, "ViperEffectCreate(), Constructing ProcessUnit_FX"); auto *pContext = new ViperContext; pContext->interface = &viper_interface; pContext->effect = new ProcessUnit_FX(); - pContext->descriptor = &viper_descriptor; - v4a_print(ANDROID_LOG_INFO, "Creating ViPER4Android Reworked [" VERSION_STRING "]"); *pHandle = (effect_handle_t) pContext; return 0; } -int32_t viper_effect_release(effect_handle_t handle) { +int32_t ViperEffectRelease(effect_handle_t handle) { auto *pContext = (ViperContext *) handle; - v4a_print(ANDROID_LOG_INFO, "Enter viper_effect_release()"); + v4a_print(ANDROID_LOG_INFO, "Enter ViperEffectRelease()"); if (pContext == nullptr) { - v4a_printf(ANDROID_LOG_ERROR, "viper_effect_release(), Error [pContext = NULL]"); + v4a_printf(ANDROID_LOG_ERROR, "ViperEffectRelease(), Error [pContext = NULL]"); return -EINVAL; } - v4a_print(ANDROID_LOG_INFO, "viper_effect_release(), Deconstructing ProcessUnit"); + v4a_print(ANDROID_LOG_INFO, "ViperEffectRelease(), Deconstructing ProcessUnit"); if (pContext->effect != nullptr) { delete pContext->effect; @@ -135,25 +136,25 @@ int32_t viper_effect_release(effect_handle_t handle) { return 0; } -int32_t viper_effect_get_descriptor(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor) { - v4a_print(ANDROID_LOG_INFO, "Enter viper_effect_get_descriptor()"); +int32_t ViperEffectGetDescriptor(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor) { + v4a_print(ANDROID_LOG_INFO, "Enter ViperEffectGetDescriptor()"); if (uuid == nullptr) { - v4a_printf(ANDROID_LOG_ERROR, "viper_effect_get_descriptor(), Error [uuid = NULL]"); + v4a_printf(ANDROID_LOG_ERROR, "ViperEffectGetDescriptor(), Error [uuid = NULL]"); return -EINVAL; } if (pDescriptor == nullptr) { - v4a_printf(ANDROID_LOG_ERROR, "viper_effect_get_descriptor(), Error [pDescriptor = NULL]"); + v4a_printf(ANDROID_LOG_ERROR, "ViperEffectGetDescriptor(), Error [pDescriptor = NULL]"); return -EINVAL; } if (memcmp(uuid, &viper_descriptor.uuid, sizeof(effect_uuid_t)) != 0) { - v4a_print(ANDROID_LOG_ERROR, "viper_effect_get_descriptor(), Error [effect not found]"); + v4a_print(ANDROID_LOG_ERROR, "ViperEffectGetDescriptor(), Error [effect not found]"); return -EINVAL; } - v4a_printf(ANDROID_LOG_INFO, "viper_effect_get_descriptor(), uuid = %08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x", + v4a_printf(ANDROID_LOG_INFO, "ViperEffectGetDescriptor(), uuid = %08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x", uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion, uuid->clockSeq, uuid->node[0], uuid->node[1], uuid->node[2], uuid->node[3], uuid->node[4], uuid->node[5]); @@ -165,10 +166,10 @@ int32_t viper_effect_get_descriptor(const effect_uuid_t *uuid, effect_descriptor audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = { .tag = AUDIO_EFFECT_LIBRARY_TAG, .version = EFFECT_LIBRARY_API_VERSION, - .name = "ViPER4Android FX Reworked", - .implementor = "ViPER.WYF, Martmists, Iscle", - .create_effect = viper_effect_create, - .release_effect = viper_effect_release, - .get_descriptor = viper_effect_get_descriptor, + .name = EFFECT_NAME, + .implementor = EFFECT_IMPLEMENTOR, + .create_effect = ViperEffectCreate, + .release_effect = ViperEffectRelease, + .get_descriptor = ViperEffectGetDescriptor, }; }