Fix build

This commit is contained in:
Iscle 2025-04-02 02:02:51 +02:00
parent d23bbdf7e1
commit e769ff7d4e
11 changed files with 560 additions and 170 deletions

View File

@ -6,6 +6,15 @@ project("ViPER4Android")
add_compile_definitions(VIPER_VERSION=20240314)
# External
set(CORE_SRC
external/core/libcutils/ashmem-host.cpp
external/core/libcutils/native_handle.cpp
external/core/libutils/SystemClock.cpp
external/core/libutils/Timers.cpp)
set(LIBFMQ_SRC
external/libfmq/EventFlag.cpp)
include_directories(
external/libbase/include
external/core/include
@ -148,6 +157,9 @@ include_directories(generated/include)
include_directories(src/include)
set(FILES
# Shim
src/shim.cpp
# Main
src/viper/ViPER.cpp
src/ViPER4Android.cpp
@ -203,6 +215,8 @@ set(FILES
src/viper/utils/WaveBuffer.cpp)
add_library(v4a_re SHARED
${CORE_SRC}
${LIBFMQ_SRC}
${AIDL_SRC}
${FILES})

View File

@ -3,7 +3,6 @@
#include <cmath>
#include <chrono>
#include "ViperContext.h"
#include "log.h"
#include "viper/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,34 +66,34 @@ 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;
// }
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;
}
@ -102,8 +101,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;
}
@ -111,13 +110,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
@ -135,7 +134,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;
}
@ -144,23 +143,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;
}
@ -169,182 +168,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 = {
@ -371,7 +370,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;
}
@ -379,230 +378,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;
}
}
@ -614,7 +613,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;
}
@ -678,7 +677,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;
}
}
@ -689,7 +688,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);
@ -697,7 +696,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);
@ -710,7 +709,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;
@ -719,7 +718,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;
@ -728,28 +727,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

@ -1,2 +1,373 @@
/* Shim for external dependencies */
/*
* Copyright (C) 2005-2017 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 <stdbool.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <android/log.h>
__BEGIN_DECLS
/*
* Normally we strip the effects of ALOGV (VERBOSE messages),
* LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the
* release builds by defining NDEBUG. You can modify this (for
* example with "#define LOG_NDEBUG 0" at the top of your source
* file) to change that behavior.
*/
#ifndef LOG_NDEBUG
#ifdef NDEBUG
#define LOG_NDEBUG 1
#else
#define LOG_NDEBUG 0
#endif
#endif
#ifndef LOG_TAG
#define LOG_TAG "ViPER4Android"
#endif
/* --------------------------------------------------------------------- */
/*
* This file uses ", ## __VA_ARGS__" zero-argument token pasting to
* work around issues with debug-only syntax errors in assertions
* that are missing format strings. See commit
* 19299904343daf191267564fe32e6cd5c165cd42
*/
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#endif
/*
* Use __VA_ARGS__ if running a static analyzer,
* to avoid warnings of unused variables in __VA_ARGS__.
* Use constexpr function in C++ mode, so these macros can be used
* in other constexpr functions without warning.
*/
#ifdef __clang_analyzer__
#ifdef __cplusplus
extern "C++" {
template <typename... Ts>
constexpr int __fake_use_va_args(Ts...) {
return 0;
}
}
#else
extern int __fake_use_va_args(int, ...);
#endif /* __cplusplus */
#define __FAKE_USE_VA_ARGS(...) ((void)__fake_use_va_args(0, ##__VA_ARGS__))
#else
#define __FAKE_USE_VA_ARGS(...) ((void)(0))
#endif /* __clang_analyzer__ */
#ifndef __predict_false
#define __predict_false(exp) __builtin_expect((exp) != 0, 0)
#endif
#define android_writeLog(prio, tag, text) __android_log_write(prio, tag, text)
#define android_printLog(prio, tag, ...) \
__android_log_print(prio, tag, __VA_ARGS__)
#define android_vprintLog(prio, cond, tag, ...) \
__android_log_vprint(prio, tag, __VA_ARGS__)
/*
* Log macro that allows you to specify a number for the priority.
*/
#ifndef LOG_PRI
#define LOG_PRI(priority, tag, ...) android_printLog(priority, tag, __VA_ARGS__)
#endif
/*
* Log macro that allows you to pass in a varargs ("args" is a va_list).
*/
#ifndef LOG_PRI_VA
#define LOG_PRI_VA(priority, tag, fmt, args) \
android_vprintLog(priority, NULL, tag, fmt, args)
#endif
/* --------------------------------------------------------------------- */
/* XXX Macros to work around syntax errors in places where format string
* arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF
* (happens only in debug builds).
*/
/* Returns 2nd arg. Used to substitute default value if caller's vararg list
* is empty.
*/
#define __android_second(dummy, second, ...) second
/* If passed multiple args, returns ',' followed by all but 1st arg, otherwise
* returns nothing.
*/
#define __android_rest(first, ...) , ##__VA_ARGS__
#define android_printAssert(cond, tag, ...) \
__android_log_assert(cond, tag, \
__android_second(0, ##__VA_ARGS__, NULL) \
__android_rest(__VA_ARGS__))
/*
* Log a fatal error. If the given condition fails, this stops program
* execution like a normal assertion, but also generating the given message.
* It is NOT stripped from release builds. Note that the condition test
* is -inverted- from the normal assert() semantics.
*/
#ifndef LOG_ALWAYS_FATAL_IF
#define LOG_ALWAYS_FATAL_IF(cond, ...) \
((__predict_false(cond)) ? (__FAKE_USE_VA_ARGS(__VA_ARGS__), \
((void)android_printAssert(#cond, LOG_TAG, ##__VA_ARGS__))) \
: ((void)0))
#endif
#ifndef LOG_ALWAYS_FATAL
#define LOG_ALWAYS_FATAL(...) \
(((void)android_printAssert(NULL, LOG_TAG, ##__VA_ARGS__)))
#endif
/*
* Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that
* are stripped out of release builds.
*/
#if LOG_NDEBUG
#ifndef LOG_FATAL_IF
#define LOG_FATAL_IF(cond, ...) __FAKE_USE_VA_ARGS(__VA_ARGS__)
#endif
#ifndef LOG_FATAL
#define LOG_FATAL(...) __FAKE_USE_VA_ARGS(__VA_ARGS__)
#endif
#else
#ifndef LOG_FATAL_IF
#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ##__VA_ARGS__)
#endif
#ifndef LOG_FATAL
#define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__)
#endif
#endif
/*
* Assertion that generates a log message when the assertion fails.
* Stripped out of release builds. Uses the current LOG_TAG.
*/
#ifndef ALOG_ASSERT
#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ##__VA_ARGS__)
#endif
/* --------------------------------------------------------------------- */
/*
* C/C++ logging functions. See the logging documentation for API details.
*
* We'd like these to be available from C code (in case we import some from
* somewhere), so this has a C interface.
*
* The output will be correct when the log file is shared between multiple
* threads and/or multiple processes so long as the operating system
* supports O_APPEND. These calls have mutex-protected data structures
* and so are NOT reentrant. Do not use LOG in a signal handler.
*/
/* --------------------------------------------------------------------- */
/*
* Simplified macro to send a verbose log message using the current LOG_TAG.
*/
#ifndef ALOGV
#define __ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
#if LOG_NDEBUG
#define ALOGV(...) \
do { \
__FAKE_USE_VA_ARGS(__VA_ARGS__); \
if (false) { \
__ALOGV(__VA_ARGS__); \
} \
} while (false)
#else
#define ALOGV(...) __ALOGV(__VA_ARGS__)
#endif
#endif
#ifndef ALOGV_IF
#if LOG_NDEBUG
#define ALOGV_IF(cond, ...) __FAKE_USE_VA_ARGS(__VA_ARGS__)
#else
#define ALOGV_IF(cond, ...) \
((__predict_false(cond)) \
? (__FAKE_USE_VA_ARGS(__VA_ARGS__), (void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
: ((void)0))
#endif
#endif
/*
* Simplified macro to send a debug log message using the current LOG_TAG.
*/
#ifndef ALOGD
#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#endif
#ifndef ALOGD_IF
#define ALOGD_IF(cond, ...) \
((__predict_false(cond)) \
? (__FAKE_USE_VA_ARGS(__VA_ARGS__), (void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
: ((void)0))
#endif
/*
* Simplified macro to send an info log message using the current LOG_TAG.
*/
#ifndef ALOGI
#define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__))
#endif
#ifndef ALOGI_IF
#define ALOGI_IF(cond, ...) \
((__predict_false(cond)) \
? (__FAKE_USE_VA_ARGS(__VA_ARGS__), (void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \
: ((void)0))
#endif
/*
* Simplified macro to send a warning log message using the current LOG_TAG.
*/
#ifndef ALOGW
#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__))
#endif
#ifndef ALOGW_IF
#define ALOGW_IF(cond, ...) \
((__predict_false(cond)) \
? (__FAKE_USE_VA_ARGS(__VA_ARGS__), (void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \
: ((void)0))
#endif
/*
* Simplified macro to send an error log message using the current LOG_TAG.
*/
#ifndef ALOGE
#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
#endif
#ifndef ALOGE_IF
#define ALOGE_IF(cond, ...) \
((__predict_false(cond)) \
? (__FAKE_USE_VA_ARGS(__VA_ARGS__), (void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
: ((void)0))
#endif
/* --------------------------------------------------------------------- */
/*
* Conditional based on whether the current LOG_TAG is enabled at
* verbose priority.
*/
#ifndef IF_ALOGV
#if LOG_NDEBUG
#define IF_ALOGV() if (false)
#else
#define IF_ALOGV() IF_ALOG(LOG_VERBOSE, LOG_TAG)
#endif
#endif
/*
* Conditional based on whether the current LOG_TAG is enabled at
* debug priority.
*/
#ifndef IF_ALOGD
#define IF_ALOGD() IF_ALOG(LOG_DEBUG, LOG_TAG)
#endif
/*
* Conditional based on whether the current LOG_TAG is enabled at
* info priority.
*/
#ifndef IF_ALOGI
#define IF_ALOGI() IF_ALOG(LOG_INFO, LOG_TAG)
#endif
/*
* Conditional based on whether the current LOG_TAG is enabled at
* warn priority.
*/
#ifndef IF_ALOGW
#define IF_ALOGW() IF_ALOG(LOG_WARN, LOG_TAG)
#endif
/*
* Conditional based on whether the current LOG_TAG is enabled at
* error priority.
*/
#ifndef IF_ALOGE
#define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG)
#endif
/* --------------------------------------------------------------------- */
/*
* Basic log message macro.
*
* Example:
* ALOG(LOG_WARN, NULL, "Failed with error %d", errno);
*
* The second argument may be NULL or "" to indicate the "global" tag.
*/
#ifndef ALOG
#define ALOG(priority, tag, ...) LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
#endif
/*
* Conditional given a desired logging priority and tag.
*/
#ifndef IF_ALOG
#define IF_ALOG(priority, tag) if (android_testLog(ANDROID_##priority, tag))
#endif
/* --------------------------------------------------------------------- */
/*
* IF_ALOG uses android_testLog, but IF_ALOG can be overridden.
* android_testLog will remain constant in its purpose as a wrapper
* for Android logging filter policy, and can be subject to
* change. It can be reused by the developers that override
* IF_ALOG as a convenient means to reimplement their policy
* over Android.
*/
#if LOG_NDEBUG /* Production */
#define android_testLog(prio, tag) \
(__android_log_is_loggable_len(prio, tag, (tag) ? strlen(tag) : 0, ANDROID_LOG_DEBUG) != 0)
#else
#define android_testLog(prio, tag) \
(__android_log_is_loggable_len(prio, tag, (tag) ? strlen(tag) : 0, ANDROID_LOG_VERBOSE) != 0)
#endif
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
__END_DECLS

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__)

19
src/shim.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <string>
namespace android::hardware::details {
void check(bool exp) {
}
void check(bool exp, const char* message) {
}
void logError(const std::string &message) {
}
void errorWriteLog(int tag, const char* info) {
}
} // namespace android::hardware::details

View File

@ -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

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

View File

@ -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,4 @@
#include "ViPERDDC.h"
#include "../../log.h"
#include "../constants.h"
#include <cstring>
@ -146,7 +145,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,5 +1,4 @@
#include "viper_aidl.h"
#include "log.h"
#include "viper/constants.h"
#include <aidl/android/media/audio/common/PcmType.h>
#include <android-base/thread_annotations.h>
@ -118,14 +117,14 @@ ndk::ScopedAStatus ViPER4AndroidAIDL::open(const Parameter::Common &common,
const std::optional<Parameter::Specific> &specific,
IEffect::OpenEffectReturn *ret) {
if (common.input.base.format.pcm != PcmType::FLOAT_32_BIT) {
VIPER_LOGE("open called with invalid PCM type");
ALOGE("open called with invalid PCM type");
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
std::lock_guard lg(mMutex);
if (mState != State::INIT) {
VIPER_LOGD("open: already opened");
ALOGD("open: already opened");
return ndk::ScopedAStatus::ok();
}
@ -143,21 +142,21 @@ ndk::ScopedAStatus ViPER4AndroidAIDL::open(const Parameter::Common &common,
mOutputMQ = std::make_shared<DataMQ>(outBufferSizeInFloat);
if (!mStatusMQ->isValid() || !mInputMQ->isValid() || !mOutputMQ->isValid()) {
VIPER_LOGE("open: failed to create message queues");
ALOGE("open: failed to create message queues");
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
android::status_t status = EventFlag::createEventFlag(
mStatusMQ->getEventFlagWord(), &mEventFlag);
if (status != android::OK || mEventFlag == nullptr) {
VIPER_LOGE("open: failed to create event flag");
ALOGE("open: failed to create event flag");
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
mWorkBuffer.resize(std::max(inBufferSizeInFloat, outBufferSizeInFloat));
if (specific.has_value()) {
VIPER_LOGD("open: specific parameters provided, ignoring for now...");
ALOGD("open: specific parameters provided, ignoring for now...");
}
mState = State::IDLE;
@ -172,58 +171,58 @@ ndk::ScopedAStatus ViPER4AndroidAIDL::open(const Parameter::Common &common,
}
ndk::ScopedAStatus ViPER4AndroidAIDL::close() {
VIPER_LOGD("close called");
ALOGD("close called");
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus
ViPER4AndroidAIDL::getDescriptor(Descriptor *descriptor) {
if (descriptor == nullptr) {
VIPER_LOGE("getDescriptor called with null descriptor");
ALOGE("getDescriptor called with null descriptor");
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
VIPER_LOGD("getDescriptor: returning descriptor");
ALOGD("getDescriptor: returning descriptor");
*descriptor = kDescriptor;
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus ViPER4AndroidAIDL::command(CommandId command_id) {
VIPER_LOGD("command called");
ALOGD("command called");
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
ndk::ScopedAStatus ViPER4AndroidAIDL::getState(State *state) {
VIPER_LOGD("getState called");
ALOGD("getState called");
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
ndk::ScopedAStatus
ViPER4AndroidAIDL::setParameter(const Parameter &parameter) {
VIPER_LOGD("setParameter called");
ALOGD("setParameter called");
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
ndk::ScopedAStatus
ViPER4AndroidAIDL::getParameter(const Parameter::Id &parameter_id, Parameter *parameter) {
VIPER_LOGD("getParameter called");
ALOGD("getParameter called");
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
ndk::ScopedAStatus
ViPER4AndroidAIDL::reopen(IEffect::OpenEffectReturn *open_effect_return) {
VIPER_LOGD("reopen called");
ALOGD("reopen called");
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
void ViPER4AndroidAIDL::threadLoop() {
VIPER_LOGD("threadLoop started");
ALOGD("threadLoop started");
while (true) {
{
std::unique_lock l(mThreadMutex);
::android::base::ScopedLockAssertion lock_assertion(mThreadMutex);
mThreadCv.wait(l, [&]() REQUIRES(mThreadMutex) { return mThreadExit || !mThreadStop; });
if (mThreadExit) {
VIPER_LOGD("threadLoop exiting");
ALOGD("threadLoop exiting");
return;
}
}
@ -240,14 +239,14 @@ void ViPER4AndroidAIDL::process() {
if (!mEventFlag ||
mEventFlag->wait(kEventFlagDataMqNotEmpty, &efState, 0 /* no timeout */, true /* retry */) != android::OK ||
!(efState & kEventFlagDataMqNotEmpty)) {
VIPER_LOGE("process: failed to wait for event flag");
ALOGE("process: failed to wait for event flag");
return;
}
{
std::lock_guard lg(mMutex);
if (mState != State::PROCESSING && mState != State::DRAINING) {
VIPER_LOGD("process: skip process in state: %d", mState);
ALOGD("process: skip process in state: %d", mState);
return;
}
@ -256,7 +255,7 @@ void ViPER4AndroidAIDL::process() {
if (processSamples) {
mInputMQ->read(buffer, processSamples);
// IEffect::Status status = effectProcessImpl(buffer, buffer, processSamples);
VIPER_LOGD("process: processing %zu samples", processSamples);
ALOGD("process: processing %zu samples", processSamples);
IEffect::Status status = {STATUS_OK, static_cast<int32_t>(processSamples), static_cast<int32_t>(processSamples)};
mOutputMQ->write(buffer, status.fmqProduced);
mStatusMQ->writeBlocking(&status, 1);
@ -266,29 +265,29 @@ void ViPER4AndroidAIDL::process() {
extern "C" binder_exception_t createEffect(const AudioUuid *audio_uuid, std::shared_ptr<IEffect> *instance) {
if (audio_uuid == nullptr || instance == nullptr) {
VIPER_LOGE("createEffect called with null arguments");
ALOGE("createEffect called with null arguments");
return EX_ILLEGAL_ARGUMENT;
}
VIPER_LOGD("createEffect: creating effect instance");
ALOGD("createEffect: creating effect instance");
*instance = ndk::SharedRefBase::make<ViPER4AndroidAIDL>();
return EX_NONE;
}
extern "C" binder_exception_t destroyEffect(const std::shared_ptr<IEffect> &instance) {
VIPER_LOGD("destroyEffect called");
ALOGD("destroyEffect called");
return EX_ILLEGAL_STATE;
}
extern "C" binder_exception_t queryEffect(const AudioUuid *audio_uuid, Descriptor *descriptor) {
if (audio_uuid == nullptr || descriptor == nullptr) {
VIPER_LOGE("queryEffect called with null arguments");
ALOGE("queryEffect called with null arguments");
return EX_ILLEGAL_ARGUMENT;
}
if (*audio_uuid != kUuid) {
VIPER_LOGE("queryEffect called with invalid uuid");
ALOGE("queryEffect called with invalid uuid");
return EX_ILLEGAL_ARGUMENT;
}
VIPER_LOGD("queryEffect: returning descriptor");
ALOGD("queryEffect: returning descriptor");
*descriptor = kDescriptor;
return EX_NONE;
}

View File

@ -11,8 +11,6 @@ using aidl::android::hardware::audio::effect::State;
class ViPER4AndroidAIDL : public BnEffect {
public:
ViPER4AndroidAIDL();
::ndk::ScopedAStatus open(const ::aidl::android::hardware::audio::effect::Parameter::Common &common, const std::optional< ::aidl::android::hardware::audio::effect::Parameter::Specific> &specific, ::aidl::android::hardware::audio::effect::IEffect::OpenEffectReturn *ret) override;
::ndk::ScopedAStatus close() override;
::ndk::ScopedAStatus getDescriptor(::aidl::android::hardware::audio::effect::Descriptor *_aidl_return) override;