Improve log header and fix some includes

This commit is contained in:
Iscle 2025-04-03 00:35:10 +02:00
parent 5840621060
commit 8463b73ccc
34 changed files with 246 additions and 192 deletions

View File

@ -1,18 +1,10 @@
cmake_minimum_required(VERSION 3.16.3)
set(CMAKE_CXX_COMPILER_VERSION 20)
# NDK Settings
#add_compile_definitions(ANDROID_ABI=arm64-v8a)
#add_compile_definitions(ANDROID_ABI=armeabi-v7a)
#add_compile_definitions(ANDROID_ARM_NEON=true)
#add_compile_definitions(ANDROID_PLATFORM=android-24)
set(CMAKE_CXX_STANDARD 20)
project("ViPER4Android")
add_compile_definitions(VIPER_VERSION=20240314)
# FFTS
#add_subdirectory(src/viper/ffts)
# ViPERFX
include_directories(src/include)
@ -70,16 +62,9 @@ set(FILES
src/viper/utils/TimeConstDelay.cpp
src/viper/utils/WaveBuffer.cpp)
add_library(
# Sets the name of the library.
v4a_re
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
add_library(v4a_re SHARED
${FILES})
target_link_libraries(v4a_re log) # kissfft)
target_link_libraries(v4a_re log)
target_compile_options(v4a_re PRIVATE -flto -O3 -DNDEBUG)
#target_compile_options(v4afx_r PRIVATE -O2 -DNDEBUG -Wall -Wsign-conversion -Wno-unused-result -Wno-unneeded-internal-declaration -fstrict-aliasing -fvisibility=hidden -Wextra -Wno-unused-parameter)

View File

@ -26,7 +26,7 @@
#include <media/AidlConversionNdk.h>
#include <system/audio_effects/effect_uuid.h>
#include "viper/constants.h"
#include <constants.h>
#include "ViPER4Aidl.h"
using aidl::android::hardware::audio::effect::Descriptor;

View File

@ -3,11 +3,11 @@
#ifdef AOSP_SOONG_BUILD
#include <hardware/audio_effect.h>
#else
#include "essential.h"
#include <essential.h>
#endif
#include "viper/ViPER.h"
#include "viper/constants.h"
#include <constants.h>
#include "ViperContext.h"
extern "C" {

View File

@ -1,10 +1,9 @@
#include <cerrno>
#include <cstring>
#include <cmath>
#include <chrono>
#include "ViperContext.h"
#include "log.h"
#include "viper/constants.h"
#include <log.h>
#include <constants.h>
#define SET(type, ptr, value) (*(type *) (ptr) = (value))
@ -14,7 +13,7 @@ ViperContext::ViperContext() :
buffer(std::vector<float>()),
bufferFrameCount(0),
enabled(false) {
VIPER_LOGI("ViperContext created");
ALOGI("ViperContext created");
}
void ViperContext::copyBufferConfig(buffer_config_t *dest, buffer_config_t *src) {
@ -46,20 +45,20 @@ void ViperContext::copyBufferConfig(buffer_config_t *dest, buffer_config_t *src)
}
void ViperContext::handleSetConfig(effect_config_t *newConfig) {
VIPER_LOGI("Checking input and output configuration ...");
ALOGI("Checking input and output configuration ...");
VIPER_LOGI("Input mask: 0x%04X", newConfig->inputCfg.mask);
VIPER_LOGI("Input buffer frame count: %zu", newConfig->inputCfg.buffer.frameCount);
VIPER_LOGI("Input sampling rate: %d", newConfig->inputCfg.samplingRate);
VIPER_LOGI("Input channels: %d", newConfig->inputCfg.channels);
VIPER_LOGI("Input format: %d", newConfig->inputCfg.format);
VIPER_LOGI("Input access mode: %d", newConfig->inputCfg.accessMode);
VIPER_LOGI("Output mask: 0x%04X", newConfig->outputCfg.mask);
VIPER_LOGI("Output buffer frame count: %zu", newConfig->outputCfg.buffer.frameCount);
VIPER_LOGI("Output sampling rate: %d", newConfig->outputCfg.samplingRate);
VIPER_LOGI("Output channels: %d", newConfig->outputCfg.channels);
VIPER_LOGI("Output format: %d", newConfig->outputCfg.format);
VIPER_LOGI("Output access mode: %d", newConfig->outputCfg.accessMode);
ALOGI("Input mask: 0x%04X", newConfig->inputCfg.mask);
ALOGI("Input buffer frame count: %zu", newConfig->inputCfg.buffer.frameCount);
ALOGI("Input sampling rate: %d", newConfig->inputCfg.samplingRate);
ALOGI("Input channels: %d", newConfig->inputCfg.channels);
ALOGI("Input format: %d", newConfig->inputCfg.format);
ALOGI("Input access mode: %d", newConfig->inputCfg.accessMode);
ALOGI("Output mask: 0x%04X", newConfig->outputCfg.mask);
ALOGI("Output buffer frame count: %zu", newConfig->outputCfg.buffer.frameCount);
ALOGI("Output sampling rate: %d", newConfig->outputCfg.samplingRate);
ALOGI("Output channels: %d", newConfig->outputCfg.channels);
ALOGI("Output format: %d", newConfig->outputCfg.format);
ALOGI("Output access mode: %d", newConfig->outputCfg.accessMode);
setDisableReason(DisableReason::UNKNOWN);
@ -67,35 +66,35 @@ void ViperContext::handleSetConfig(effect_config_t *newConfig) {
copyBufferConfig(&config.outputCfg, &newConfig->outputCfg);
if (config.inputCfg.buffer.frameCount != config.outputCfg.buffer.frameCount) {
VIPER_LOGE("ViPER4Android disabled, reason [in.FC = %zu, out.FC = %zu]",
ALOGE("ViPER4Android disabled, reason [in.FC = %zu, out.FC = %zu]",
config.inputCfg.buffer.frameCount, config.outputCfg.buffer.frameCount);
setDisableReason(DisableReason::INVALID_FRAME_COUNT);
return;
}
if (config.inputCfg.samplingRate != config.outputCfg.samplingRate) {
VIPER_LOGE("ViPER4Android disabled, reason [in.SR = %d, out.SR = %d]",
ALOGE("ViPER4Android disabled, reason [in.SR = %d, out.SR = %d]",
config.inputCfg.samplingRate, config.outputCfg.samplingRate);
setDisableReason(DisableReason::INVALID_SAMPLING_RATE);
return;
}
// if (config.inputCfg.samplingRate > 48000) {
// VIPER_LOGE("ViPER4Android disabled, reason [SR out of range]");
// ALOGE("ViPER4Android disabled, reason [SR out of range]");
// setDisableReason(DisableReason::INVALID_SAMPLING_RATE, "Sampling rate out of range: " + std::to_string(config.inputCfg.samplingRate));
// return;
// }
// TODO: this is wrong (AUDIO_CHANNEL_IN_STEREO != AUDIO_CHANNEL_OUT_STEREO)
if (config.inputCfg.channels != config.outputCfg.channels) {
VIPER_LOGE("ViPER4Android disabled, reason [in.CH = %d, out.CH = %d]",
ALOGE("ViPER4Android disabled, reason [in.CH = %d, out.CH = %d]",
config.inputCfg.channels, config.outputCfg.channels);
setDisableReason(DisableReason::INVALID_CHANNEL_COUNT);
return;
}
if (config.inputCfg.channels != AUDIO_CHANNEL_OUT_STEREO) {
VIPER_LOGE("ViPER4Android disabled, reason [CH != 2]");
ALOGE("ViPER4Android disabled, reason [CH != 2]");
setDisableReason(DisableReason::INVALID_CHANNEL_COUNT);
return;
}
@ -103,8 +102,8 @@ void ViperContext::handleSetConfig(effect_config_t *newConfig) {
if (config.inputCfg.format != AUDIO_FORMAT_PCM_16_BIT &&
config.inputCfg.format != AUDIO_FORMAT_PCM_32_BIT &&
config.inputCfg.format != AUDIO_FORMAT_PCM_FLOAT) {
VIPER_LOGE("ViPER4Android disabled, reason [in.FMT = %d]", config.inputCfg.format);
VIPER_LOGE("We only accept AUDIO_FORMAT_PCM_16_BIT, AUDIO_FORMAT_PCM_32_BIT and AUDIO_FORMAT_PCM_FLOAT input format!");
ALOGE("ViPER4Android disabled, reason [in.FMT = %d]", config.inputCfg.format);
ALOGE("We only accept AUDIO_FORMAT_PCM_16_BIT, AUDIO_FORMAT_PCM_32_BIT and AUDIO_FORMAT_PCM_FLOAT input format!");
setDisableReason(DisableReason::INVALID_FORMAT);
return;
}
@ -112,13 +111,13 @@ void ViperContext::handleSetConfig(effect_config_t *newConfig) {
if (config.outputCfg.format != AUDIO_FORMAT_PCM_16_BIT &&
config.outputCfg.format != AUDIO_FORMAT_PCM_32_BIT &&
config.outputCfg.format != AUDIO_FORMAT_PCM_FLOAT) {
VIPER_LOGE("ViPER4Android disabled, reason [out.FMT = %d]", config.outputCfg.format);
VIPER_LOGE("We only accept AUDIO_FORMAT_PCM_16_BIT, AUDIO_FORMAT_PCM_32_BIT and AUDIO_FORMAT_PCM_FLOAT output format!");
ALOGE("ViPER4Android disabled, reason [out.FMT = %d]", config.outputCfg.format);
ALOGE("We only accept AUDIO_FORMAT_PCM_16_BIT, AUDIO_FORMAT_PCM_32_BIT and AUDIO_FORMAT_PCM_FLOAT output format!");
setDisableReason(DisableReason::INVALID_FORMAT);
return;
}
VIPER_LOGI("Input and output configuration checked.");
ALOGI("Input and output configuration checked.");
setDisableReason(DisableReason::NONE);
// Processing buffer
@ -136,7 +135,7 @@ int32_t ViperContext::handleSetParam(effect_param_t *pCmdParam, void *pReplyData
uint32_t vOffset = ((pCmdParam->psize + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t);
if (pCmdParam->psize != sizeof(uint32_t)) {
VIPER_LOGE("handleSetParam: EFFECT_CMD_SET_PARAM called with invalid psize = %d, expected psize = %zu", pCmdParam->vsize, sizeof(uint32_t));
ALOGE("handleSetParam: EFFECT_CMD_SET_PARAM called with invalid psize = %d, expected psize = %zu", pCmdParam->vsize, sizeof(uint32_t));
return -EINVAL;
}
@ -145,23 +144,23 @@ int32_t ViperContext::handleSetParam(effect_param_t *pCmdParam, void *pReplyData
uint32_t key = *(uint32_t *) (pCmdParam->data);
switch (key) {
case PARAM_SET_RESET: {
VIPER_LOGD("handleSetParam: PARAM_SET_RESET called");
ALOGD("handleSetParam: PARAM_SET_RESET called");
viper.reset();
return 0;
}
case PARAM_SET_VIPER_DDC_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_VIPER_DDC_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_VIPER_DDC_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_VIPER_DDC_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_VIPER_DDC_ENABLE called with enable = %d", enable);
viper.viperDdc.SetEnable(enable);
return 0;
}
case PARAM_SET_VIPER_DDC_COEFFICIENTS: {
if (pCmdParam->vsize < sizeof(uint32_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_VIPER_DDC_COEFFICIENTS called with invalid vsize = %d, expected vsize >= %zu", pCmdParam->vsize, sizeof(uint32_t));
ALOGE("handleSetParam: PARAM_SET_VIPER_DDC_COEFFICIENTS called with invalid vsize = %d, expected vsize >= %zu", pCmdParam->vsize, sizeof(uint32_t));
return -EINVAL;
}
@ -170,182 +169,182 @@ int32_t ViperContext::handleSetParam(effect_param_t *pCmdParam, void *pReplyData
float *coeffs48000 = (float *) (pCmdParam->data + vOffset + sizeof(uint32_t) + sizeof(float) * size);
if (pCmdParam->vsize != sizeof(uint32_t) + sizeof(float) * 2 * size) {
VIPER_LOGE("handleSetParam: PARAM_SET_VIPER_DDC_COEFFICIENTS called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint32_t) + sizeof(float) * 2 * size);
ALOGE("handleSetParam: PARAM_SET_VIPER_DDC_COEFFICIENTS called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint32_t) + sizeof(float) * 2 * size);
return -EINVAL;
}
VIPER_LOGD("handleSetParam: PARAM_SET_VIPER_DDC_COEFFICIENTS called with size = %d", size);
ALOGD("handleSetParam: PARAM_SET_VIPER_DDC_COEFFICIENTS called with size = %d", size);
viper.viperDdc.SetCoeffs(size, coeffs44100, coeffs48000);
return 0;
}
case PARAM_SET_VIPER_BASS_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_VIPER_BASS_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_VIPER_BASS_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_VIPER_BASS_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_VIPER_BASS_ENABLE called with enable = %d", enable);
viper.viperBass.SetEnable(enable);
return 0;
}
case PARAM_SET_VIPER_BASS_MODE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_VIPER_BASS_MODE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_VIPER_BASS_MODE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t mode = *(uint8_t *) (pCmdParam->data + vOffset);
if (mode > 2) {
VIPER_LOGE("handleSetParam: PARAM_SET_VIPER_BASS_MODE called with invalid mode = %d, expected mode = 0, 1 or 2", mode);
ALOGE("handleSetParam: PARAM_SET_VIPER_BASS_MODE called with invalid mode = %d, expected mode = 0, 1 or 2", mode);
*(int32_t *) pReplyData = -EINVAL;
return 0;
}
VIPER_LOGD("handleSetParam: PARAM_SET_VIPER_BASS_MODE called with mode = %d", mode);
ALOGD("handleSetParam: PARAM_SET_VIPER_BASS_MODE called with mode = %d", mode);
viper.viperBass.SetProcessMode(static_cast<ViPERBass::ProcessMode>(mode));
return 0;
}
case PARAM_SET_VIPER_BASS_FREQUENCY: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_VIPER_BASS_FREQUENCY called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_VIPER_BASS_FREQUENCY called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t frequency = *(uint8_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_VIPER_BASS_FREQUENCY called with frequency = %d", frequency);
ALOGD("handleSetParam: PARAM_SET_VIPER_BASS_FREQUENCY called with frequency = %d", frequency);
viper.viperBass.SetSpeaker(frequency);
return 0;
}
case PARAM_SET_VIPER_BASS_GAIN: {
if (pCmdParam->vsize != sizeof(uint16_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_VIPER_BASS_GAIN called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t));
ALOGE("handleSetParam: PARAM_SET_VIPER_BASS_GAIN called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t));
return -EINVAL;
}
uint16_t gain = *(uint16_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_VIPER_BASS_GAIN called with gain = %d", gain);
ALOGD("handleSetParam: PARAM_SET_VIPER_BASS_GAIN called with gain = %d", gain);
viper.viperBass.SetBassFactor(static_cast<float>(gain) / 100.0f);
return 0;
}
case PARAM_SET_VIPER_CLARITY_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_VIPER_CLARITY_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_VIPER_CLARITY_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_VIPER_CLARITY_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_VIPER_CLARITY_ENABLE called with enable = %d", enable);
viper.viperClarity.SetEnable(enable);
return 0;
}
case PARAM_SET_VIPER_CLARITY_MODE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_VIPER_CLARITY_MODE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_VIPER_CLARITY_MODE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t mode = *(uint8_t *) (pCmdParam->data + vOffset);
if (mode > 2) {
VIPER_LOGE("handleSetParam: PARAM_SET_VIPER_CLARITY_MODE called with invalid mode = %d, expected mode = 0, 1 or 2", mode);
ALOGE("handleSetParam: PARAM_SET_VIPER_CLARITY_MODE called with invalid mode = %d, expected mode = 0, 1 or 2", mode);
*(int32_t *) pReplyData = -EINVAL;
return 0;
}
VIPER_LOGD("handleSetParam: PARAM_SET_VIPER_CLARITY_MODE called with mode = %d", mode);
ALOGD("handleSetParam: PARAM_SET_VIPER_CLARITY_MODE called with mode = %d", mode);
viper.viperClarity.SetProcessMode(static_cast<ViPERClarity::ClarityMode>(mode));
return 0;
}
case PARAM_SET_VIPER_CLARITY_GAIN: {
if (pCmdParam->vsize != sizeof(uint16_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_VIPER_CLARITY_GAIN called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t));
ALOGE("handleSetParam: PARAM_SET_VIPER_CLARITY_GAIN called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t));
return -EINVAL;
}
uint16_t gain = *(uint16_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_VIPER_CLARITY_GAIN called with gain = %d", gain);
ALOGD("handleSetParam: PARAM_SET_VIPER_CLARITY_GAIN called with gain = %d", gain);
viper.viperClarity.SetClarity(static_cast<float>(gain) / 100.0f);
return 0;
}
case PARAM_SET_OUTPUT_GAIN: {
// 0 - 255
if (pCmdParam->vsize != sizeof(uint8_t) * 2) {
VIPER_LOGE("handleSetParam: PARAM_SET_OUTPUT_GAIN called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t) * 2);
ALOGE("handleSetParam: PARAM_SET_OUTPUT_GAIN called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t) * 2);
return -EINVAL;
}
uint8_t gainL = *(uint8_t *) (pCmdParam->data + vOffset);
uint8_t gainR = *(uint8_t *) (pCmdParam->data + vOffset + sizeof(uint8_t));
VIPER_LOGD("handleSetParam: PARAM_SET_OUTPUT_GAIN called with gainL = %d, gainR = %d", gainL, gainR);
ALOGD("handleSetParam: PARAM_SET_OUTPUT_GAIN called with gainL = %d, gainR = %d", gainL, gainR);
viper.setGain(static_cast<float>(gainL) / 100.0f, static_cast<float>(gainR) / 100.0f);
return 0;
}
case PARAM_SET_THRESHOLD_LIMIT: {
// 0 - 100 (TODO: Check range)
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_THRESHOLD_LIMIT called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_THRESHOLD_LIMIT called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t limit = *(uint8_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_THRESHOLD_LIMIT called with limit = %d", limit);
ALOGD("handleSetParam: PARAM_SET_THRESHOLD_LIMIT called with limit = %d", limit);
viper.setThresholdLimit(static_cast<float>(limit) / 100.0f);
return 0;
}
case PARAM_SET_SPEAKER_OPTIMIZATION_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_SPEAKER_OPTIMIZATION_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_SPEAKER_OPTIMIZATION_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_SPEAKER_OPTIMIZATION_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_SPEAKER_OPTIMIZATION_ENABLE called with enable = %d", enable);
viper.speakerCorrection.SetEnable(enable);
return 0;
}
case PARAM_SET_ANALOGX_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_ANALOGX_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_ANALOGX_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_ANALOGX_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_ANALOGX_ENABLE called with enable = %d", enable);
viper.analogX.SetEnable(enable);
return 0;
}
case PARAM_SET_ANALOGX_LEVEL: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_ANALOGX_LEVEL called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_ANALOGX_LEVEL called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t level = *(uint8_t *) (pCmdParam->data + vOffset);
if (level > 2) {
VIPER_LOGE("handleSetParam: PARAM_SET_ANALOGX_LEVEL called with invalid level = %d, expected level = 0, 1 or 2", level);
ALOGE("handleSetParam: PARAM_SET_ANALOGX_LEVEL called with invalid level = %d, expected level = 0, 1 or 2", level);
*(int32_t *) pReplyData = -EINVAL;
return 0;
}
VIPER_LOGD("handleSetParam: PARAM_SET_ANALOGX_LEVEL called with level = %d", level);
ALOGD("handleSetParam: PARAM_SET_ANALOGX_LEVEL called with level = %d", level);
viper.analogX.SetProcessingModel(level);
return 0;
}
case PARAM_SET_TUBE_SIMULATOR_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_TUBE_SIMULATOR_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_TUBE_SIMULATOR_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_TUBE_SIMULATOR_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_TUBE_SIMULATOR_ENABLE called with enable = %d", enable);
viper.tubeSimulator.SetEnable(enable);
return 0;
}
case PARAM_SET_CURE_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_CURE_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_CURE_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_CURE_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_CURE_ENABLE called with enable = %d", enable);
viper.cure.SetEnable(enable);
return 0;
}
case PARAM_SET_CURE_LEVEL: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_CURE_LEVEL called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_CURE_LEVEL called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t level = *(uint8_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_CURE_LEVEL called with level = %d", level);
ALOGD("handleSetParam: PARAM_SET_CURE_LEVEL called with level = %d", level);
switch (level) {
case 0: {
struct Crossfeed::Preset preset = {
@ -372,7 +371,7 @@ int32_t ViperContext::handleSetParam(effect_param_t *pCmdParam, void *pReplyData
break;
}
default:
VIPER_LOGE("handleSetParam: PARAM_SET_CURE_LEVEL called with invalid level = %d, expected level = 0, 1 or 2", level);
ALOGE("handleSetParam: PARAM_SET_CURE_LEVEL called with invalid level = %d, expected level = 0, 1 or 2", level);
*(int32_t *) pReplyData = -EINVAL;
break;
}
@ -380,230 +379,230 @@ int32_t ViperContext::handleSetParam(effect_param_t *pCmdParam, void *pReplyData
}
case PARAM_SET_REVERBERATION_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_REVERBERATION_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_REVERBERATION_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_REVERBERATION_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_REVERBERATION_ENABLE called with enable = %d", enable);
viper.reverberation.SetEnable(enable);
return 0;
}
case PARAM_SET_REVERBERATION_ROOM_SIZE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_REVERBERATION_ROOM_SIZE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_REVERBERATION_ROOM_SIZE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t roomSize = *(uint8_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_REVERBERATION_ROOM_SIZE called with roomSize = %d", roomSize);
ALOGD("handleSetParam: PARAM_SET_REVERBERATION_ROOM_SIZE called with roomSize = %d", roomSize);
viper.reverberation.SetRoomSize(static_cast<float>(roomSize) / 100.0f);
return 0;
}
case PARAM_SET_REVERBERATION_SOUND_FIELD: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_REVERBERATION_SOUND_FIELD called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_REVERBERATION_SOUND_FIELD called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t soundField = *(uint8_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_REVERBERATION_SOUND_FIELD called with soundField = %d", soundField);
ALOGD("handleSetParam: PARAM_SET_REVERBERATION_SOUND_FIELD called with soundField = %d", soundField);
viper.reverberation.SetWidth(static_cast<float>(soundField) / 100.0f);
return 0;
}
case PARAM_SET_REVERBERATION_DAMPING: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_REVERBERATION_DAMPING called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_REVERBERATION_DAMPING called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t damping = *(uint8_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_REVERBERATION_DAMPING called with damping = %d", damping);
ALOGD("handleSetParam: PARAM_SET_REVERBERATION_DAMPING called with damping = %d", damping);
viper.reverberation.SetDamp(static_cast<float>(damping) / 100.0f);
return 0;
}
case PARAM_SET_REVERBERATION_WET_SIGNAL: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_REVERBERATION_WET_SIGNAL called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_REVERBERATION_WET_SIGNAL called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t wetSignal = *(uint8_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_REVERBERATION_WET_SIGNAL called with wetSignal = %d", wetSignal);
ALOGD("handleSetParam: PARAM_SET_REVERBERATION_WET_SIGNAL called with wetSignal = %d", wetSignal);
viper.reverberation.SetWet(static_cast<float>(wetSignal) / 100.0f);
return 0;
}
case PARAM_SET_REVERBERATION_DRY_SIGNAL: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_REVERBERATION_DRY_SIGNAL called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_REVERBERATION_DRY_SIGNAL called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t drySignal = *(uint8_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_REVERBERATION_DRY_SIGNAL called with drySignal = %d", drySignal);
ALOGD("handleSetParam: PARAM_SET_REVERBERATION_DRY_SIGNAL called with drySignal = %d", drySignal);
viper.reverberation.SetDry(static_cast<float>(drySignal) / 100.0f);
return 0;
}
case PARAM_SET_DIFFERENTIAL_SURROUND_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_DIFFERENTIAL_SURROUND_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_DIFFERENTIAL_SURROUND_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_DIFFERENTIAL_SURROUND_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_DIFFERENTIAL_SURROUND_ENABLE called with enable = %d", enable);
viper.diffSurround.SetEnable(enable);
return 0;
}
case PARAM_SET_DIFFERENTIAL_SURROUND_DELAY: {
if (pCmdParam->vsize != sizeof(uint16_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_DIFFERENTIAL_SURROUND_DELAY called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t));
ALOGE("handleSetParam: PARAM_SET_DIFFERENTIAL_SURROUND_DELAY called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t));
return -EINVAL;
}
uint16_t delay = *(uint16_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_DIFFERENTIAL_SURROUND_DELAY called with delay = %d", delay);
ALOGD("handleSetParam: PARAM_SET_DIFFERENTIAL_SURROUND_DELAY called with delay = %d", delay);
viper.diffSurround.SetDelayTime(static_cast<float>(delay) / 100.0f);
return 0;
}
case PARAM_SET_FIELD_SURROUND_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_FIELD_SURROUND_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_FIELD_SURROUND_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_FIELD_SURROUND_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_FIELD_SURROUND_ENABLE called with enable = %d", enable);
viper.colorfulMusic.SetEnable(enable);
return 0;
}
case PARAM_SET_FIELD_SURROUND_DEPTH: {
if (pCmdParam->vsize != sizeof(uint16_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_FIELD_SURROUND_DEPTH called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t));
ALOGE("handleSetParam: PARAM_SET_FIELD_SURROUND_DEPTH called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t));
return -EINVAL;
}
uint16_t depth = *(uint16_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_FIELD_SURROUND_DEPTH called with depth = %d", depth);
ALOGD("handleSetParam: PARAM_SET_FIELD_SURROUND_DEPTH called with depth = %d", depth);
viper.colorfulMusic.SetDepthValue(depth);
return 0;
}
case PARAM_SET_FIELD_SURROUND_MID_IMAGE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_FIELD_SURROUND_MID_IMAGE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_FIELD_SURROUND_MID_IMAGE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t midImage = *(uint8_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_FIELD_SURROUND_MID_IMAGE called with midImage = %d", midImage);
ALOGD("handleSetParam: PARAM_SET_FIELD_SURROUND_MID_IMAGE called with midImage = %d", midImage);
viper.colorfulMusic.SetMidImageValue(static_cast<float>(midImage) / 100.0f);
return 0;
}
case PARAM_SET_IIR_EQUALIZER_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_IIR_EQUALIZER_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_IIR_EQUALIZER_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_IIR_EQUALIZER_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_IIR_EQUALIZER_ENABLE called with enable = %d", enable);
viper.iirFilter.SetEnable(enable);
return 0;
}
case PARAM_SET_IIR_EQUALIZER_BAND_LEVEL: {
if (pCmdParam->vsize != sizeof(uint8_t) + sizeof(int16_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_IIR_EQUALIZER_BAND_LEVEL called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t) + sizeof(int16_t));
ALOGE("handleSetParam: PARAM_SET_IIR_EQUALIZER_BAND_LEVEL called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t) + sizeof(int16_t));
return -EINVAL;
}
uint8_t band = *(uint8_t *) (pCmdParam->data + vOffset);
int16_t level = *(int16_t *) (pCmdParam->data + vOffset + sizeof(uint8_t));
VIPER_LOGD("handleSetParam: PARAM_SET_IIR_EQUALIZER_BAND_LEVEL called with band = %d, level = %d", band, level);
ALOGD("handleSetParam: PARAM_SET_IIR_EQUALIZER_BAND_LEVEL called with band = %d, level = %d", band, level);
viper.iirFilter.SetBandLevel(band, static_cast<float>(level) / 100.0f);
return 0;
}
case PARAM_SET_SPECTRUM_EXTENSION_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_SPECTRUM_EXTENSION_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_SPECTRUM_EXTENSION_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_SPECTRUM_EXTENSION_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_SPECTRUM_EXTENSION_ENABLE called with enable = %d", enable);
viper.spectrumExtend.SetEnable(enable);
return 0;
}
case PARAM_SET_SPECTRUM_EXTENSION_STRENGTH: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_SPECTRUM_EXTENSION_STRENGTH called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_SPECTRUM_EXTENSION_STRENGTH called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t strength = *(uint8_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_SPECTRUM_EXTENSION_STRENGTH called with strength = %d", strength);
ALOGD("handleSetParam: PARAM_SET_SPECTRUM_EXTENSION_STRENGTH called with strength = %d", strength);
viper.spectrumExtend.SetExciter(static_cast<float>(strength) / 100.0f);
return 0;
}
case PARAM_SET_HEADPHONE_SURROUND_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_HEADPHONE_SURROUND_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_HEADPHONE_SURROUND_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_HEADPHONE_SURROUND_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_HEADPHONE_SURROUND_ENABLE called with enable = %d", enable);
viper.vhe.SetEnable(enable);
return 0;
}
case PARAM_SET_HEADPHONE_SURROUND_LEVEL: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_HEADPHONE_SURROUND_LEVEL called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_HEADPHONE_SURROUND_LEVEL called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
uint8_t level = *(uint8_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_HEADPHONE_SURROUND_LEVEL called with level = %d", level);
ALOGD("handleSetParam: PARAM_SET_HEADPHONE_SURROUND_LEVEL called with level = %d", level);
viper.vhe.SetEffectLevel(level);
return 0;
}
case PARAM_SET_DYNAMIC_SYSTEM_ENABLE: {
if (pCmdParam->vsize != sizeof(uint8_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
ALOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_ENABLE called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t));
return -EINVAL;
}
bool enable = *(uint8_t *) (pCmdParam->data + vOffset) != 0;
VIPER_LOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_ENABLE called with enable = %d", enable);
ALOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_ENABLE called with enable = %d", enable);
viper.dynamicSystem.SetEnable(enable);
return 0;
}
case PARAM_SET_DYNAMIC_SYSTEM_X_COEFFICIENTS: {
if (pCmdParam->vsize != sizeof(uint16_t) * 2) {
VIPER_LOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_X_COEFFICIENTS called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t) * 2);
ALOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_X_COEFFICIENTS called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t) * 2);
return -EINVAL;
}
uint16_t low = *(uint16_t *) (pCmdParam->data + vOffset);
uint16_t high = *(uint16_t *) (pCmdParam->data + vOffset + sizeof(uint16_t));
VIPER_LOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_X_COEFFICIENTS called with low = %d, high = %d", low, high);
ALOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_X_COEFFICIENTS called with low = %d, high = %d", low, high);
viper.dynamicSystem.SetXCoeffs(low, high);
return 0;
}
case PARAM_SET_DYNAMIC_SYSTEM_Y_COEFFICIENTS: {
if (pCmdParam->vsize != sizeof(uint16_t) * 2) {
VIPER_LOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_Y_COEFFICIENTS called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t) * 2);
ALOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_Y_COEFFICIENTS called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t) * 2);
return -EINVAL;
}
uint16_t low = *(uint16_t *) (pCmdParam->data + vOffset);
uint16_t high = *(uint16_t *) (pCmdParam->data + vOffset + sizeof(uint16_t));
VIPER_LOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_Y_COEFFICIENTS called with low = %d, high = %d", low, high);
ALOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_Y_COEFFICIENTS called with low = %d, high = %d", low, high);
viper.dynamicSystem.SetYCoeffs(low, high);
return 0;
}
case PARAM_SET_DYNAMIC_SYSTEM_SIDE_GAIN: {
if (pCmdParam->vsize != sizeof(uint8_t) * 2) {
VIPER_LOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_SIDE_GAIN called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t) * 2);
ALOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_SIDE_GAIN called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint8_t) * 2);
return -EINVAL;
}
uint8_t gainX = *(uint8_t *) (pCmdParam->data + vOffset);
uint8_t gainY = *(uint8_t *) (pCmdParam->data + vOffset + sizeof(uint8_t));
VIPER_LOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_SIDE_GAIN called with gainX = %d, gainY = %d", gainX, gainY);
ALOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_SIDE_GAIN called with gainX = %d, gainY = %d", gainX, gainY);
viper.dynamicSystem.SetSideGain(static_cast<float>(gainX) / 100.0f, static_cast<float>(gainY) / 100.0f);
return 0;
}
case PARAM_SET_DYNAMIC_SYSTEM_STRENGTH: {
if (pCmdParam->vsize != sizeof(uint16_t)) {
VIPER_LOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_STRENGTH called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t));
ALOGE("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_STRENGTH called with invalid vsize = %d, expected vsize = %zu", pCmdParam->vsize, sizeof(uint16_t));
return -EINVAL;
}
uint16_t strength = *(uint16_t *) (pCmdParam->data + vOffset);
VIPER_LOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_STRENGTH called with strength = %d", strength);
ALOGD("handleSetParam: PARAM_SET_DYNAMIC_SYSTEM_STRENGTH called with strength = %d", strength);
viper.dynamicSystem.SetBassGain(static_cast<float>(strength) / 100.0f);
return 0;
}
default: {
VIPER_LOGE("handleSetParam: called with unknown key: %d", key);
ALOGE("handleSetParam: called with unknown key: %d", key);
return -EINVAL;
}
}
@ -615,7 +614,7 @@ int32_t ViperContext::handleGetParam(effect_param_t *pCmdParam, effect_param_t *
uint32_t vOffset = ((pCmdParam->psize + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t);
if (pCmdParam->psize != sizeof(uint32_t)) {
VIPER_LOGE("handleGetParam() EFFECT_CMD_GET_PARAM called with invalid psize = %d, expected psize = %zu", pCmdParam->vsize, sizeof(uint32_t));
ALOGE("handleGetParam() EFFECT_CMD_GET_PARAM called with invalid psize = %d, expected psize = %zu", pCmdParam->vsize, sizeof(uint32_t));
return -EINVAL;
}
@ -679,7 +678,7 @@ int32_t ViperContext::handleGetParam(effect_param_t *pCmdParam, effect_param_t *
return 0;
}
default: {
VIPER_LOGE("handleGetParam() called with unknown key: %d", key);
ALOGE("handleGetParam() called with unknown key: %d", key);
return -EINVAL;
}
}
@ -690,7 +689,7 @@ int32_t ViperContext::handleCommand(uint32_t cmdCode, uint32_t cmdSize, void *pC
switch (cmdCode) {
case EFFECT_CMD_INIT: {
if (replySize != sizeof(int32_t) || pReplyData == nullptr) {
VIPER_LOGE("EFFECT_CMD_INIT called with invalid replySize = %d, pReplyData = %p, expected replySize = %zu", replySize, pReplyData, sizeof(int32_t));
ALOGE("EFFECT_CMD_INIT called with invalid replySize = %d, pReplyData = %p, expected replySize = %zu", replySize, pReplyData, sizeof(int32_t));
return -EINVAL;
}
SET(int32_t, pReplyData, 0);
@ -698,7 +697,7 @@ int32_t ViperContext::handleCommand(uint32_t cmdCode, uint32_t cmdSize, void *pC
}
case EFFECT_CMD_SET_CONFIG: {
if (cmdSize != sizeof(effect_config_t) || pCmdData == nullptr || replySize != sizeof(int32_t) || pReplyData == nullptr) {
VIPER_LOGE("EFFECT_CMD_SET_CONFIG called with invalid cmdSize = %d, pCmdData = %p, replySize = %d, pReplyData = %p, expected cmdSize = %zu, expected replySize = %zu", cmdSize, pCmdData, replySize, pReplyData, sizeof(effect_config_t), sizeof(int32_t));
ALOGE("EFFECT_CMD_SET_CONFIG called with invalid cmdSize = %d, pCmdData = %p, replySize = %d, pReplyData = %p, expected cmdSize = %zu, expected replySize = %zu", cmdSize, pCmdData, replySize, pReplyData, sizeof(effect_config_t), sizeof(int32_t));
return -EINVAL;
}
handleSetConfig((effect_config_t *) pCmdData);
@ -711,7 +710,7 @@ int32_t ViperContext::handleCommand(uint32_t cmdCode, uint32_t cmdSize, void *pC
}
case EFFECT_CMD_ENABLE: {
if (replySize != sizeof(int32_t) || pReplyData == nullptr) {
VIPER_LOGE("EFFECT_CMD_ENABLE called with invalid replySize = %d, pReplyData = %p, expected replySize = %zu", replySize, pReplyData, sizeof(int32_t));
ALOGE("EFFECT_CMD_ENABLE called with invalid replySize = %d, pReplyData = %p, expected replySize = %zu", replySize, pReplyData, sizeof(int32_t));
return -EINVAL;
}
enabled = true;
@ -720,7 +719,7 @@ int32_t ViperContext::handleCommand(uint32_t cmdCode, uint32_t cmdSize, void *pC
}
case EFFECT_CMD_DISABLE: {
if (replySize != sizeof(int32_t) || pReplyData == nullptr) {
VIPER_LOGE("EFFECT_CMD_DISABLE called with invalid replySize = %d, pReplyData = %p, expected replySize = %zu", replySize, pReplyData, sizeof(int32_t));
ALOGE("EFFECT_CMD_DISABLE called with invalid replySize = %d, pReplyData = %p, expected replySize = %zu", replySize, pReplyData, sizeof(int32_t));
return -EINVAL;
}
enabled = false;
@ -729,28 +728,28 @@ int32_t ViperContext::handleCommand(uint32_t cmdCode, uint32_t cmdSize, void *pC
}
case EFFECT_CMD_SET_PARAM: {
if (cmdSize < sizeof(effect_param_t) || pCmdData == nullptr || replySize != sizeof(int32_t) || pReplyData == nullptr) {
VIPER_LOGE("EFFECT_CMD_SET_PARAM called with invalid cmdSize = %d, pCmdData = %p, replySize = %d, pReplyData = %p, expected cmdSize >= %zu, expected replySize >= %zu", cmdSize, pCmdData, replySize, pReplyData, sizeof(effect_param_t), sizeof(int32_t));
ALOGE("EFFECT_CMD_SET_PARAM called with invalid cmdSize = %d, pCmdData = %p, replySize = %d, pReplyData = %p, expected cmdSize >= %zu, expected replySize >= %zu", cmdSize, pCmdData, replySize, pReplyData, sizeof(effect_param_t), sizeof(int32_t));
return -EINVAL;
}
return handleSetParam((effect_param_t *) pCmdData, pReplyData);
}
case EFFECT_CMD_GET_PARAM: {
if (cmdSize < sizeof(effect_param_t) || pCmdData == nullptr || replySize < sizeof(effect_param_t) || pReplyData == nullptr) {
VIPER_LOGE("EFFECT_CMD_GET_PARAM called with invalid cmdSize = %d, pCmdData = %p, replySize = %d, pReplyData = %p, expected cmdSize >= %zu, expected replySize >= %zu", cmdSize, pCmdData, replySize, pReplyData, sizeof(effect_param_t), sizeof(effect_param_t));
ALOGE("EFFECT_CMD_GET_PARAM called with invalid cmdSize = %d, pCmdData = %p, replySize = %d, pReplyData = %p, expected cmdSize >= %zu, expected replySize >= %zu", cmdSize, pCmdData, replySize, pReplyData, sizeof(effect_param_t), sizeof(effect_param_t));
return -EINVAL;
}
return handleGetParam((effect_param_t *) pCmdData, (effect_param_t *) pReplyData, pReplySize);
}
case EFFECT_CMD_GET_CONFIG: {
if (replySize != sizeof(effect_config_t) || pReplyData == nullptr) {
VIPER_LOGE("EFFECT_CMD_GET_CONFIG called with invalid replySize = %d, pReplyData = %p, expected replySize = %zu", replySize, pReplyData, sizeof(effect_config_t));
ALOGE("EFFECT_CMD_GET_CONFIG called with invalid replySize = %d, pReplyData = %p, expected replySize = %zu", replySize, pReplyData, sizeof(effect_config_t));
return -EINVAL;
}
*(effect_config_t *) pReplyData = config;
return 0;
}
default: {
VIPER_LOGE("handleCommand called with unknown command: %d", cmdCode);
ALOGE("handleCommand called with unknown command: %d", cmdCode);
return -EINVAL;
}
}

View File

@ -5,7 +5,7 @@
#ifdef AOSP_SOONG_BUILD
#include <system/audio_effect.h>
#else
#include "essential.h"
#include <essential.h>
#endif
#include "viper/ViPER.h"
#include <string>

View File

@ -6,7 +6,7 @@
#include <cerrno>
#endif
#include "../log.h" // TODO: Remove this dependency
#include <log.h> // TODO: Remove this dependency
enum class Architecture : uint8_t {
UNKNOWN = 0,

81
src/include/log.h Normal file
View File

@ -0,0 +1,81 @@
/*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <android/log.h>
#ifndef LOG_TAG
#define LOG_TAG "ViPER4Android"
#endif
#ifndef LOG_NDEBUG
#ifdef NDEBUG
#define LOG_NDEBUG 1
#else
#define LOG_NDEBUG 0
#endif
#endif
/*
* Basic log message macros intended to emulate the behavior of log/log.h
* in system core. This should be dependent only on ndk exposed logging
* functionality.
*/
#ifndef ALOG
#define ALOG(priority, tag, ...) \
__android_log_print(ANDROID_##priority, tag, __VA_ARGS__)
#endif
#ifndef ALOGV
#if LOG_NDEBUG
#define ALOGV(...) ((void)0)
#else
#define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#endif
#endif
#ifndef ALOGD
#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#endif
#ifndef ALOGI
#define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__))
#endif
#ifndef ALOGW
#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
#endif
#ifndef ALOGE
#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
#endif
#ifndef ALOGF
#define ALOGF(...) ((void)ALOG(LOG_FATAL, LOG_TAG, __VA_ARGS__))
#endif
/*
* Log a fatal error if cond is true. The condition test is inverted from
* assert(3) semantics. The test and message are not stripped from release
* builds
*/
#ifndef ALOG_ALWAYS_FATAL_IF
#define ALOG_ALWAYS_FATAL_IF(cond, ...) \
if (cond) __android_log_assert(#cond, LOG_TAG, __VA_ARGS__)
#endif

View File

@ -1,9 +0,0 @@
#pragma once
#include <android/log.h>
#define TAG "ViPER4Android"
#define VIPER_LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
#define VIPER_LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
#define VIPER_LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)

View File

@ -1,7 +1,7 @@
#include "ViPER.h"
#include <cstring>
#include <chrono>
#include "constants.h"
#include <constants.h>
#include <log.h>
ViPER::ViPER() :
frameCount(0),
@ -11,8 +11,8 @@ ViPER::ViPER() :
iirFilter(IIRFilter(10)),
gainL(1.0),
gainR(1.0) {
VIPER_LOGI("Welcome to ViPER FX");
VIPER_LOGI("Current version is %d", VIPER_VERSION);
ALOGI("Welcome to ViPER FX");
ALOGI("Current version is %d", VIPER_VERSION);
this->convolver.SetEnable(false);
this->convolver.SetSamplingRate(this->samplingRate);
@ -94,7 +94,7 @@ void ViPER::process(std::vector<float>& buffer, uint32_t size) {
uint32_t tmpBufSize;
if (this->convolver.GetEnabled() || this->vhe.GetEnabled()) {
// VIPER_LOGD("Convolver or VHE is enable, use wave buffer");
// ALOGD("Convolver or VHE is enable, use wave buffer");
if (!this->waveBuffer.PushSamples(buffer.data(), size)) {
this->waveBuffer.Reset();
@ -119,7 +119,7 @@ void ViPER::process(std::vector<float>& buffer, uint32_t size) {
tmpBuf = ptr;
tmpBufSize = ret;
} else {
// VIPER_LOGD("Convolver and VHE are disabled, use adaptive buffer");
// ALOGD("Convolver and VHE are disabled, use adaptive buffer");
if (this->adaptiveBuffer.PushFrames(buffer.data(), size)) {
this->adaptiveBuffer.SetBufferOffset(size);
@ -132,7 +132,7 @@ void ViPER::process(std::vector<float>& buffer, uint32_t size) {
}
}
// VIPER_LOGD("Process buffer size: %d", tmpBufSize);
// ALOGD("Process buffer size: %d", tmpBufSize);
if (tmpBufSize != 0) {
this->viperDdc.Process(tmpBuf, size);
this->spectrumExtend.Process(tmpBuf, size);
@ -175,7 +175,7 @@ void ViPER::process(std::vector<float>& buffer, uint32_t size) {
//void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, uint32_t arrSize,
// signed char *arr) {
// VIPER_LOGD("Dispatch command: %d, %d, %d, %d, %d, %d, %p", param, val1, val2, val3, val4, arrSize, arr);
// ALOGD("Dispatch command: %d, %d, %d, %d, %d, %d, %p", param, val1, val2, val3, val4, arrSize, arr);
// switch (param) {
// case PARAM_SET_RESET_STATUS: {
// this->reset();

View File

@ -1,6 +1,6 @@
#include "AnalogX.h"
#include <cstring>
#include "../constants.h"
#include <constants.h>
static const float ANALOGX_HARMONICS[] = {
0.01f,

View File

@ -1,5 +1,5 @@
#include "ColorfulMusic.h"
#include "../constants.h"
#include <constants.h>
ColorfulMusic::ColorfulMusic() {
this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;

View File

@ -1,5 +1,5 @@
#include "Convolver.h"
#include "../constants.h"
#include <constants.h>
#include <cstring>
#include <cstddef>

View File

@ -1,6 +1,6 @@
#include <cstring>
#include "DiffSurround.h"
#include "../constants.h"
#include <constants.h>
DiffSurround::DiffSurround() : buffers({
WaveBuffer(1, 0x1000),

View File

@ -1,5 +1,5 @@
#include "DynamicSystem.h"
#include "../constants.h"
#include <constants.h>
DynamicSystem::DynamicSystem() {
this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;

View File

@ -1,6 +1,6 @@
#include <cmath>
#include "FETCompressor.h"
#include "../constants.h"
#include <constants.h>
static const float DEFAULT_FETCOMP_PARAMETERS[] = {
1.000000,

View File

@ -1,7 +1,7 @@
#include <cmath>
#include <cstring>
#include "IIRFilter.h"
#include "../constants.h"
#include <constants.h>
// Iscle: Verified with the latest version at 13/12/2022

View File

@ -1,6 +1,6 @@
#include <cmath>
#include "PlaybackGain.h"
#include "../constants.h"
#include <constants.h>
PlaybackGain::PlaybackGain() {
this->enable = false;

View File

@ -1,5 +1,4 @@
#include "Reverberation.h"
#include "../constants.h"
Reverberation::Reverberation() {
this->model.SetRoomSize(0.0);

View File

@ -1,5 +1,5 @@
#include "SpeakerCorrection.h"
#include "../constants.h"
#include <constants.h>
// Iscle: Verified with the latest version at 13/12/2022

View File

@ -1,5 +1,5 @@
#include "SpectrumExtend.h"
#include "../constants.h"
#include <constants.h>
static const float SPECTRUM_HARMONICS[10] = {
0.02f,

View File

@ -1,5 +1,5 @@
#include "VHE.h"
#include "../constants.h"
#include <constants.h>
#include "VHE_L0.h"
#include "VHE_L1.h"
#include "VHE_L2.h"
@ -48,12 +48,12 @@ void VHE::Reset() {
this->convRight.UnloadKernel();
if (this->effectLevel > 4) {
VIPER_LOGD("Invalid effect level %d", this->effectLevel);
ALOGD("Invalid effect level %d", this->effectLevel);
return;
}
if (this->samplingRate != 44100 && this->samplingRate != 48000) {
VIPER_LOGD("Invalid sampling rate %d", this->samplingRate);
ALOGD("Invalid sampling rate %d", this->samplingRate);
return;
}

View File

@ -1,5 +1,5 @@
#include "ViPERBass.h"
#include "../constants.h"
#include <constants.h>
// Iscle: Verified with the latest version at 13/12/2022

View File

@ -1,5 +1,5 @@
#include "ViPERClarity.h"
#include "../constants.h"
#include <constants.h>
// Iscle: Verified with the latest version at 13/12/2022

View File

@ -1,6 +1,6 @@
#include "ViPERDDC.h"
#include "../../log.h"
#include "../constants.h"
#include <log.h>
#include <constants.h>
#include <cstring>
ViPERDDC::ViPERDDC() :
@ -146,7 +146,7 @@ void ViPERDDC::SetSamplingRate(uint32_t samplingRate) {
if (this->samplingRate != samplingRate) {
this->samplingRate = samplingRate;
if (!isSamplingRateValid()) {
VIPER_LOGE("ViPERDDC::SetSamplingRate() -> Invalid sampling rate: %d", this->samplingRate);
ALOGE("ViPERDDC::SetSamplingRate() -> Invalid sampling rate: %d", this->samplingRate);
}
Reset();
}

View File

@ -1,7 +1,7 @@
#include <cstring>
#include <cmath>
#include "Crossfeed.h"
#include "../constants.h"
#include <constants.h>
// Basically Bauer-to-Stereophonic Binaural filter
// See: http://bs2b.sourceforge.net/

View File

@ -1,6 +1,6 @@
#include "DepthSurround.h"
#include <cmath>
#include "../constants.h"
#include <constants.h>
DepthSurround::DepthSurround() {
this->strength = 0;

View File

@ -1,5 +1,5 @@
#include "DynamicBass.h"
#include "../constants.h"
#include <constants.h>
DynamicBass::DynamicBass() {
this->qPeak = 0;

View File

@ -1,5 +1,5 @@
#include "HiFi.h"
#include "../constants.h"
#include <constants.h>
HiFi::HiFi() {
this->gain = 1.f;

View File

@ -1,5 +1,4 @@
#include "MinPhaseIIRCoeffs.h"
#include "../constants.h"
#include <cmath>
// Iscle: Verified with the latest version at 13/12/2022

View File

@ -1,5 +1,5 @@
#include "NoiseSharpening.h"
#include "../constants.h"
#include <constants.h>
NoiseSharpening::NoiseSharpening() {
this->samplingRate = VIPER_DEFAULT_SAMPLING_RATE;

View File

@ -1,5 +1,5 @@
#include "PassFilter.h"
#include "../constants.h"
#include <constants.h>
PassFilter::PassFilter() : filters({
IIR_NOrder_BW_LH(3),

View File

@ -1,5 +1,5 @@
#include "PolesFilter.h"
#include "../constants.h"
#include <constants.h>
#include <cstring>
#include <cmath>

View File

@ -1,5 +1,5 @@
#include "Polyphase.h"
#include "../constants.h"
#include <constants.h>
static const float POLYPHASE_COEFFICIENTS_2[] = {
-0.002339,

View File

@ -1,5 +1,5 @@
#include "Subwoofer.h"
#include "../constants.h"
#include <constants.h>
#include <cmath>
Subwoofer::Subwoofer() {