From 70dff35e63d39b0410e8f5b1cc67ca388d63de28 Mon Sep 17 00:00:00 2001 From: Martmists Date: Tue, 27 Jul 2021 19:00:39 +0200 Subject: [PATCH] logging and version --- CMakeLists.txt | 11 +++++++++- include/hardware/system/audio.h | 2 +- src/Effect.cpp | 36 ++++++++++++++++++++------------- src/ProcessUnit_FX.cpp | 4 +++- src/constants.h | 8 ++++++++ src/viper.cpp | 23 ++++++++++++++++++--- 6 files changed, 64 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4db34d5..8d27a72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,12 @@ project("ViPER4Android Reworked") set(CMAKE_CXX_COMPILER_VERSION 20) include_directories(include/) -message(${ANDROID_NDK}/include/) + +add_compile_definitions(VERSION_MAJOR=1) +add_compile_definitions(VERSION_MINOR=0) +add_compile_definitions(VERSION_REVISION=0) +add_compile_definitions(VERSION_BUILD=0) +add_compile_definitions(VERSION_CODENAME="Reworked") set(FILES # Main @@ -39,3 +44,7 @@ add_library( # Provides a relative path to your source file(s). ${FILES}) +target_link_libraries( + v4afx_r + log +) diff --git a/include/hardware/system/audio.h b/include/hardware/system/audio.h index 42f17dc..17526f8 100644 --- a/include/hardware/system/audio.h +++ b/include/hardware/system/audio.h @@ -136,7 +136,7 @@ static inline audio_unique_id_use_t audio_unique_id_get_use(audio_unique_id_t id */ typedef uint32_t audio_channel_mask_t; -/* log(2) of maximum number of representations, not part of public API */ +/* v4a_print(2) of maximum number of representations, not part of public API */ #define AUDIO_CHANNEL_REPRESENTATION_LOG2 2 /* The return value is undefined if the channel mask is invalid. */ diff --git a/src/Effect.cpp b/src/Effect.cpp index 13d69f9..727152a 100644 --- a/src/Effect.cpp +++ b/src/Effect.cpp @@ -70,40 +70,45 @@ int32_t Effect::command(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint return 0; } -#define ERROR this->configureOk = false;\ -return -EINVAL; +#define DO_ERROR() this->configureOk = false;\ +return -EINVAL int32_t Effect::configure(effect_config_t *newConfig) { + v4a_print(ANDROID_LOG_INFO, "Begin audio configure ..."); + v4a_print(ANDROID_LOG_INFO, "Checking input and output configuration ..."); + if (newConfig->inputCfg.samplingRate != newConfig->outputCfg.samplingRate) { - // __android_log_print(4,"ViPER4Android_v2","ViPER4Android disabled, reason [in.SR = %d, out.SR = %d]",inSamplingRate,outSamplingRate); - ERROR + v4a_printf(ANDROID_LOG_ERROR, "ViPER4Android disabled, reason [in.SR = %d, out.SR = %d]", newConfig->inputCfg.samplingRate, newConfig->outputCfg.samplingRate); + DO_ERROR(); } if (newConfig->inputCfg.samplingRate > 48000) { - // __android_log_print(4,"ViPER4Android_v2","ViPER4Android disabled, reason [SR out of range]"); - ERROR + v4a_print(ANDROID_LOG_ERROR, "ViPER4Android disabled, reason [SR out of range]"); + DO_ERROR(); } if (newConfig->inputCfg.channels != newConfig->outputCfg.channels) { - // __android_log_print(4,"ViPER4Android_v2","ViPER4Android disabled, reason [in.CH = %d, out.CH = %d]",inChannels,outChannels); - ERROR + v4a_printf(ANDROID_LOG_ERROR, "ViPER4Android disabled, reason [in.CH = %d, out.CH = %d]", newConfig->inputCfg.channels, newConfig->outputCfg.channels); + DO_ERROR(); } if (newConfig->inputCfg.channels != AUDIO_CHANNEL_OUT_STEREO) { - // __android_log_print(4,"ViPER4Android_v2","ViPER4Android disabled, reason [CH != 2]"); - ERROR + v4a_print(ANDROID_LOG_ERROR, "ViPER4Android disabled, reason [CH != 2]"); + DO_ERROR(); } + + v4a_print(ANDROID_LOG_INFO, "Input and output configuration checked."); // if (((inFormat & 0x80000) != 0) && ((outFormat & 0x80000) != 0)) { // if ((inFormat & 0xfd) != 1) { -// __android_log_print(4,"ViPER4Android_v2","ViPER4Android disabled, reason [in.FMT = %d]"); -// __android_log_print(4,"ViPER4Android_v2","We only accept s16 and fixed.31 format"); +// v4a_printf(ANDROID_LOG_ERROR, "ViPER4Android disabled, reason [in.FMT = %d]"); +// v4a_printf(ANDROID_LOG_ERROR, "We only accept s16 and fixed.31 format"); // this->configureOk = false; // return 0xffffffea; // } // if ((outFormat & 0xfd) != 1) { -// __android_log_print(4,"ViPER4Android_v2","ViPER4Android disabled, reason [out.FMT = %d]"); -// __android_log_print(4,"ViPER4Android_v2","We only accept s16 and fixed.31 format"); +// v4a_printf(ANDROID_LOG_ERROR, "ViPER4Android disabled, reason [out.FMT = %d]"); +// v4a_printf(ANDROID_LOG_ERROR, "We only accept s16 and fixed.31 format"); // this->configureOk = false; // return 0xffffffea; // } @@ -111,6 +116,9 @@ int32_t Effect::configure(effect_config_t *newConfig) { memcpy(&this->config, newConfig, sizeof(effect_config_t)); this->configureOk = true; + + v4a_print(ANDROID_LOG_INFO, "Audio configure finished"); + return 0; } diff --git a/src/ProcessUnit_FX.cpp b/src/ProcessUnit_FX.cpp index 9c172df..e6695a6 100644 --- a/src/ProcessUnit_FX.cpp +++ b/src/ProcessUnit_FX.cpp @@ -4,9 +4,11 @@ #include "ProcessUnit_FX.h" #include "Effect.h" +#include "constants.h" ProcessUnit_FX::ProcessUnit_FX() { - + v4a_print(ANDROID_LOG_INFO, "Welcome to ViPER4Android Reworked driver[SQ]"); + v4a_printf(ANDROID_LOG_INFO, "Current version is %s %s", VERSION_STRING, VERSION_CODENAME); } ProcessUnit_FX::~ProcessUnit_FX() { diff --git a/src/constants.h b/src/constants.h index 7a6aec6..19e0c87 100644 --- a/src/constants.h +++ b/src/constants.h @@ -4,4 +4,12 @@ #pragma once +#include + +#define STR_HELPER(x) #x +#define STR(x) STR_HELPER(x) +#define VERSION_STRING STR(VERSION_MAJOR) "." STR(VERSION_MINOR) "." STR(VERSION_REVISION) "." STR(VERSION_BUILD) + #define DEFAULT_SAMPLERATE 44100 +#define v4a_print(status, message) __android_log_write(status, "ViPER4Android_Reworked", message) +#define v4a_printf(status, format, ...) __android_log_print(status, "ViPER4Android_Reworked", format, __VA_ARGS__) \ No newline at end of file diff --git a/src/viper.cpp b/src/viper.cpp index 439203a..1409506 100644 --- a/src/viper.cpp +++ b/src/viper.cpp @@ -4,6 +4,7 @@ #include "Effect.h" #include "ProcessUnit_FX.h" +#include "constants.h" static effect_descriptor_t viper_descriptor = { // Identical type/uuid to original ViPER4Android @@ -32,7 +33,7 @@ extern "C" { } static int32_t generic_getDescriptor(effect_handle_t self, effect_descriptor_t *pDescriptor) { auto e = (handle *) self; - strcpy(viper_descriptor.name, "ViPER4Android Reworked [1.0.0.0]"); + strcpy(viper_descriptor.name, "ViPER4Android Reworked [" VERSION_STRING "]"); strcpy(viper_descriptor.implementor, "ViPER.WYF, Martmists, Iscle"); memcpy(pDescriptor, e->descriptor, sizeof(effect_descriptor_t)); @@ -47,23 +48,34 @@ extern "C" { }; int32_t EffectCreate(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pEffect) { + v4a_print(ANDROID_LOG_INFO,"Enter EffectCreate()"); if (memcmp(uuid, &viper_descriptor.uuid, sizeof(effect_uuid_t)) == 0) { // UUID matches - strcpy(viper_descriptor.name, "ViPER4Android Reworked [1.0.0.0]"); + v4a_printf(ANDROID_LOG_INFO, "EffectCreate(), 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]); + + strcpy(viper_descriptor.name, "ViPER4Android Reworked [" VERSION_STRING "]"); strcpy(viper_descriptor.implementor, "ViPER.WYF, Martmists, Iscle"); + v4a_print(ANDROID_LOG_INFO, "EffectCreate(), v4a standard effect (normal), Constructing ProcessUnit_FX"); + auto ptr = (handle*)calloc(1, sizeof(handle)); ptr->interface = &viper_interface; ptr->effect = new ProcessUnit_FX(); ptr->descriptor = &viper_descriptor; + + v4a_print(ANDROID_LOG_INFO, "Creating ViPER4Android Reworked [" VERSION_STRING "]"); *pEffect = (effect_handle_t)ptr; } else { + + v4a_print(ANDROID_LOG_ERROR, "EffectCreate(), Error [effect not found]"); return -ENOENT; } return 0; } int32_t EffectRelease(effect_handle_t ei) { + v4a_print(ANDROID_LOG_INFO, "EffectRelease(), Deconstructing ProcessUnit"); + auto ptr = (handle*)ei; delete ptr->effect; free(ptr); @@ -71,12 +83,17 @@ extern "C" { } int32_t EffectGetDescriptor(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor) { + v4a_print(ANDROID_LOG_INFO, "Enter EffectGetDescriptor()"); + if (memcmp(uuid, &viper_descriptor.uuid, sizeof(effect_uuid_t)) == 0) { - strcpy(viper_descriptor.name, "ViPER4Android Reworked [1.0.0.0]"); + v4a_printf(ANDROID_LOG_INFO, "EffectGetDescriptor(), 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]); + + strcpy(viper_descriptor.name, "ViPER4Android Reworked [" VERSION_STRING "]"); strcpy(viper_descriptor.implementor, "ViPER.WYF, Martmists, Iscle"); memcpy(pDescriptor, &viper_descriptor, sizeof(effect_descriptor_t)); } else { + v4a_print(ANDROID_LOG_ERROR, "EffectGetDescriptor(), Error [effect not found]"); return -EINVAL; } return 0;