mirror of
https://github.com/AndroidAudioMods/ViPERFX_RE.git
synced 2025-06-08 10:39:29 +08:00
Add name and implementor to descriptor struct
This commit is contained in:
parent
926aec54bb
commit
6300df0be0
@ -1,10 +1,12 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "Effect.h"
|
|
||||||
#include "ProcessUnit_FX.h"
|
#include "ProcessUnit_FX.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
#define EFFECT_NAME "ViPER4Android Reworked [" VERSION_STRING "]"
|
||||||
|
#define EFFECT_IMPLEMENTOR "ViPER.WYF, Martmists, Iscle"
|
||||||
|
|
||||||
static effect_descriptor_t viper_descriptor = {
|
static effect_descriptor_t viper_descriptor = {
|
||||||
// Identical type/uuid to original ViPER4Android
|
// Identical type/uuid to original ViPER4Android
|
||||||
.type = {0x00000000, 0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
|
.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,
|
.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
|
.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
|
.memoryUsage = 1, // In KB and includes only dynamically allocated memory
|
||||||
|
.name = EFFECT_NAME,
|
||||||
|
.implementor = EFFECT_IMPLEMENTOR
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
struct ViperContext {
|
struct ViperContext {
|
||||||
const struct effect_interface_s *interface;
|
const struct effect_interface_s *interface; // Should always be the first struct member
|
||||||
ProcessUnit_FX *effect;
|
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;
|
auto pContext = (ViperContext *) self;
|
||||||
|
|
||||||
if (pContext == nullptr) {
|
if (pContext == nullptr) {
|
||||||
v4a_printf(ANDROID_LOG_ERROR, "viper_process(), Error [pContext = NULL]");
|
v4a_printf(ANDROID_LOG_ERROR, "ViperProcess(), Error [pContext = NULL]");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in == nullptr) {
|
if (inBuffer == nullptr) {
|
||||||
v4a_printf(ANDROID_LOG_ERROR, "viper_process(), Error [in = NULL]");
|
v4a_printf(ANDROID_LOG_ERROR, "ViperProcess(), Error [inBuffer = NULL]");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out == nullptr) {
|
if (outBuffer == nullptr) {
|
||||||
v4a_printf(ANDROID_LOG_ERROR, "viper_process(), Error [out = NULL]");
|
v4a_printf(ANDROID_LOG_ERROR, "ViperProcess(), Error [outBuffer = NULL]");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pContext->effect->process(in, out);
|
return pContext->effect->process(inBuffer, outBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t
|
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) {
|
void *pReplyData) {
|
||||||
auto pContext = (ViperContext *) self;
|
auto pContext = (ViperContext *) self;
|
||||||
|
|
||||||
if (pContext == nullptr) {
|
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 -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pContext->effect->command(cmdCode, cmdSize, pCmdData, replySize, pReplyData);
|
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;
|
auto *pContext = (ViperContext *) self;
|
||||||
|
|
||||||
if (pContext == nullptr) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDescriptor == nullptr) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pDescriptor = *pContext->descriptor;
|
*pDescriptor = viper_descriptor;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const effect_interface_s viper_interface = {
|
const effect_interface_s viper_interface = {
|
||||||
.process = viper_process,
|
.process = ViperProcess,
|
||||||
.command = viper_command,
|
.command = ViperCommand,
|
||||||
.get_descriptor = viper_get_descriptor
|
.get_descriptor = ViperGetDescriptor
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t viper_effect_create(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle) {
|
int32_t ViperEffectCreate(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle) {
|
||||||
v4a_print(ANDROID_LOG_INFO, "Enter viper_effect_create()");
|
v4a_print(ANDROID_LOG_INFO, "Enter ViperEffectCreate()");
|
||||||
|
|
||||||
if (uuid == nullptr) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pHandle == nullptr) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(uuid, &viper_descriptor.uuid, sizeof(effect_uuid_t)) != 0) {
|
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;
|
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->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]);
|
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;
|
auto *pContext = new ViperContext;
|
||||||
pContext->interface = &viper_interface;
|
pContext->interface = &viper_interface;
|
||||||
pContext->effect = new ProcessUnit_FX();
|
pContext->effect = new ProcessUnit_FX();
|
||||||
pContext->descriptor = &viper_descriptor;
|
|
||||||
|
|
||||||
v4a_print(ANDROID_LOG_INFO, "Creating ViPER4Android Reworked [" VERSION_STRING "]");
|
|
||||||
*pHandle = (effect_handle_t) pContext;
|
*pHandle = (effect_handle_t) pContext;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t viper_effect_release(effect_handle_t handle) {
|
int32_t ViperEffectRelease(effect_handle_t handle) {
|
||||||
auto *pContext = (ViperContext *) handle;
|
auto *pContext = (ViperContext *) handle;
|
||||||
|
|
||||||
v4a_print(ANDROID_LOG_INFO, "Enter viper_effect_release()");
|
v4a_print(ANDROID_LOG_INFO, "Enter ViperEffectRelease()");
|
||||||
|
|
||||||
if (pContext == nullptr) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
v4a_print(ANDROID_LOG_INFO, "viper_effect_release(), Deconstructing ProcessUnit");
|
v4a_print(ANDROID_LOG_INFO, "ViperEffectRelease(), Deconstructing ProcessUnit");
|
||||||
|
|
||||||
if (pContext->effect != nullptr) {
|
if (pContext->effect != nullptr) {
|
||||||
delete pContext->effect;
|
delete pContext->effect;
|
||||||
@ -135,25 +136,25 @@ int32_t viper_effect_release(effect_handle_t handle) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t viper_effect_get_descriptor(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor) {
|
int32_t ViperEffectGetDescriptor(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor) {
|
||||||
v4a_print(ANDROID_LOG_INFO, "Enter viper_effect_get_descriptor()");
|
v4a_print(ANDROID_LOG_INFO, "Enter ViperEffectGetDescriptor()");
|
||||||
|
|
||||||
if (uuid == nullptr) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDescriptor == nullptr) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(uuid, &viper_descriptor.uuid, sizeof(effect_uuid_t)) != 0) {
|
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;
|
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->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]);
|
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 = {
|
audio_effect_library_t AUDIO_EFFECT_LIBRARY_INFO_SYM = {
|
||||||
.tag = AUDIO_EFFECT_LIBRARY_TAG,
|
.tag = AUDIO_EFFECT_LIBRARY_TAG,
|
||||||
.version = EFFECT_LIBRARY_API_VERSION,
|
.version = EFFECT_LIBRARY_API_VERSION,
|
||||||
.name = "ViPER4Android FX Reworked",
|
.name = EFFECT_NAME,
|
||||||
.implementor = "ViPER.WYF, Martmists, Iscle",
|
.implementor = EFFECT_IMPLEMENTOR,
|
||||||
.create_effect = viper_effect_create,
|
.create_effect = ViperEffectCreate,
|
||||||
.release_effect = viper_effect_release,
|
.release_effect = ViperEffectRelease,
|
||||||
.get_descriptor = viper_effect_get_descriptor,
|
.get_descriptor = ViperEffectGetDescriptor,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user