mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Effect AIDL: Refactor effect capability with Range implementation am: 8781102d74
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2433252 Change-Id: Ibc64aec405112499bd6a96721baf14e6146bc791 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -78,7 +78,7 @@ ndk::ScopedAStatus EffectImpl::close() {
|
|||||||
ndk::ScopedAStatus EffectImpl::setParameter(const Parameter& param) {
|
ndk::ScopedAStatus EffectImpl::setParameter(const Parameter& param) {
|
||||||
LOG(DEBUG) << __func__ << " with: " << param.toString();
|
LOG(DEBUG) << __func__ << " with: " << param.toString();
|
||||||
|
|
||||||
auto tag = param.getTag();
|
const auto tag = param.getTag();
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case Parameter::common:
|
case Parameter::common:
|
||||||
case Parameter::deviceDescription:
|
case Parameter::deviceDescription:
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ using aidl::android::hardware::audio::effect::AcousticEchoCancelerSw;
|
|||||||
using aidl::android::hardware::audio::effect::Descriptor;
|
using aidl::android::hardware::audio::effect::Descriptor;
|
||||||
using aidl::android::hardware::audio::effect::IEffect;
|
using aidl::android::hardware::audio::effect::IEffect;
|
||||||
using aidl::android::hardware::audio::effect::kAcousticEchoCancelerSwImplUUID;
|
using aidl::android::hardware::audio::effect::kAcousticEchoCancelerSwImplUUID;
|
||||||
|
using aidl::android::hardware::audio::effect::Range;
|
||||||
using aidl::android::media::audio::common::AudioUuid;
|
using aidl::android::media::audio::common::AudioUuid;
|
||||||
|
|
||||||
extern "C" binder_exception_t createEffect(const AudioUuid* in_impl_uuid,
|
extern "C" binder_exception_t createEffect(const AudioUuid* in_impl_uuid,
|
||||||
@@ -60,8 +61,14 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
|
|||||||
namespace aidl::android::hardware::audio::effect {
|
namespace aidl::android::hardware::audio::effect {
|
||||||
|
|
||||||
const std::string AcousticEchoCancelerSw::kEffectName = "AcousticEchoCancelerSw";
|
const std::string AcousticEchoCancelerSw::kEffectName = "AcousticEchoCancelerSw";
|
||||||
const AcousticEchoCanceler::Capability AcousticEchoCancelerSw::kCapability = {
|
|
||||||
.maxEchoDelayUs = 500, .supportMobileMode = false};
|
const std::vector<Range::AcousticEchoCancelerRange> AcousticEchoCancelerSw::kRanges = {
|
||||||
|
MAKE_RANGE(AcousticEchoCanceler, echoDelayUs, 0, 500),
|
||||||
|
/* mobile mode not supported, and not settable */
|
||||||
|
MAKE_RANGE(AcousticEchoCanceler, mobileMode, false, false)};
|
||||||
|
|
||||||
|
const Capability AcousticEchoCancelerSw::kCapability = {.range = AcousticEchoCancelerSw::kRanges};
|
||||||
|
|
||||||
const Descriptor AcousticEchoCancelerSw::kDescriptor = {
|
const Descriptor AcousticEchoCancelerSw::kDescriptor = {
|
||||||
.common = {.id = {.type = kAcousticEchoCancelerTypeUUID,
|
.common = {.id = {.type = kAcousticEchoCancelerTypeUUID,
|
||||||
.uuid = kAcousticEchoCancelerSwImplUUID,
|
.uuid = kAcousticEchoCancelerSwImplUUID,
|
||||||
@@ -71,8 +78,7 @@ const Descriptor AcousticEchoCancelerSw::kDescriptor = {
|
|||||||
.volume = Flags::Volume::CTRL},
|
.volume = Flags::Volume::CTRL},
|
||||||
.name = AcousticEchoCancelerSw::kEffectName,
|
.name = AcousticEchoCancelerSw::kEffectName,
|
||||||
.implementor = "The Android Open Source Project"},
|
.implementor = "The Android Open Source Project"},
|
||||||
.capability = Capability::make<Capability::acousticEchoCanceler>(
|
.capability = AcousticEchoCancelerSw::kCapability};
|
||||||
AcousticEchoCancelerSw::kCapability)};
|
|
||||||
|
|
||||||
ndk::ScopedAStatus AcousticEchoCancelerSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus AcousticEchoCancelerSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
||||||
@@ -87,8 +93,9 @@ ndk::ScopedAStatus AcousticEchoCancelerSw::setParameterSpecific(
|
|||||||
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
|
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
|
||||||
|
|
||||||
auto& param = specific.get<Parameter::Specific::acousticEchoCanceler>();
|
auto& param = specific.get<Parameter::Specific::acousticEchoCanceler>();
|
||||||
auto tag = param.getTag();
|
RETURN_IF(!inRange(param, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
|
||||||
|
|
||||||
|
auto tag = param.getTag();
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case AcousticEchoCanceler::echoDelayUs: {
|
case AcousticEchoCanceler::echoDelayUs: {
|
||||||
RETURN_IF(mContext->setEchoDelay(param.get<AcousticEchoCanceler::echoDelayUs>()) !=
|
RETURN_IF(mContext->setEchoDelay(param.get<AcousticEchoCanceler::echoDelayUs>()) !=
|
||||||
@@ -182,10 +189,6 @@ IEffect::Status AcousticEchoCancelerSw::effectProcessImpl(float* in, float* out,
|
|||||||
}
|
}
|
||||||
|
|
||||||
RetCode AcousticEchoCancelerSwContext::setEchoDelay(int echoDelayUs) {
|
RetCode AcousticEchoCancelerSwContext::setEchoDelay(int echoDelayUs) {
|
||||||
if (echoDelayUs < 0 || echoDelayUs > AcousticEchoCancelerSw::kCapability.maxEchoDelayUs) {
|
|
||||||
LOG(DEBUG) << __func__ << " illegal delay " << echoDelayUs;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
mEchoDelayUs = echoDelayUs;
|
mEchoDelayUs = echoDelayUs;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <aidl/android/hardware/audio/effect/BnEffect.h>
|
#include <aidl/android/hardware/audio/effect/BnEffect.h>
|
||||||
|
#include <aidl/android/hardware/audio/effect/Range.h>
|
||||||
#include <fmq/AidlMessageQueue.h>
|
#include <fmq/AidlMessageQueue.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -43,8 +44,7 @@ class AcousticEchoCancelerSwContext final : public EffectContext {
|
|||||||
class AcousticEchoCancelerSw final : public EffectImpl {
|
class AcousticEchoCancelerSw final : public EffectImpl {
|
||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const bool kStrengthSupported;
|
static const Capability kCapability;
|
||||||
static const AcousticEchoCanceler::Capability kCapability;
|
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
AcousticEchoCancelerSw() { LOG(DEBUG) << __func__; }
|
AcousticEchoCancelerSw() { LOG(DEBUG) << __func__; }
|
||||||
~AcousticEchoCancelerSw() {
|
~AcousticEchoCancelerSw() {
|
||||||
@@ -65,6 +65,7 @@ class AcousticEchoCancelerSw final : public EffectImpl {
|
|||||||
IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
|
IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const std::vector<Range::AcousticEchoCancelerRange> kRanges;
|
||||||
std::shared_ptr<AcousticEchoCancelerSwContext> mContext;
|
std::shared_ptr<AcousticEchoCancelerSwContext> mContext;
|
||||||
ndk::ScopedAStatus getParameterAcousticEchoCanceler(const AcousticEchoCanceler::Tag& tag,
|
ndk::ScopedAStatus getParameterAcousticEchoCanceler(const AcousticEchoCanceler::Tag& tag,
|
||||||
Parameter::Specific* specific);
|
Parameter::Specific* specific);
|
||||||
|
|||||||
@@ -60,8 +60,13 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
|
|||||||
namespace aidl::android::hardware::audio::effect {
|
namespace aidl::android::hardware::audio::effect {
|
||||||
|
|
||||||
const std::string AutomaticGainControlSw::kEffectName = "AutomaticGainControlSw";
|
const std::string AutomaticGainControlSw::kEffectName = "AutomaticGainControlSw";
|
||||||
const AutomaticGainControl::Capability AutomaticGainControlSw::kCapability = {
|
|
||||||
.maxFixedDigitalGainMb = 50000, .maxSaturationMarginMb = 10000};
|
const std::vector<Range::AutomaticGainControlRange> AutomaticGainControlSw::kRanges = {
|
||||||
|
MAKE_RANGE(AutomaticGainControl, fixedDigitalGainMb, 0, 50000),
|
||||||
|
MAKE_RANGE(AutomaticGainControl, saturationMarginMb, 0, 10000)};
|
||||||
|
|
||||||
|
const Capability AutomaticGainControlSw::kCapability = {.range = AutomaticGainControlSw::kRanges};
|
||||||
|
|
||||||
const Descriptor AutomaticGainControlSw::kDescriptor = {
|
const Descriptor AutomaticGainControlSw::kDescriptor = {
|
||||||
.common = {.id = {.type = kAutomaticGainControlTypeUUID,
|
.common = {.id = {.type = kAutomaticGainControlTypeUUID,
|
||||||
.uuid = kAutomaticGainControlSwImplUUID,
|
.uuid = kAutomaticGainControlSwImplUUID,
|
||||||
@@ -71,8 +76,7 @@ const Descriptor AutomaticGainControlSw::kDescriptor = {
|
|||||||
.volume = Flags::Volume::CTRL},
|
.volume = Flags::Volume::CTRL},
|
||||||
.name = AutomaticGainControlSw::kEffectName,
|
.name = AutomaticGainControlSw::kEffectName,
|
||||||
.implementor = "The Android Open Source Project"},
|
.implementor = "The Android Open Source Project"},
|
||||||
.capability = Capability::make<Capability::automaticGainControl>(
|
.capability = AutomaticGainControlSw::kCapability};
|
||||||
AutomaticGainControlSw::kCapability)};
|
|
||||||
|
|
||||||
ndk::ScopedAStatus AutomaticGainControlSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus AutomaticGainControlSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
||||||
@@ -87,8 +91,8 @@ ndk::ScopedAStatus AutomaticGainControlSw::setParameterSpecific(
|
|||||||
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
|
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
|
||||||
|
|
||||||
auto& param = specific.get<Parameter::Specific::automaticGainControl>();
|
auto& param = specific.get<Parameter::Specific::automaticGainControl>();
|
||||||
|
RETURN_IF(!inRange(param, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
|
||||||
auto tag = param.getTag();
|
auto tag = param.getTag();
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case AutomaticGainControl::fixedDigitalGainMb: {
|
case AutomaticGainControl::fixedDigitalGainMb: {
|
||||||
RETURN_IF(mContext->setDigitalGain(
|
RETURN_IF(mContext->setDigitalGain(
|
||||||
@@ -196,10 +200,6 @@ IEffect::Status AutomaticGainControlSw::effectProcessImpl(float* in, float* out,
|
|||||||
}
|
}
|
||||||
|
|
||||||
RetCode AutomaticGainControlSwContext::setDigitalGain(int gain) {
|
RetCode AutomaticGainControlSwContext::setDigitalGain(int gain) {
|
||||||
if (gain < 0 || gain > AutomaticGainControlSw::kCapability.maxFixedDigitalGainMb) {
|
|
||||||
LOG(DEBUG) << __func__ << " illegal digital gain " << gain;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
mDigitalGain = gain;
|
mDigitalGain = gain;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -219,10 +219,6 @@ AutomaticGainControl::LevelEstimator AutomaticGainControlSwContext::getLevelEsti
|
|||||||
}
|
}
|
||||||
|
|
||||||
RetCode AutomaticGainControlSwContext::setSaturationMargin(int margin) {
|
RetCode AutomaticGainControlSwContext::setSaturationMargin(int margin) {
|
||||||
if (margin < 0 || margin > AutomaticGainControlSw::kCapability.maxSaturationMarginMb) {
|
|
||||||
LOG(DEBUG) << __func__ << " illegal saturationMargin " << margin;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
mSaturationMargin = margin;
|
mSaturationMargin = margin;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class AutomaticGainControlSw final : public EffectImpl {
|
|||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const bool kStrengthSupported;
|
static const bool kStrengthSupported;
|
||||||
static const AutomaticGainControl::Capability kCapability;
|
static const Capability kCapability;
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
AutomaticGainControlSw() { LOG(DEBUG) << __func__; }
|
AutomaticGainControlSw() { LOG(DEBUG) << __func__; }
|
||||||
~AutomaticGainControlSw() {
|
~AutomaticGainControlSw() {
|
||||||
@@ -72,6 +72,7 @@ class AutomaticGainControlSw final : public EffectImpl {
|
|||||||
IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
|
IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const std::vector<Range::AutomaticGainControlRange> kRanges;
|
||||||
std::shared_ptr<AutomaticGainControlSwContext> mContext;
|
std::shared_ptr<AutomaticGainControlSwContext> mContext;
|
||||||
ndk::ScopedAStatus getParameterAutomaticGainControl(const AutomaticGainControl::Tag& tag,
|
ndk::ScopedAStatus getParameterAutomaticGainControl(const AutomaticGainControl::Tag& tag,
|
||||||
Parameter::Specific* specific);
|
Parameter::Specific* specific);
|
||||||
|
|||||||
@@ -61,9 +61,10 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
|
|||||||
namespace aidl::android::hardware::audio::effect {
|
namespace aidl::android::hardware::audio::effect {
|
||||||
|
|
||||||
const std::string BassBoostSw::kEffectName = "BassBoostSw";
|
const std::string BassBoostSw::kEffectName = "BassBoostSw";
|
||||||
const bool BassBoostSw::kStrengthSupported = true;
|
|
||||||
const BassBoost::Capability BassBoostSw::kCapability = {.maxStrengthPm = 1000,
|
const std::vector<Range::BassBoostRange> BassBoostSw::kRanges = {
|
||||||
.strengthSupported = kStrengthSupported};
|
MAKE_RANGE(BassBoost, strengthPm, 0, 1000)};
|
||||||
|
const Capability BassBoostSw::kCapability = {.range = {BassBoostSw::kRanges}};
|
||||||
const Descriptor BassBoostSw::kDescriptor = {
|
const Descriptor BassBoostSw::kDescriptor = {
|
||||||
.common = {.id = {.type = kBassBoostTypeUUID,
|
.common = {.id = {.type = kBassBoostTypeUUID,
|
||||||
.uuid = kBassBoostSwImplUUID,
|
.uuid = kBassBoostSwImplUUID,
|
||||||
@@ -73,7 +74,7 @@ const Descriptor BassBoostSw::kDescriptor = {
|
|||||||
.volume = Flags::Volume::CTRL},
|
.volume = Flags::Volume::CTRL},
|
||||||
.name = BassBoostSw::kEffectName,
|
.name = BassBoostSw::kEffectName,
|
||||||
.implementor = "The Android Open Source Project"},
|
.implementor = "The Android Open Source Project"},
|
||||||
.capability = Capability::make<Capability::bassBoost>(BassBoostSw::kCapability)};
|
.capability = BassBoostSw::kCapability};
|
||||||
|
|
||||||
ndk::ScopedAStatus BassBoostSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus BassBoostSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
||||||
@@ -87,15 +88,14 @@ ndk::ScopedAStatus BassBoostSw::setParameterSpecific(const Parameter::Specific&
|
|||||||
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
|
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
|
||||||
|
|
||||||
auto& bbParam = specific.get<Parameter::Specific::bassBoost>();
|
auto& bbParam = specific.get<Parameter::Specific::bassBoost>();
|
||||||
|
RETURN_IF(!inRange(bbParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
|
||||||
auto tag = bbParam.getTag();
|
auto tag = bbParam.getTag();
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case BassBoost::strengthPm: {
|
case BassBoost::strengthPm: {
|
||||||
RETURN_IF(!kStrengthSupported, EX_ILLEGAL_ARGUMENT, "SettingStrengthNotSupported");
|
const auto strength = bbParam.get<BassBoost::strengthPm>();
|
||||||
|
RETURN_IF(mContext->setBbStrengthPm(strength) != RetCode::SUCCESS, EX_ILLEGAL_ARGUMENT,
|
||||||
RETURN_IF(mContext->setBbStrengthPm(bbParam.get<BassBoost::strengthPm>()) !=
|
"strengthPmNotSupported");
|
||||||
RetCode::SUCCESS,
|
|
||||||
EX_ILLEGAL_ARGUMENT, "strengthPmNotSupported");
|
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@@ -173,11 +173,6 @@ IEffect::Status BassBoostSw::effectProcessImpl(float* in, float* out, int sample
|
|||||||
}
|
}
|
||||||
|
|
||||||
RetCode BassBoostSwContext::setBbStrengthPm(int strength) {
|
RetCode BassBoostSwContext::setBbStrengthPm(int strength) {
|
||||||
if (strength < 0 || strength > BassBoostSw::kCapability.maxStrengthPm) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid strength: " << strength;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to apply new strength
|
|
||||||
mStrength = strength;
|
mStrength = strength;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ class BassBoostSwContext final : public EffectContext {
|
|||||||
class BassBoostSw final : public EffectImpl {
|
class BassBoostSw final : public EffectImpl {
|
||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const bool kStrengthSupported;
|
static const Capability kCapability;
|
||||||
static const BassBoost::Capability kCapability;
|
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
BassBoostSw() { LOG(DEBUG) << __func__; }
|
BassBoostSw() { LOG(DEBUG) << __func__; }
|
||||||
~BassBoostSw() {
|
~BassBoostSw() {
|
||||||
@@ -65,6 +64,7 @@ class BassBoostSw final : public EffectImpl {
|
|||||||
IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
|
IEffect::Status effectProcessImpl(float* in, float* out, int samples) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const std::vector<Range::BassBoostRange> kRanges;
|
||||||
std::shared_ptr<BassBoostSwContext> mContext;
|
std::shared_ptr<BassBoostSwContext> mContext;
|
||||||
ndk::ScopedAStatus getParameterBassBoost(const BassBoost::Tag& tag,
|
ndk::ScopedAStatus getParameterBassBoost(const BassBoost::Tag& tag,
|
||||||
Parameter::Specific* specific);
|
Parameter::Specific* specific);
|
||||||
|
|||||||
@@ -60,17 +60,14 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
|
|||||||
namespace aidl::android::hardware::audio::effect {
|
namespace aidl::android::hardware::audio::effect {
|
||||||
|
|
||||||
const std::string DownmixSw::kEffectName = "DownmixSw";
|
const std::string DownmixSw::kEffectName = "DownmixSw";
|
||||||
const Downmix::Capability DownmixSw::kCapability;
|
|
||||||
const Descriptor DownmixSw::kDescriptor = {
|
const Descriptor DownmixSw::kDescriptor = {
|
||||||
.common = {.id = {.type = kDownmixTypeUUID,
|
.common = {
|
||||||
.uuid = kDownmixSwImplUUID,
|
.id = {.type = kDownmixTypeUUID, .uuid = kDownmixSwImplUUID, .proxy = std::nullopt},
|
||||||
.proxy = std::nullopt},
|
.flags = {.type = Flags::Type::INSERT,
|
||||||
.flags = {.type = Flags::Type::INSERT,
|
.insert = Flags::Insert::FIRST,
|
||||||
.insert = Flags::Insert::FIRST,
|
.volume = Flags::Volume::CTRL},
|
||||||
.volume = Flags::Volume::CTRL},
|
.name = kEffectName,
|
||||||
.name = kEffectName,
|
.implementor = "The Android Open Source Project"}};
|
||||||
.implementor = "The Android Open Source Project"},
|
|
||||||
.capability = Capability::make<Capability::downmix>(kCapability)};
|
|
||||||
|
|
||||||
ndk::ScopedAStatus DownmixSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus DownmixSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class DownmixSwContext final : public EffectContext {
|
|||||||
class DownmixSw final : public EffectImpl {
|
class DownmixSw final : public EffectImpl {
|
||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const Downmix::Capability kCapability;
|
static const Capability kCapability;
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
DownmixSw() { LOG(DEBUG) << __func__; }
|
DownmixSw() { LOG(DEBUG) << __func__; }
|
||||||
~DownmixSw() {
|
~DownmixSw() {
|
||||||
|
|||||||
@@ -61,8 +61,33 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
|
|||||||
namespace aidl::android::hardware::audio::effect {
|
namespace aidl::android::hardware::audio::effect {
|
||||||
|
|
||||||
const std::string DynamicsProcessingSw::kEffectName = "DynamicsProcessingSw";
|
const std::string DynamicsProcessingSw::kEffectName = "DynamicsProcessingSw";
|
||||||
const DynamicsProcessing::Capability DynamicsProcessingSw::kCapability = {.minCutOffFreq = 220,
|
const DynamicsProcessing::EqBandConfig DynamicsProcessingSw::kEqBandConfigMin =
|
||||||
.maxCutOffFreq = 20000};
|
DynamicsProcessing::EqBandConfig({.channel = 0,
|
||||||
|
.band = 0,
|
||||||
|
.enable = false,
|
||||||
|
.cutoffFrequencyHz = 220,
|
||||||
|
.gainDb = std::numeric_limits<float>::min()});
|
||||||
|
const DynamicsProcessing::EqBandConfig DynamicsProcessingSw::kEqBandConfigMax =
|
||||||
|
DynamicsProcessing::EqBandConfig({.channel = std::numeric_limits<int>::max(),
|
||||||
|
.band = std::numeric_limits<int>::max(),
|
||||||
|
.enable = true,
|
||||||
|
.cutoffFrequencyHz = 20000,
|
||||||
|
.gainDb = std::numeric_limits<float>::max()});
|
||||||
|
const Range::DynamicsProcessingRange DynamicsProcessingSw::kPreEqBandRange = {
|
||||||
|
.min = DynamicsProcessing::make<DynamicsProcessing::preEqBand>(
|
||||||
|
{DynamicsProcessingSw::kEqBandConfigMin}),
|
||||||
|
.max = DynamicsProcessing::make<DynamicsProcessing::preEqBand>(
|
||||||
|
{DynamicsProcessingSw::kEqBandConfigMax})};
|
||||||
|
const Range::DynamicsProcessingRange DynamicsProcessingSw::kPostEqBandRange = {
|
||||||
|
.min = DynamicsProcessing::make<DynamicsProcessing::postEqBand>(
|
||||||
|
{DynamicsProcessingSw::kEqBandConfigMin}),
|
||||||
|
.max = DynamicsProcessing::make<DynamicsProcessing::postEqBand>(
|
||||||
|
{DynamicsProcessingSw::kEqBandConfigMax})};
|
||||||
|
|
||||||
|
const std::vector<Range::DynamicsProcessingRange> DynamicsProcessingSw::kRanges = {
|
||||||
|
DynamicsProcessingSw::kPreEqBandRange, DynamicsProcessingSw::kPostEqBandRange};
|
||||||
|
const Capability DynamicsProcessingSw::kCapability = {.range = DynamicsProcessingSw::kRanges};
|
||||||
|
|
||||||
const Descriptor DynamicsProcessingSw::kDescriptor = {
|
const Descriptor DynamicsProcessingSw::kDescriptor = {
|
||||||
.common = {.id = {.type = kDynamicsProcessingTypeUUID,
|
.common = {.id = {.type = kDynamicsProcessingTypeUUID,
|
||||||
.uuid = kDynamicsProcessingSwImplUUID,
|
.uuid = kDynamicsProcessingSwImplUUID,
|
||||||
@@ -72,8 +97,7 @@ const Descriptor DynamicsProcessingSw::kDescriptor = {
|
|||||||
.volume = Flags::Volume::CTRL},
|
.volume = Flags::Volume::CTRL},
|
||||||
.name = DynamicsProcessingSw::kEffectName,
|
.name = DynamicsProcessingSw::kEffectName,
|
||||||
.implementor = "The Android Open Source Project"},
|
.implementor = "The Android Open Source Project"},
|
||||||
.capability = Capability::make<Capability::dynamicsProcessing>(
|
.capability = DynamicsProcessingSw::kCapability};
|
||||||
DynamicsProcessingSw::kCapability)};
|
|
||||||
|
|
||||||
ndk::ScopedAStatus DynamicsProcessingSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus DynamicsProcessingSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
||||||
@@ -341,7 +365,6 @@ RetCode DynamicsProcessingSwContext::setEqBandCfgs(
|
|||||||
LOG(WARNING) << __func__ << " skip invalid band " << cfg.toString();
|
LOG(WARNING) << __func__ << " skip invalid band " << cfg.toString();
|
||||||
ret = RetCode::ERROR_ILLEGAL_PARAMETER;
|
ret = RetCode::ERROR_ILLEGAL_PARAMETER;
|
||||||
continue;
|
continue;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
targetCfgs[cfg.channel * stage.bandCount + cfg.band] = cfg;
|
targetCfgs[cfg.channel * stage.bandCount + cfg.band] = cfg;
|
||||||
}
|
}
|
||||||
@@ -380,7 +403,6 @@ RetCode DynamicsProcessingSwContext::setMbcBandCfgs(
|
|||||||
LOG(WARNING) << __func__ << " skip invalid band " << it.toString();
|
LOG(WARNING) << __func__ << " skip invalid band " << it.toString();
|
||||||
ret = RetCode::ERROR_ILLEGAL_PARAMETER;
|
ret = RetCode::ERROR_ILLEGAL_PARAMETER;
|
||||||
continue;
|
continue;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
mMbcChBands[it.channel * bandCount + it.band] = it;
|
mMbcChBands[it.channel * bandCount + it.band] = it;
|
||||||
}
|
}
|
||||||
@@ -462,11 +484,6 @@ std::vector<DynamicsProcessing::InputGain> DynamicsProcessingSwContext::getInput
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicsProcessingSwContext::validateCutoffFrequency(float freq) {
|
|
||||||
return freq >= DynamicsProcessingSw::kCapability.minCutOffFreq &&
|
|
||||||
freq <= DynamicsProcessingSw::kCapability.maxCutOffFreq;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DynamicsProcessingSwContext::validateStageEnablement(
|
bool DynamicsProcessingSwContext::validateStageEnablement(
|
||||||
const DynamicsProcessing::StageEnablement& enablement) {
|
const DynamicsProcessing::StageEnablement& enablement) {
|
||||||
return !enablement.inUse || (enablement.inUse && enablement.bandCount > 0);
|
return !enablement.inUse || (enablement.inUse && enablement.bandCount > 0);
|
||||||
@@ -484,7 +501,7 @@ bool DynamicsProcessingSwContext::validateEqBandConfig(
|
|||||||
const std::vector<DynamicsProcessing::ChannelConfig>& channelConfig) {
|
const std::vector<DynamicsProcessing::ChannelConfig>& channelConfig) {
|
||||||
return band.channel >= 0 && band.channel < maxChannel &&
|
return band.channel >= 0 && band.channel < maxChannel &&
|
||||||
(size_t)band.channel < channelConfig.size() && channelConfig[band.channel].enable &&
|
(size_t)band.channel < channelConfig.size() && channelConfig[band.channel].enable &&
|
||||||
band.band >= 0 && band.band < maxBand && validateCutoffFrequency(band.cutoffFrequencyHz);
|
band.band >= 0 && band.band < maxBand;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicsProcessingSwContext::validateMbcBandConfig(
|
bool DynamicsProcessingSwContext::validateMbcBandConfig(
|
||||||
@@ -492,8 +509,7 @@ bool DynamicsProcessingSwContext::validateMbcBandConfig(
|
|||||||
const std::vector<DynamicsProcessing::ChannelConfig>& channelConfig) {
|
const std::vector<DynamicsProcessing::ChannelConfig>& channelConfig) {
|
||||||
return band.channel >= 0 && band.channel < maxChannel &&
|
return band.channel >= 0 && band.channel < maxChannel &&
|
||||||
(size_t)band.channel < channelConfig.size() && channelConfig[band.channel].enable &&
|
(size_t)band.channel < channelConfig.size() && channelConfig[band.channel].enable &&
|
||||||
band.band >= 0 && band.band < maxBand &&
|
band.band >= 0 && band.band < maxBand && band.attackTimeMs >= 0 &&
|
||||||
validateCutoffFrequency(band.cutoffFrequencyHz) && band.attackTimeMs >= 0 &&
|
|
||||||
band.releaseTimeMs >= 0 && band.ratio >= 0 && band.thresholdDb <= 0 &&
|
band.releaseTimeMs >= 0 && band.ratio >= 0 && band.thresholdDb <= 0 &&
|
||||||
band.kneeWidthDb <= 0 && band.noiseGateThresholdDb <= 0 && band.expanderRatio >= 0;
|
band.kneeWidthDb <= 0 && band.noiseGateThresholdDb <= 0 && band.expanderRatio >= 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,8 +86,6 @@ class DynamicsProcessingSwContext final : public EffectContext {
|
|||||||
std::vector<DynamicsProcessing::EqBandConfig> mPreEqChBands;
|
std::vector<DynamicsProcessing::EqBandConfig> mPreEqChBands;
|
||||||
std::vector<DynamicsProcessing::EqBandConfig> mPostEqChBands;
|
std::vector<DynamicsProcessing::EqBandConfig> mPostEqChBands;
|
||||||
std::vector<DynamicsProcessing::MbcBandConfig> mMbcChBands;
|
std::vector<DynamicsProcessing::MbcBandConfig> mMbcChBands;
|
||||||
|
|
||||||
bool validateCutoffFrequency(float freq);
|
|
||||||
bool validateStageEnablement(const DynamicsProcessing::StageEnablement& enablement);
|
bool validateStageEnablement(const DynamicsProcessing::StageEnablement& enablement);
|
||||||
bool validateEngineConfig(const DynamicsProcessing::EngineArchitecture& engine);
|
bool validateEngineConfig(const DynamicsProcessing::EngineArchitecture& engine);
|
||||||
bool validateEqBandConfig(const DynamicsProcessing::EqBandConfig& band, int maxChannel,
|
bool validateEqBandConfig(const DynamicsProcessing::EqBandConfig& band, int maxChannel,
|
||||||
@@ -104,7 +102,7 @@ class DynamicsProcessingSwContext final : public EffectContext {
|
|||||||
class DynamicsProcessingSw final : public EffectImpl {
|
class DynamicsProcessingSw final : public EffectImpl {
|
||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const DynamicsProcessing::Capability kCapability;
|
static const Capability kCapability;
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
DynamicsProcessingSw() { LOG(DEBUG) << __func__; }
|
DynamicsProcessingSw() { LOG(DEBUG) << __func__; }
|
||||||
~DynamicsProcessingSw() {
|
~DynamicsProcessingSw() {
|
||||||
@@ -125,6 +123,11 @@ class DynamicsProcessingSw final : public EffectImpl {
|
|||||||
std::string getEffectName() override { return kEffectName; };
|
std::string getEffectName() override { return kEffectName; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const DynamicsProcessing::EqBandConfig kEqBandConfigMin;
|
||||||
|
static const DynamicsProcessing::EqBandConfig kEqBandConfigMax;
|
||||||
|
static const Range::DynamicsProcessingRange kPreEqBandRange;
|
||||||
|
static const Range::DynamicsProcessingRange kPostEqBandRange;
|
||||||
|
static const std::vector<Range::DynamicsProcessingRange> kRanges;
|
||||||
std::shared_ptr<DynamicsProcessingSwContext> mContext;
|
std::shared_ptr<DynamicsProcessingSwContext> mContext;
|
||||||
ndk::ScopedAStatus getParameterDynamicsProcessing(const DynamicsProcessing::Tag& tag,
|
ndk::ScopedAStatus getParameterDynamicsProcessing(const DynamicsProcessing::Tag& tag,
|
||||||
Parameter::Specific* specific);
|
Parameter::Specific* specific);
|
||||||
|
|||||||
@@ -60,18 +60,20 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
|
|||||||
namespace aidl::android::hardware::audio::effect {
|
namespace aidl::android::hardware::audio::effect {
|
||||||
|
|
||||||
const std::string EnvReverbSw::kEffectName = "EnvReverbSw";
|
const std::string EnvReverbSw::kEffectName = "EnvReverbSw";
|
||||||
const EnvironmentalReverb::Capability EnvReverbSw::kCapability = {.minRoomLevelMb = -6000,
|
|
||||||
.maxRoomLevelMb = 0,
|
const std::vector<Range::EnvironmentalReverbRange> EnvReverbSw::kRanges = {
|
||||||
.minRoomHfLevelMb = -4000,
|
MAKE_RANGE(EnvironmentalReverb, roomLevelMb, -6000, 0),
|
||||||
.maxRoomHfLevelMb = 0,
|
MAKE_RANGE(EnvironmentalReverb, roomHfLevelMb, -4000, 0),
|
||||||
.maxDecayTimeMs = 7000,
|
MAKE_RANGE(EnvironmentalReverb, decayTimeMs, 0, 7000),
|
||||||
.minDecayHfRatioPm = 100,
|
MAKE_RANGE(EnvironmentalReverb, decayHfRatioPm, 100, 2000),
|
||||||
.maxDecayHfRatioPm = 2000,
|
MAKE_RANGE(EnvironmentalReverb, levelMb, -6000, 0),
|
||||||
.minLevelMb = -6000,
|
MAKE_RANGE(EnvironmentalReverb, delayMs, 0, 65),
|
||||||
.maxLevelMb = 0,
|
MAKE_RANGE(EnvironmentalReverb, diffusionPm, 0, 1000),
|
||||||
.maxDelayMs = 65,
|
MAKE_RANGE(EnvironmentalReverb, densityPm, 0, 1000)};
|
||||||
.maxDiffusionPm = 1000,
|
|
||||||
.maxDensityPm = 1000};
|
const Capability EnvReverbSw::kCapability = {
|
||||||
|
.range = Range::make<Range::environmentalReverb>(EnvReverbSw::kRanges)};
|
||||||
|
|
||||||
const Descriptor EnvReverbSw::kDescriptor = {
|
const Descriptor EnvReverbSw::kDescriptor = {
|
||||||
.common = {.id = {.type = kEnvReverbTypeUUID,
|
.common = {.id = {.type = kEnvReverbTypeUUID,
|
||||||
.uuid = kEnvReverbSwImplUUID,
|
.uuid = kEnvReverbSwImplUUID,
|
||||||
@@ -81,7 +83,7 @@ const Descriptor EnvReverbSw::kDescriptor = {
|
|||||||
.volume = Flags::Volume::CTRL},
|
.volume = Flags::Volume::CTRL},
|
||||||
.name = EnvReverbSw::kEffectName,
|
.name = EnvReverbSw::kEffectName,
|
||||||
.implementor = "The Android Open Source Project"},
|
.implementor = "The Android Open Source Project"},
|
||||||
.capability = Capability::make<Capability::environmentalReverb>(EnvReverbSw::kCapability)};
|
.capability = EnvReverbSw::kCapability};
|
||||||
|
|
||||||
ndk::ScopedAStatus EnvReverbSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus EnvReverbSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
||||||
@@ -94,8 +96,8 @@ ndk::ScopedAStatus EnvReverbSw::setParameterSpecific(const Parameter::Specific&
|
|||||||
"EffectNotSupported");
|
"EffectNotSupported");
|
||||||
|
|
||||||
auto& erParam = specific.get<Parameter::Specific::environmentalReverb>();
|
auto& erParam = specific.get<Parameter::Specific::environmentalReverb>();
|
||||||
|
RETURN_IF(!inRange(erParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
|
||||||
auto tag = erParam.getTag();
|
auto tag = erParam.getTag();
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case EnvironmentalReverb::roomLevelMb: {
|
case EnvironmentalReverb::roomLevelMb: {
|
||||||
RETURN_IF(mContext->setErRoomLevel(erParam.get<EnvironmentalReverb::roomLevelMb>()) !=
|
RETURN_IF(mContext->setErRoomLevel(erParam.get<EnvironmentalReverb::roomLevelMb>()) !=
|
||||||
@@ -262,85 +264,41 @@ IEffect::Status EnvReverbSw::effectProcessImpl(float* in, float* out, int sample
|
|||||||
}
|
}
|
||||||
|
|
||||||
RetCode EnvReverbSwContext::setErRoomLevel(int roomLevel) {
|
RetCode EnvReverbSwContext::setErRoomLevel(int roomLevel) {
|
||||||
if (roomLevel < EnvReverbSw::kCapability.minRoomLevelMb ||
|
|
||||||
roomLevel > EnvReverbSw::kCapability.maxRoomLevelMb) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid roomLevel: " << roomLevel;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to apply new room level
|
|
||||||
mRoomLevel = roomLevel;
|
mRoomLevel = roomLevel;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetCode EnvReverbSwContext::setErRoomHfLevel(int roomHfLevel) {
|
RetCode EnvReverbSwContext::setErRoomHfLevel(int roomHfLevel) {
|
||||||
if (roomHfLevel < EnvReverbSw::kCapability.minRoomHfLevelMb ||
|
|
||||||
roomHfLevel > EnvReverbSw::kCapability.maxRoomHfLevelMb) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid roomHfLevel: " << roomHfLevel;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to apply new room HF level
|
|
||||||
mRoomHfLevel = roomHfLevel;
|
mRoomHfLevel = roomHfLevel;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetCode EnvReverbSwContext::setErDecayTime(int decayTime) {
|
RetCode EnvReverbSwContext::setErDecayTime(int decayTime) {
|
||||||
if (decayTime < 0 || decayTime > EnvReverbSw::kCapability.maxDecayTimeMs) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid decayTime: " << decayTime;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to apply new decay time
|
|
||||||
mDecayTime = decayTime;
|
mDecayTime = decayTime;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetCode EnvReverbSwContext::setErDecayHfRatio(int decayHfRatio) {
|
RetCode EnvReverbSwContext::setErDecayHfRatio(int decayHfRatio) {
|
||||||
if (decayHfRatio < EnvReverbSw::kCapability.minDecayHfRatioPm ||
|
|
||||||
decayHfRatio > EnvReverbSw::kCapability.maxDecayHfRatioPm) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid decayHfRatio: " << decayHfRatio;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to apply new decay HF ratio
|
|
||||||
mDecayHfRatio = decayHfRatio;
|
mDecayHfRatio = decayHfRatio;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetCode EnvReverbSwContext::setErLevel(int level) {
|
RetCode EnvReverbSwContext::setErLevel(int level) {
|
||||||
if (level < EnvReverbSw::kCapability.minLevelMb ||
|
|
||||||
level > EnvReverbSw::kCapability.maxLevelMb) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid level: " << level;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to apply new level
|
|
||||||
mLevel = level;
|
mLevel = level;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetCode EnvReverbSwContext::setErDelay(int delay) {
|
RetCode EnvReverbSwContext::setErDelay(int delay) {
|
||||||
if (delay < 0 || delay > EnvReverbSw::kCapability.maxDelayMs) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid delay: " << delay;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to apply new delay
|
|
||||||
mDelay = delay;
|
mDelay = delay;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetCode EnvReverbSwContext::setErDiffusion(int diffusion) {
|
RetCode EnvReverbSwContext::setErDiffusion(int diffusion) {
|
||||||
if (diffusion < 0 || diffusion > EnvReverbSw::kCapability.maxDiffusionPm) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid diffusion: " << diffusion;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to apply new diffusion
|
|
||||||
mDiffusion = diffusion;
|
mDiffusion = diffusion;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetCode EnvReverbSwContext::setErDensity(int density) {
|
RetCode EnvReverbSwContext::setErDensity(int density) {
|
||||||
if (density < 0 || density > EnvReverbSw::kCapability.maxDensityPm) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid density: " << density;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to apply new density
|
|
||||||
mDensity = density;
|
mDensity = density;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class EnvReverbSwContext final : public EffectContext {
|
|||||||
class EnvReverbSw final : public EffectImpl {
|
class EnvReverbSw final : public EffectImpl {
|
||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const EnvironmentalReverb::Capability kCapability;
|
static const Capability kCapability;
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
EnvReverbSw() { LOG(DEBUG) << __func__; }
|
EnvReverbSw() { LOG(DEBUG) << __func__; }
|
||||||
~EnvReverbSw() {
|
~EnvReverbSw() {
|
||||||
@@ -100,6 +100,7 @@ class EnvReverbSw final : public EffectImpl {
|
|||||||
std::string getEffectName() override { return kEffectName; }
|
std::string getEffectName() override { return kEffectName; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const std::vector<Range::EnvironmentalReverbRange> kRanges;
|
||||||
std::shared_ptr<EnvReverbSwContext> mContext;
|
std::shared_ptr<EnvReverbSwContext> mContext;
|
||||||
ndk::ScopedAStatus getParameterEnvironmentalReverb(const EnvironmentalReverb::Tag& tag,
|
ndk::ScopedAStatus getParameterEnvironmentalReverb(const EnvironmentalReverb::Tag& tag,
|
||||||
Parameter::Specific* specific);
|
Parameter::Specific* specific);
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
|
|||||||
namespace aidl::android::hardware::audio::effect {
|
namespace aidl::android::hardware::audio::effect {
|
||||||
|
|
||||||
const std::string EqualizerSw::kEffectName = "EqualizerSw";
|
const std::string EqualizerSw::kEffectName = "EqualizerSw";
|
||||||
|
|
||||||
const std::vector<Equalizer::BandFrequency> EqualizerSw::kBandFrequency = {{0, 30000, 120000},
|
const std::vector<Equalizer::BandFrequency> EqualizerSw::kBandFrequency = {{0, 30000, 120000},
|
||||||
{1, 120001, 460000},
|
{1, 120001, 460000},
|
||||||
{2, 460001, 1800000},
|
{2, 460001, 1800000},
|
||||||
@@ -69,19 +70,34 @@ const std::vector<Equalizer::Preset> EqualizerSw::kPresets = {
|
|||||||
{0, "Normal"}, {1, "Classical"}, {2, "Dance"}, {3, "Flat"}, {4, "Folk"},
|
{0, "Normal"}, {1, "Classical"}, {2, "Dance"}, {3, "Flat"}, {4, "Folk"},
|
||||||
{5, "Heavy Metal"}, {6, "Hip Hop"}, {7, "Jazz"}, {8, "Pop"}, {9, "Rock"}};
|
{5, "Heavy Metal"}, {6, "Hip Hop"}, {7, "Jazz"}, {8, "Pop"}, {9, "Rock"}};
|
||||||
|
|
||||||
const Equalizer::Capability EqualizerSw::kEqCap = {.bandFrequencies = kBandFrequency,
|
/**
|
||||||
.presets = kPresets};
|
* Use the same min and max to build a capability represented by Range.
|
||||||
|
*/
|
||||||
|
const std::vector<Range::EqualizerRange> EqualizerSw::kRanges = {
|
||||||
|
MAKE_RANGE(Equalizer, preset, 0, EqualizerSw::kPresets.size() - 1),
|
||||||
|
MAKE_RANGE(Equalizer, bandLevels,
|
||||||
|
std::vector<Equalizer::BandLevel>{Equalizer::BandLevel(
|
||||||
|
{.index = 0, .levelMb = std::numeric_limits<int>::min()})},
|
||||||
|
std::vector<Equalizer::BandLevel>{
|
||||||
|
Equalizer::BandLevel({.index = EqualizerSwContext::kMaxBandNumber - 1,
|
||||||
|
.levelMb = std::numeric_limits<int>::max()})}),
|
||||||
|
/* capability definition */
|
||||||
|
MAKE_RANGE(Equalizer, bandFrequencies, EqualizerSw::kBandFrequency,
|
||||||
|
EqualizerSw::kBandFrequency),
|
||||||
|
MAKE_RANGE(Equalizer, presets, EqualizerSw::kPresets, EqualizerSw::kPresets),
|
||||||
|
/* centerFreqMh is get only, set invalid range min > max */
|
||||||
|
MAKE_RANGE(Equalizer, centerFreqMh, std::vector<int>({1}), std::vector<int>({0}))};
|
||||||
|
|
||||||
const Descriptor EqualizerSw::kDesc = {
|
const Capability EqualizerSw::kEqCap = {.range = EqualizerSw::kRanges};
|
||||||
.common = {.id = {.type = kEqualizerTypeUUID,
|
const Descriptor EqualizerSw::kDesc = {.common = {.id = {.type = kEqualizerTypeUUID,
|
||||||
.uuid = kEqualizerSwImplUUID,
|
.uuid = kEqualizerSwImplUUID,
|
||||||
.proxy = kEqualizerProxyUUID},
|
.proxy = kEqualizerProxyUUID},
|
||||||
.flags = {.type = Flags::Type::INSERT,
|
.flags = {.type = Flags::Type::INSERT,
|
||||||
.insert = Flags::Insert::FIRST,
|
.insert = Flags::Insert::FIRST,
|
||||||
.volume = Flags::Volume::CTRL},
|
.volume = Flags::Volume::CTRL},
|
||||||
.name = EqualizerSw::kEffectName,
|
.name = EqualizerSw::kEffectName,
|
||||||
.implementor = "The Android Open Source Project"},
|
.implementor = "The Android Open Source Project"},
|
||||||
.capability = Capability::make<Capability::equalizer>(EqualizerSw::kEqCap)};
|
.capability = EqualizerSw::kEqCap};
|
||||||
|
|
||||||
ndk::ScopedAStatus EqualizerSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus EqualizerSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDesc.toString();
|
LOG(DEBUG) << __func__ << kDesc.toString();
|
||||||
@@ -95,6 +111,7 @@ ndk::ScopedAStatus EqualizerSw::setParameterSpecific(const Parameter::Specific&
|
|||||||
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
|
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
|
||||||
|
|
||||||
auto& eqParam = specific.get<Parameter::Specific::equalizer>();
|
auto& eqParam = specific.get<Parameter::Specific::equalizer>();
|
||||||
|
RETURN_IF(!inRange(eqParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
|
||||||
auto tag = eqParam.getTag();
|
auto tag = eqParam.getTag();
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case Equalizer::preset: {
|
case Equalizer::preset: {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class EqualizerSwContext final : public EffectContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RetCode setEqPreset(const int& presetIdx) {
|
RetCode setEqPreset(const int& presetIdx) {
|
||||||
if (presetIdx < 0 || presetIdx >= NUM_OF_PRESETS) {
|
if (presetIdx < 0 || presetIdx >= kMaxPresetNumber) {
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
||||||
}
|
}
|
||||||
mPreset = presetIdx;
|
mPreset = presetIdx;
|
||||||
@@ -43,13 +43,13 @@ class EqualizerSwContext final : public EffectContext {
|
|||||||
int getEqPreset() { return mPreset; }
|
int getEqPreset() { return mPreset; }
|
||||||
|
|
||||||
RetCode setEqBandLevels(const std::vector<Equalizer::BandLevel>& bandLevels) {
|
RetCode setEqBandLevels(const std::vector<Equalizer::BandLevel>& bandLevels) {
|
||||||
if (bandLevels.size() > NUM_OF_BANDS) {
|
if (bandLevels.size() > kMaxBandNumber) {
|
||||||
LOG(ERROR) << __func__ << " return because size exceed " << NUM_OF_BANDS;
|
LOG(ERROR) << __func__ << " return because size exceed " << kMaxBandNumber;
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
||||||
}
|
}
|
||||||
RetCode ret = RetCode::SUCCESS;
|
RetCode ret = RetCode::SUCCESS;
|
||||||
for (auto& it : bandLevels) {
|
for (auto& it : bandLevels) {
|
||||||
if (it.index >= NUM_OF_BANDS || it.index < 0) {
|
if (it.index >= kMaxBandNumber || it.index < 0) {
|
||||||
LOG(ERROR) << __func__ << " index illegal, skip: " << it.index << " - "
|
LOG(ERROR) << __func__ << " index illegal, skip: " << it.index << " - "
|
||||||
<< it.levelMb;
|
<< it.levelMb;
|
||||||
ret = RetCode::ERROR_ILLEGAL_PARAMETER;
|
ret = RetCode::ERROR_ILLEGAL_PARAMETER;
|
||||||
@@ -62,7 +62,7 @@ class EqualizerSwContext final : public EffectContext {
|
|||||||
|
|
||||||
std::vector<Equalizer::BandLevel> getEqBandLevels() {
|
std::vector<Equalizer::BandLevel> getEqBandLevels() {
|
||||||
std::vector<Equalizer::BandLevel> bandLevels;
|
std::vector<Equalizer::BandLevel> bandLevels;
|
||||||
for (int i = 0; i < NUM_OF_BANDS; i++) {
|
for (int i = 0; i < kMaxBandNumber; i++) {
|
||||||
bandLevels.push_back({i, mBandLevels[i]});
|
bandLevels.push_back({i, mBandLevels[i]});
|
||||||
}
|
}
|
||||||
return bandLevels;
|
return bandLevels;
|
||||||
@@ -71,16 +71,16 @@ class EqualizerSwContext final : public EffectContext {
|
|||||||
std::vector<int> getCenterFreqs() {
|
std::vector<int> getCenterFreqs() {
|
||||||
return {std::begin(kPresetsFrequencies), std::end(kPresetsFrequencies)};
|
return {std::begin(kPresetsFrequencies), std::end(kPresetsFrequencies)};
|
||||||
}
|
}
|
||||||
|
static const int kMaxBandNumber = 5;
|
||||||
|
static const int kMaxPresetNumber = 10;
|
||||||
|
static const int kCustomPreset = -1;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int NUM_OF_BANDS = 5;
|
static constexpr std::array<uint16_t, kMaxBandNumber> kPresetsFrequencies = {60, 230, 910, 3600,
|
||||||
static const int NUM_OF_PRESETS = 10;
|
14000};
|
||||||
static const int PRESET_CUSTOM = -1;
|
|
||||||
static constexpr std::array<uint16_t, NUM_OF_BANDS> kPresetsFrequencies = {60, 230, 910, 3600,
|
|
||||||
14000};
|
|
||||||
// preset band level
|
// preset band level
|
||||||
int mPreset = PRESET_CUSTOM;
|
int mPreset = kCustomPreset;
|
||||||
int32_t mBandLevels[NUM_OF_BANDS] = {3, 0, 0, 0, 3};
|
int32_t mBandLevels[kMaxBandNumber] = {3, 0, 0, 0, 3};
|
||||||
|
|
||||||
// Add equalizer specific context for processing here
|
// Add equalizer specific context for processing here
|
||||||
};
|
};
|
||||||
@@ -88,9 +88,7 @@ class EqualizerSwContext final : public EffectContext {
|
|||||||
class EqualizerSw final : public EffectImpl {
|
class EqualizerSw final : public EffectImpl {
|
||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const std::vector<Equalizer::BandFrequency> kBandFrequency;
|
static const Capability kEqCap;
|
||||||
static const std::vector<Equalizer::Preset> kPresets;
|
|
||||||
static const Equalizer::Capability kEqCap;
|
|
||||||
static const Descriptor kDesc;
|
static const Descriptor kDesc;
|
||||||
|
|
||||||
EqualizerSw() { LOG(DEBUG) << __func__; }
|
EqualizerSw() { LOG(DEBUG) << __func__; }
|
||||||
@@ -112,6 +110,9 @@ class EqualizerSw final : public EffectImpl {
|
|||||||
std::string getEffectName() override { return kEffectName; }
|
std::string getEffectName() override { return kEffectName; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const std::vector<Equalizer::BandFrequency> kBandFrequency;
|
||||||
|
static const std::vector<Equalizer::Preset> kPresets;
|
||||||
|
static const std::vector<Range::EqualizerRange> kRanges;
|
||||||
ndk::ScopedAStatus getParameterEqualizer(const Equalizer::Tag& tag,
|
ndk::ScopedAStatus getParameterEqualizer(const Equalizer::Tag& tag,
|
||||||
Parameter::Specific* specific);
|
Parameter::Specific* specific);
|
||||||
std::shared_ptr<EqualizerSwContext> mContext;
|
std::shared_ptr<EqualizerSwContext> mContext;
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
|
|||||||
namespace aidl::android::hardware::audio::effect {
|
namespace aidl::android::hardware::audio::effect {
|
||||||
|
|
||||||
const std::string HapticGeneratorSw::kEffectName = "HapticGeneratorSw";
|
const std::string HapticGeneratorSw::kEffectName = "HapticGeneratorSw";
|
||||||
/* capabilities */
|
|
||||||
const HapticGenerator::Capability HapticGeneratorSw::kCapability;
|
|
||||||
/* Effect descriptor */
|
/* Effect descriptor */
|
||||||
const Descriptor HapticGeneratorSw::kDescriptor = {
|
const Descriptor HapticGeneratorSw::kDescriptor = {
|
||||||
.common = {.id = {.type = kHapticGeneratorTypeUUID,
|
.common = {.id = {.type = kHapticGeneratorTypeUUID,
|
||||||
@@ -71,9 +69,7 @@ const Descriptor HapticGeneratorSw::kDescriptor = {
|
|||||||
.insert = Flags::Insert::FIRST,
|
.insert = Flags::Insert::FIRST,
|
||||||
.volume = Flags::Volume::CTRL},
|
.volume = Flags::Volume::CTRL},
|
||||||
.name = HapticGeneratorSw::kEffectName,
|
.name = HapticGeneratorSw::kEffectName,
|
||||||
.implementor = "The Android Open Source Project"},
|
.implementor = "The Android Open Source Project"}};
|
||||||
.capability =
|
|
||||||
Capability::make<Capability::hapticGenerator>(HapticGeneratorSw::kCapability)};
|
|
||||||
|
|
||||||
ndk::ScopedAStatus HapticGeneratorSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus HapticGeneratorSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ class HapticGeneratorSwContext final : public EffectContext {
|
|||||||
class HapticGeneratorSw final : public EffectImpl {
|
class HapticGeneratorSw final : public EffectImpl {
|
||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const HapticGenerator::Capability kCapability;
|
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
HapticGeneratorSw() { LOG(DEBUG) << __func__; }
|
HapticGeneratorSw() { LOG(DEBUG) << __func__; }
|
||||||
~HapticGeneratorSw() {
|
~HapticGeneratorSw() {
|
||||||
|
|||||||
@@ -19,16 +19,18 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <aidl/android/hardware/audio/effect/BnEffect.h>
|
#include <aidl/android/hardware/audio/effect/BnEffect.h>
|
||||||
|
#include <aidl/android/hardware/audio/effect/Range.h>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
|
#include <system/audio_effects/aidl_effects_utils.h>
|
||||||
|
|
||||||
typedef binder_exception_t (*EffectCreateFunctor)(
|
typedef binder_exception_t (*EffectCreateFunctor)(
|
||||||
const ::aidl::android::media::audio::common::AudioUuid*,
|
const ::aidl::android::media::audio::common::AudioUuid*,
|
||||||
std::shared_ptr<aidl::android::hardware::audio::effect::IEffect>*);
|
std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>*);
|
||||||
typedef binder_exception_t (*EffectDestroyFunctor)(
|
typedef binder_exception_t (*EffectDestroyFunctor)(
|
||||||
const std::shared_ptr<aidl::android::hardware::audio::effect::IEffect>&);
|
const std::shared_ptr<::aidl::android::hardware::audio::effect::IEffect>&);
|
||||||
typedef binder_exception_t (*EffectQueryFunctor)(
|
typedef binder_exception_t (*EffectQueryFunctor)(
|
||||||
const ::aidl::android::media::audio::common::AudioUuid*,
|
const ::aidl::android::media::audio::common::AudioUuid*,
|
||||||
aidl::android::hardware::audio::effect::Descriptor*);
|
::aidl::android::hardware::audio::effect::Descriptor*);
|
||||||
|
|
||||||
struct effect_dl_interface_s {
|
struct effect_dl_interface_s {
|
||||||
EffectCreateFunctor createEffectFunc;
|
EffectCreateFunctor createEffectFunc;
|
||||||
@@ -116,6 +118,16 @@ inline std::ostream& operator<<(std::ostream& out, const RetCode& code) {
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a Range::$EffectType$Range.
|
||||||
|
* T: The $EffectType$, Visualizer for example.
|
||||||
|
* Tag: The union tag name in $EffectType$ definition, latencyMs for example.
|
||||||
|
* l: The value of Range::$EffectType$Range.min.
|
||||||
|
* r: The value of Range::$EffectType$Range.max.
|
||||||
|
*/
|
||||||
|
#define MAKE_RANGE(T, Tag, l, r) \
|
||||||
|
{ .min = T::make<T::Tag>(l), .max = T::make<T::Tag>(r) }
|
||||||
|
|
||||||
static inline bool stringToUuid(const char* str,
|
static inline bool stringToUuid(const char* str,
|
||||||
::aidl::android::media::audio::common::AudioUuid* uuid) {
|
::aidl::android::media::audio::common::AudioUuid* uuid) {
|
||||||
RETURN_VALUE_IF(!uuid || !str, false, "nullPtr");
|
RETURN_VALUE_IF(!uuid || !str, false, "nullPtr");
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ class LoudnessEnhancerSwContext final : public EffectContext {
|
|||||||
class LoudnessEnhancerSw final : public EffectImpl {
|
class LoudnessEnhancerSw final : public EffectImpl {
|
||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const LoudnessEnhancer::Capability kCapability;
|
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
LoudnessEnhancerSw() { LOG(DEBUG) << __func__; }
|
LoudnessEnhancerSw() { LOG(DEBUG) << __func__; }
|
||||||
~LoudnessEnhancerSw() {
|
~LoudnessEnhancerSw() {
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
|
|||||||
namespace aidl::android::hardware::audio::effect {
|
namespace aidl::android::hardware::audio::effect {
|
||||||
|
|
||||||
const std::string NoiseSuppressionSw::kEffectName = "NoiseSuppressionSw";
|
const std::string NoiseSuppressionSw::kEffectName = "NoiseSuppressionSw";
|
||||||
const NoiseSuppression::Capability NoiseSuppressionSw::kCapability;
|
|
||||||
const Descriptor NoiseSuppressionSw::kDescriptor = {
|
const Descriptor NoiseSuppressionSw::kDescriptor = {
|
||||||
.common = {.id = {.type = kNoiseSuppressionTypeUUID,
|
.common = {.id = {.type = kNoiseSuppressionTypeUUID,
|
||||||
.uuid = kNoiseSuppressionSwImplUUID,
|
.uuid = kNoiseSuppressionSwImplUUID,
|
||||||
@@ -69,9 +68,7 @@ const Descriptor NoiseSuppressionSw::kDescriptor = {
|
|||||||
.insert = Flags::Insert::FIRST,
|
.insert = Flags::Insert::FIRST,
|
||||||
.volume = Flags::Volume::CTRL},
|
.volume = Flags::Volume::CTRL},
|
||||||
.name = NoiseSuppressionSw::kEffectName,
|
.name = NoiseSuppressionSw::kEffectName,
|
||||||
.implementor = "The Android Open Source Project"},
|
.implementor = "The Android Open Source Project"}};
|
||||||
.capability =
|
|
||||||
Capability::make<Capability::noiseSuppression>(NoiseSuppressionSw::kCapability)};
|
|
||||||
|
|
||||||
ndk::ScopedAStatus NoiseSuppressionSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus NoiseSuppressionSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ class NoiseSuppressionSw final : public EffectImpl {
|
|||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const bool kStrengthSupported;
|
static const bool kStrengthSupported;
|
||||||
static const NoiseSuppression::Capability kCapability;
|
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
NoiseSuppressionSw() { LOG(DEBUG) << __func__; }
|
NoiseSuppressionSw() { LOG(DEBUG) << __func__; }
|
||||||
~NoiseSuppressionSw() {
|
~NoiseSuppressionSw() {
|
||||||
|
|||||||
@@ -62,12 +62,17 @@ namespace aidl::android::hardware::audio::effect {
|
|||||||
|
|
||||||
const std::string PresetReverbSw::kEffectName = "PresetReverbSw";
|
const std::string PresetReverbSw::kEffectName = "PresetReverbSw";
|
||||||
|
|
||||||
const std::vector<PresetReverb::Presets> kSupportedPresets{
|
const std::vector<PresetReverb::Presets> PresetReverbSw::kSupportedPresets{
|
||||||
ndk::enum_range<PresetReverb::Presets>().begin(),
|
ndk::enum_range<PresetReverb::Presets>().begin(),
|
||||||
ndk::enum_range<PresetReverb::Presets>().end()};
|
ndk::enum_range<PresetReverb::Presets>().end()};
|
||||||
|
|
||||||
const PresetReverb::Capability PresetReverbSw::kCapability = {.supportedPresets =
|
const std::vector<Range::PresetReverbRange> PresetReverbSw::kRanges = {
|
||||||
kSupportedPresets};
|
MAKE_RANGE(PresetReverb, supportedPresets, PresetReverbSw::kSupportedPresets,
|
||||||
|
PresetReverbSw::kSupportedPresets)};
|
||||||
|
|
||||||
|
const Capability PresetReverbSw::kCapability = {
|
||||||
|
.range = Range::make<Range::presetReverb>(PresetReverbSw::kRanges)};
|
||||||
|
|
||||||
const Descriptor PresetReverbSw::kDescriptor = {
|
const Descriptor PresetReverbSw::kDescriptor = {
|
||||||
.common = {.id = {.type = kPresetReverbTypeUUID,
|
.common = {.id = {.type = kPresetReverbTypeUUID,
|
||||||
.uuid = kPresetReverbSwImplUUID,
|
.uuid = kPresetReverbSwImplUUID,
|
||||||
@@ -77,7 +82,7 @@ const Descriptor PresetReverbSw::kDescriptor = {
|
|||||||
.volume = Flags::Volume::CTRL},
|
.volume = Flags::Volume::CTRL},
|
||||||
.name = PresetReverbSw::kEffectName,
|
.name = PresetReverbSw::kEffectName,
|
||||||
.implementor = "The Android Open Source Project"},
|
.implementor = "The Android Open Source Project"},
|
||||||
.capability = Capability::make<Capability::presetReverb>(PresetReverbSw::kCapability)};
|
.capability = PresetReverbSw::kCapability};
|
||||||
|
|
||||||
ndk::ScopedAStatus PresetReverbSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus PresetReverbSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
||||||
@@ -92,6 +97,7 @@ ndk::ScopedAStatus PresetReverbSw::setParameterSpecific(const Parameter::Specifi
|
|||||||
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
|
RETURN_IF(!mContext, EX_NULL_POINTER, "nullContext");
|
||||||
|
|
||||||
auto& prParam = specific.get<Parameter::Specific::presetReverb>();
|
auto& prParam = specific.get<Parameter::Specific::presetReverb>();
|
||||||
|
RETURN_IF(!inRange(prParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
|
||||||
auto tag = prParam.getTag();
|
auto tag = prParam.getTag();
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ class PresetReverbSwContext final : public EffectContext {
|
|||||||
class PresetReverbSw final : public EffectImpl {
|
class PresetReverbSw final : public EffectImpl {
|
||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const PresetReverb::Capability kCapability;
|
static const std::vector<PresetReverb::Presets> kSupportedPresets;
|
||||||
|
static const std::vector<Range::PresetReverbRange> kRanges;
|
||||||
|
static const Capability kCapability;
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
PresetReverbSw() { LOG(DEBUG) << __func__; }
|
PresetReverbSw() { LOG(DEBUG) << __func__; }
|
||||||
~PresetReverbSw() {
|
~PresetReverbSw() {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ using aidl::android::hardware::audio::effect::State;
|
|||||||
using aidl::android::hardware::audio::effect::VirtualizerSw;
|
using aidl::android::hardware::audio::effect::VirtualizerSw;
|
||||||
using aidl::android::media::audio::common::AudioChannelLayout;
|
using aidl::android::media::audio::common::AudioChannelLayout;
|
||||||
using aidl::android::media::audio::common::AudioDeviceDescription;
|
using aidl::android::media::audio::common::AudioDeviceDescription;
|
||||||
|
using aidl::android::media::audio::common::AudioDeviceType;
|
||||||
using aidl::android::media::audio::common::AudioUuid;
|
using aidl::android::media::audio::common::AudioUuid;
|
||||||
|
|
||||||
extern "C" binder_exception_t createEffect(const AudioUuid* in_impl_uuid,
|
extern "C" binder_exception_t createEffect(const AudioUuid* in_impl_uuid,
|
||||||
@@ -62,9 +63,20 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
|
|||||||
namespace aidl::android::hardware::audio::effect {
|
namespace aidl::android::hardware::audio::effect {
|
||||||
|
|
||||||
const std::string VirtualizerSw::kEffectName = "VirtualizerSw";
|
const std::string VirtualizerSw::kEffectName = "VirtualizerSw";
|
||||||
const bool VirtualizerSw::kStrengthSupported = true;
|
|
||||||
const Virtualizer::Capability VirtualizerSw::kCapability = {
|
const std::vector<Range::VirtualizerRange> VirtualizerSw::kRanges = {
|
||||||
.maxStrengthPm = 1000, .strengthSupported = kStrengthSupported};
|
MAKE_RANGE(Virtualizer, strengthPm, 0, 1000),
|
||||||
|
/* speakerAngle is get-only, set min > max */
|
||||||
|
MAKE_RANGE(Virtualizer, speakerAngles, {Virtualizer::ChannelAngle({.channel = 1})},
|
||||||
|
{Virtualizer::ChannelAngle({.channel = 0})}),
|
||||||
|
/* device is get-only */
|
||||||
|
MAKE_RANGE(Virtualizer, device,
|
||||||
|
AudioDeviceDescription({.type = AudioDeviceType::IN_DEFAULT}),
|
||||||
|
AudioDeviceDescription({.type = AudioDeviceType::NONE}))};
|
||||||
|
|
||||||
|
const Capability VirtualizerSw::kCapability = {
|
||||||
|
.range = Range::make<Range::virtualizer>(VirtualizerSw::kRanges)};
|
||||||
|
|
||||||
const Descriptor VirtualizerSw::kDescriptor = {
|
const Descriptor VirtualizerSw::kDescriptor = {
|
||||||
.common = {.id = {.type = kVirtualizerTypeUUID,
|
.common = {.id = {.type = kVirtualizerTypeUUID,
|
||||||
.uuid = kVirtualizerSwImplUUID,
|
.uuid = kVirtualizerSwImplUUID,
|
||||||
@@ -74,7 +86,7 @@ const Descriptor VirtualizerSw::kDescriptor = {
|
|||||||
.volume = Flags::Volume::CTRL},
|
.volume = Flags::Volume::CTRL},
|
||||||
.name = VirtualizerSw::kEffectName,
|
.name = VirtualizerSw::kEffectName,
|
||||||
.implementor = "The Android Open Source Project"},
|
.implementor = "The Android Open Source Project"},
|
||||||
.capability = Capability::make<Capability::virtualizer>(VirtualizerSw::kCapability)};
|
.capability = VirtualizerSw::kCapability};
|
||||||
|
|
||||||
ndk::ScopedAStatus VirtualizerSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus VirtualizerSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
||||||
@@ -87,12 +99,11 @@ ndk::ScopedAStatus VirtualizerSw::setParameterSpecific(const Parameter::Specific
|
|||||||
"EffectNotSupported");
|
"EffectNotSupported");
|
||||||
|
|
||||||
auto& vrParam = specific.get<Parameter::Specific::virtualizer>();
|
auto& vrParam = specific.get<Parameter::Specific::virtualizer>();
|
||||||
|
RETURN_IF(!inRange(vrParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
|
||||||
auto tag = vrParam.getTag();
|
auto tag = vrParam.getTag();
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case Virtualizer::strengthPm: {
|
case Virtualizer::strengthPm: {
|
||||||
RETURN_IF(!kStrengthSupported, EX_ILLEGAL_ARGUMENT, "SettingStrengthNotSupported");
|
|
||||||
|
|
||||||
RETURN_IF(mContext->setVrStrength(vrParam.get<Virtualizer::strengthPm>()) !=
|
RETURN_IF(mContext->setVrStrength(vrParam.get<Virtualizer::strengthPm>()) !=
|
||||||
RetCode::SUCCESS,
|
RetCode::SUCCESS,
|
||||||
EX_ILLEGAL_ARGUMENT, "setStrengthPmFailed");
|
EX_ILLEGAL_ARGUMENT, "setStrengthPmFailed");
|
||||||
@@ -213,11 +224,6 @@ IEffect::Status VirtualizerSw::effectProcessImpl(float* in, float* out, int samp
|
|||||||
}
|
}
|
||||||
|
|
||||||
RetCode VirtualizerSwContext::setVrStrength(int strength) {
|
RetCode VirtualizerSwContext::setVrStrength(int strength) {
|
||||||
if (strength < 0 || strength > VirtualizerSw::kCapability.maxStrengthPm) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid strength: " << strength;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to apply new strength
|
|
||||||
mStrength = strength;
|
mStrength = strength;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ class VirtualizerSwContext final : public EffectContext {
|
|||||||
class VirtualizerSw final : public EffectImpl {
|
class VirtualizerSw final : public EffectImpl {
|
||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const bool kStrengthSupported;
|
static const Capability kCapability;
|
||||||
static const Virtualizer::Capability kCapability;
|
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
VirtualizerSw() { LOG(DEBUG) << __func__; }
|
VirtualizerSw() { LOG(DEBUG) << __func__; }
|
||||||
~VirtualizerSw() {
|
~VirtualizerSw() {
|
||||||
@@ -73,6 +72,7 @@ class VirtualizerSw final : public EffectImpl {
|
|||||||
std::string getEffectName() override { return kEffectName; }
|
std::string getEffectName() override { return kEffectName; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const std::vector<Range::VirtualizerRange> kRanges;
|
||||||
std::shared_ptr<VirtualizerSwContext> mContext;
|
std::shared_ptr<VirtualizerSwContext> mContext;
|
||||||
|
|
||||||
ndk::ScopedAStatus getParameterVirtualizer(const Virtualizer::Tag& tag,
|
ndk::ScopedAStatus getParameterVirtualizer(const Virtualizer::Tag& tag,
|
||||||
|
|||||||
@@ -55,12 +55,15 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
|
|||||||
namespace aidl::android::hardware::audio::effect {
|
namespace aidl::android::hardware::audio::effect {
|
||||||
|
|
||||||
const std::string VisualizerSw::kEffectName = "VisualizerSw";
|
const std::string VisualizerSw::kEffectName = "VisualizerSw";
|
||||||
|
|
||||||
/* capabilities */
|
/* capabilities */
|
||||||
const Visualizer::CaptureSamplesRange VisualizerSwContext::kCaptureSamplesRange = {
|
const std::vector<Range::VisualizerRange> VisualizerSw::kRanges = {
|
||||||
VisualizerSwContext::kMinCaptureSize, VisualizerSwContext::kMaxCaptureSize};
|
MAKE_RANGE(Visualizer, latencyMs, 0, VisualizerSwContext::kMaxLatencyMs),
|
||||||
const Visualizer::Capability VisualizerSw::kCapability = {
|
MAKE_RANGE(Visualizer, captureSamples, VisualizerSwContext::kMinCaptureSize,
|
||||||
.maxLatencyMs = VisualizerSwContext::kMaxLatencyMs,
|
VisualizerSwContext::kMaxCaptureSize)};
|
||||||
.captureSampleRange = VisualizerSwContext::kCaptureSamplesRange};
|
|
||||||
|
const Capability VisualizerSw::kCapability = {
|
||||||
|
.range = Range::make<Range::visualizer>(VisualizerSw::kRanges)};
|
||||||
|
|
||||||
const Descriptor VisualizerSw::kDescriptor = {
|
const Descriptor VisualizerSw::kDescriptor = {
|
||||||
.common = {.id = {.type = kVisualizerTypeUUID,
|
.common = {.id = {.type = kVisualizerTypeUUID,
|
||||||
@@ -71,7 +74,7 @@ const Descriptor VisualizerSw::kDescriptor = {
|
|||||||
.volume = Flags::Volume::CTRL},
|
.volume = Flags::Volume::CTRL},
|
||||||
.name = VisualizerSw::kEffectName,
|
.name = VisualizerSw::kEffectName,
|
||||||
.implementor = "The Android Open Source Project"},
|
.implementor = "The Android Open Source Project"},
|
||||||
.capability = Capability::make<Capability::visualizer>(VisualizerSw::kCapability)};
|
.capability = VisualizerSw::kCapability};
|
||||||
|
|
||||||
ndk::ScopedAStatus VisualizerSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus VisualizerSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
||||||
@@ -84,34 +87,33 @@ ndk::ScopedAStatus VisualizerSw::setParameterSpecific(const Parameter::Specific&
|
|||||||
"EffectNotSupported");
|
"EffectNotSupported");
|
||||||
|
|
||||||
auto& vsParam = specific.get<Parameter::Specific::visualizer>();
|
auto& vsParam = specific.get<Parameter::Specific::visualizer>();
|
||||||
|
RETURN_IF(!inRange(vsParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
|
||||||
auto tag = vsParam.getTag();
|
auto tag = vsParam.getTag();
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case Visualizer::captureSamples: {
|
case Visualizer::captureSamples: {
|
||||||
RETURN_IF(mContext->setVsCaptureSize(vsParam.get<Visualizer::captureSamples>()) !=
|
RETURN_IF(mContext->setVsCaptureSize(vsParam.get<Visualizer::captureSamples>()) !=
|
||||||
RetCode::SUCCESS,
|
RetCode::SUCCESS,
|
||||||
EX_ILLEGAL_ARGUMENT, "captureSizeNotSupported");
|
EX_ILLEGAL_ARGUMENT, "setCaptureSizeFailed");
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
case Visualizer::scalingMode: {
|
case Visualizer::scalingMode: {
|
||||||
RETURN_IF(mContext->setVsScalingMode(vsParam.get<Visualizer::scalingMode>()) !=
|
RETURN_IF(mContext->setVsScalingMode(vsParam.get<Visualizer::scalingMode>()) !=
|
||||||
RetCode::SUCCESS,
|
RetCode::SUCCESS,
|
||||||
EX_ILLEGAL_ARGUMENT, "scalingModeNotSupported");
|
EX_ILLEGAL_ARGUMENT, "setScalingModeFailed");
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
case Visualizer::measurementMode: {
|
case Visualizer::measurementMode: {
|
||||||
RETURN_IF(mContext->setVsMeasurementMode(vsParam.get<Visualizer::measurementMode>()) !=
|
RETURN_IF(mContext->setVsMeasurementMode(vsParam.get<Visualizer::measurementMode>()) !=
|
||||||
RetCode::SUCCESS,
|
RetCode::SUCCESS,
|
||||||
EX_ILLEGAL_ARGUMENT, "measurementModeNotSupported");
|
EX_ILLEGAL_ARGUMENT, "setMeasurementModeFailed");
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
case Visualizer::setOnlyParameters: {
|
case Visualizer::latencyMs: {
|
||||||
return setSetOnlyParameterVisualizer(vsParam.get<Visualizer::setOnlyParameters>());
|
RETURN_IF(mContext->setVsLatency(vsParam.get<Visualizer::latencyMs>()) !=
|
||||||
}
|
RetCode::SUCCESS,
|
||||||
case Visualizer::getOnlyParameters: {
|
EX_ILLEGAL_ARGUMENT, "setLatencyFailed");
|
||||||
LOG(ERROR) << __func__ << " unsupported settable getOnlyParam";
|
return ndk::ScopedAStatus::ok();
|
||||||
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
|
|
||||||
EX_ILLEGAL_ARGUMENT, "SetofGetOnlyParamsNotSupported");
|
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
|
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
|
||||||
@@ -121,18 +123,6 @@ ndk::ScopedAStatus VisualizerSw::setParameterSpecific(const Parameter::Specific&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ndk::ScopedAStatus VisualizerSw::setSetOnlyParameterVisualizer(
|
|
||||||
Visualizer::SetOnlyParameters setOnlyParam) {
|
|
||||||
auto tag = setOnlyParam.getTag();
|
|
||||||
RETURN_IF(Visualizer::SetOnlyParameters::latencyMs != tag, EX_ILLEGAL_ARGUMENT,
|
|
||||||
"SetOnlyParametersTagNotSupported");
|
|
||||||
RETURN_IF(
|
|
||||||
mContext->setVsLatency(setOnlyParam.get<Visualizer::SetOnlyParameters::latencyMs>()) !=
|
|
||||||
RetCode::SUCCESS,
|
|
||||||
EX_ILLEGAL_ARGUMENT, "latencyNotSupported");
|
|
||||||
return ndk::ScopedAStatus::ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
ndk::ScopedAStatus VisualizerSw::getParameterSpecific(const Parameter::Id& id,
|
ndk::ScopedAStatus VisualizerSw::getParameterSpecific(const Parameter::Id& id,
|
||||||
Parameter::Specific* specific) {
|
Parameter::Specific* specific) {
|
||||||
auto tag = id.getTag();
|
auto tag = id.getTag();
|
||||||
@@ -142,14 +132,6 @@ ndk::ScopedAStatus VisualizerSw::getParameterSpecific(const Parameter::Id& id,
|
|||||||
switch (vsIdTag) {
|
switch (vsIdTag) {
|
||||||
case Visualizer::Id::commonTag:
|
case Visualizer::Id::commonTag:
|
||||||
return getParameterVisualizer(vsId.get<Visualizer::Id::commonTag>(), specific);
|
return getParameterVisualizer(vsId.get<Visualizer::Id::commonTag>(), specific);
|
||||||
case Visualizer::Id::getOnlyParamTag:
|
|
||||||
return getGetOnlyParameterVisualizer(vsId.get<Visualizer::Id::getOnlyParamTag>(),
|
|
||||||
specific);
|
|
||||||
case Visualizer::Id::setOnlyParamTag: {
|
|
||||||
LOG(ERROR) << __func__ << " unsupported gettable setOnlyParam";
|
|
||||||
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
|
|
||||||
EX_ILLEGAL_ARGUMENT, "GetofSetOnlyParamsNotSupported");
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
|
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
|
||||||
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
|
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
|
||||||
@@ -174,6 +156,18 @@ ndk::ScopedAStatus VisualizerSw::getParameterVisualizer(const Visualizer::Tag& t
|
|||||||
vsParam.set<Visualizer::measurementMode>(mContext->getVsMeasurementMode());
|
vsParam.set<Visualizer::measurementMode>(mContext->getVsMeasurementMode());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case Visualizer::measurement: {
|
||||||
|
vsParam.set<Visualizer::measurement>(mContext->getVsMeasurement());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Visualizer::captureSampleBuffer: {
|
||||||
|
vsParam.set<Visualizer::captureSampleBuffer>(mContext->getVsCaptureSampleBuffer());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Visualizer::latencyMs: {
|
||||||
|
vsParam.set<Visualizer::latencyMs>(mContext->getVsLatency());
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
|
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
|
||||||
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
|
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
|
||||||
@@ -184,32 +178,6 @@ ndk::ScopedAStatus VisualizerSw::getParameterVisualizer(const Visualizer::Tag& t
|
|||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
ndk::ScopedAStatus VisualizerSw::getGetOnlyParameterVisualizer(
|
|
||||||
const Visualizer::GetOnlyParameters::Tag& tag, Parameter::Specific* specific) {
|
|
||||||
Visualizer::GetOnlyParameters getOnlyParam;
|
|
||||||
switch (tag) {
|
|
||||||
case Visualizer::GetOnlyParameters::measurement: {
|
|
||||||
getOnlyParam.set<Visualizer::GetOnlyParameters::measurement>(
|
|
||||||
mContext->getVsMeasurement());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Visualizer::GetOnlyParameters::captureSampleBuffer: {
|
|
||||||
getOnlyParam.set<Visualizer::GetOnlyParameters::captureSampleBuffer>(
|
|
||||||
mContext->getVsCaptureSampleBuffer());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
LOG(ERROR) << __func__ << " unsupported tag: " << toString(tag);
|
|
||||||
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(
|
|
||||||
EX_ILLEGAL_ARGUMENT, "GetOnlyParameterTagNotSupported");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Visualizer vsParam;
|
|
||||||
vsParam.set<Visualizer::getOnlyParameters>(getOnlyParam);
|
|
||||||
specific->set<Parameter::Specific::visualizer>(vsParam);
|
|
||||||
return ndk::ScopedAStatus::ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<EffectContext> VisualizerSw::createContext(const Parameter::Common& common) {
|
std::shared_ptr<EffectContext> VisualizerSw::createContext(const Parameter::Common& common) {
|
||||||
if (mContext) {
|
if (mContext) {
|
||||||
LOG(DEBUG) << __func__ << " context already exist";
|
LOG(DEBUG) << __func__ << " context already exist";
|
||||||
@@ -242,34 +210,21 @@ IEffect::Status VisualizerSw::effectProcessImpl(float* in, float* out, int sampl
|
|||||||
}
|
}
|
||||||
|
|
||||||
RetCode VisualizerSwContext::setVsCaptureSize(int captureSize) {
|
RetCode VisualizerSwContext::setVsCaptureSize(int captureSize) {
|
||||||
if (captureSize < VisualizerSw::kCapability.captureSampleRange.min ||
|
|
||||||
captureSize > VisualizerSw::kCapability.captureSampleRange.max) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid captureSize " << captureSize;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to apply new captureSize
|
|
||||||
mCaptureSize = captureSize;
|
mCaptureSize = captureSize;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetCode VisualizerSwContext::setVsScalingMode(Visualizer::ScalingMode scalingMode) {
|
RetCode VisualizerSwContext::setVsScalingMode(Visualizer::ScalingMode scalingMode) {
|
||||||
// TODO : Add implementation to apply new scalingMode
|
|
||||||
mScalingMode = scalingMode;
|
mScalingMode = scalingMode;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetCode VisualizerSwContext::setVsMeasurementMode(Visualizer::MeasurementMode measurementMode) {
|
RetCode VisualizerSwContext::setVsMeasurementMode(Visualizer::MeasurementMode measurementMode) {
|
||||||
// TODO : Add implementation to apply new measurementMode
|
|
||||||
mMeasurementMode = measurementMode;
|
mMeasurementMode = measurementMode;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetCode VisualizerSwContext::setVsLatency(int latency) {
|
RetCode VisualizerSwContext::setVsLatency(int latency) {
|
||||||
if (latency < 0 || latency > VisualizerSw::kCapability.maxLatencyMs) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid latency " << latency;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to modify latency
|
|
||||||
mLatency = latency;
|
mLatency = latency;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ class VisualizerSwContext final : public EffectContext {
|
|||||||
static const int kMaxCaptureSize = 0x400;
|
static const int kMaxCaptureSize = 0x400;
|
||||||
static const int kMaxLatencyMs = 3000;
|
static const int kMaxLatencyMs = 3000;
|
||||||
static const int kMaxCaptureBufSize = 0xffff;
|
static const int kMaxCaptureBufSize = 0xffff;
|
||||||
static const Visualizer::CaptureSamplesRange kCaptureSamplesRange;
|
|
||||||
VisualizerSwContext(int statusDepth, const Parameter::Common& common)
|
VisualizerSwContext(int statusDepth, const Parameter::Common& common)
|
||||||
: EffectContext(statusDepth, common) {
|
: EffectContext(statusDepth, common) {
|
||||||
LOG(DEBUG) << __func__;
|
LOG(DEBUG) << __func__;
|
||||||
@@ -48,8 +47,9 @@ class VisualizerSwContext final : public EffectContext {
|
|||||||
Visualizer::MeasurementMode getVsMeasurementMode() const { return mMeasurementMode; }
|
Visualizer::MeasurementMode getVsMeasurementMode() const { return mMeasurementMode; }
|
||||||
|
|
||||||
RetCode setVsLatency(int latency);
|
RetCode setVsLatency(int latency);
|
||||||
|
int getVsLatency() const { return mLatency; }
|
||||||
|
|
||||||
Visualizer::GetOnlyParameters::Measurement getVsMeasurement() const { return mMeasurement; }
|
Visualizer::Measurement getVsMeasurement() const { return mMeasurement; }
|
||||||
std::vector<uint8_t> getVsCaptureSampleBuffer() const { return mCaptureSampleBuffer; }
|
std::vector<uint8_t> getVsCaptureSampleBuffer() const { return mCaptureSampleBuffer; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -57,14 +57,14 @@ class VisualizerSwContext final : public EffectContext {
|
|||||||
Visualizer::ScalingMode mScalingMode = Visualizer::ScalingMode::NORMALIZED;
|
Visualizer::ScalingMode mScalingMode = Visualizer::ScalingMode::NORMALIZED;
|
||||||
Visualizer::MeasurementMode mMeasurementMode = Visualizer::MeasurementMode::NONE;
|
Visualizer::MeasurementMode mMeasurementMode = Visualizer::MeasurementMode::NONE;
|
||||||
int mLatency = 0;
|
int mLatency = 0;
|
||||||
const Visualizer::GetOnlyParameters::Measurement mMeasurement = {0, 0};
|
const Visualizer::Measurement mMeasurement = {0, 0};
|
||||||
std::vector<uint8_t> mCaptureSampleBuffer;
|
std::vector<uint8_t> mCaptureSampleBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VisualizerSw final : public EffectImpl {
|
class VisualizerSw final : public EffectImpl {
|
||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const Visualizer::Capability kCapability;
|
static const Capability kCapability;
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
VisualizerSw() { LOG(DEBUG) << __func__; }
|
VisualizerSw() { LOG(DEBUG) << __func__; }
|
||||||
~VisualizerSw() {
|
~VisualizerSw() {
|
||||||
@@ -85,12 +85,9 @@ class VisualizerSw final : public EffectImpl {
|
|||||||
std::string getEffectName() override { return kEffectName; }
|
std::string getEffectName() override { return kEffectName; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const std::vector<Range::VisualizerRange> kRanges;
|
||||||
std::shared_ptr<VisualizerSwContext> mContext;
|
std::shared_ptr<VisualizerSwContext> mContext;
|
||||||
|
|
||||||
ndk::ScopedAStatus setSetOnlyParameterVisualizer(Visualizer::SetOnlyParameters setOnlyParam);
|
|
||||||
ndk::ScopedAStatus getParameterVisualizer(const Visualizer::Tag& tag,
|
ndk::ScopedAStatus getParameterVisualizer(const Visualizer::Tag& tag,
|
||||||
Parameter::Specific* specific);
|
Parameter::Specific* specific);
|
||||||
ndk::ScopedAStatus getGetOnlyParameterVisualizer(const Visualizer::GetOnlyParameters::Tag& tag,
|
|
||||||
Parameter::Specific* specific);
|
|
||||||
};
|
};
|
||||||
} // namespace aidl::android::hardware::audio::effect
|
} // namespace aidl::android::hardware::audio::effect
|
||||||
|
|||||||
@@ -60,7 +60,11 @@ extern "C" binder_exception_t queryEffect(const AudioUuid* in_impl_uuid, Descrip
|
|||||||
namespace aidl::android::hardware::audio::effect {
|
namespace aidl::android::hardware::audio::effect {
|
||||||
|
|
||||||
const std::string VolumeSw::kEffectName = "VolumeSw";
|
const std::string VolumeSw::kEffectName = "VolumeSw";
|
||||||
const Volume::Capability VolumeSw::kCapability = {.minLevelDb = -9600, .maxLevelDb = 0};
|
|
||||||
|
const std::vector<Range::VolumeRange> VolumeSw::kRanges = {MAKE_RANGE(Volume, levelDb, -9600, 0)};
|
||||||
|
|
||||||
|
const Capability VolumeSw::kCapability = {.range = Range::make<Range::volume>(VolumeSw::kRanges)};
|
||||||
|
|
||||||
const Descriptor VolumeSw::kDescriptor = {
|
const Descriptor VolumeSw::kDescriptor = {
|
||||||
.common = {.id = {.type = kVolumeTypeUUID,
|
.common = {.id = {.type = kVolumeTypeUUID,
|
||||||
.uuid = kVolumeSwImplUUID,
|
.uuid = kVolumeSwImplUUID,
|
||||||
@@ -70,7 +74,7 @@ const Descriptor VolumeSw::kDescriptor = {
|
|||||||
.volume = Flags::Volume::CTRL},
|
.volume = Flags::Volume::CTRL},
|
||||||
.name = VolumeSw::kEffectName,
|
.name = VolumeSw::kEffectName,
|
||||||
.implementor = "The Android Open Source Project"},
|
.implementor = "The Android Open Source Project"},
|
||||||
.capability = Capability::make<Capability::volume>(VolumeSw::kCapability)};
|
.capability = VolumeSw::kCapability};
|
||||||
|
|
||||||
ndk::ScopedAStatus VolumeSw::getDescriptor(Descriptor* _aidl_return) {
|
ndk::ScopedAStatus VolumeSw::getDescriptor(Descriptor* _aidl_return) {
|
||||||
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
LOG(DEBUG) << __func__ << kDescriptor.toString();
|
||||||
@@ -83,6 +87,7 @@ ndk::ScopedAStatus VolumeSw::setParameterSpecific(const Parameter::Specific& spe
|
|||||||
"EffectNotSupported");
|
"EffectNotSupported");
|
||||||
|
|
||||||
auto& volParam = specific.get<Parameter::Specific::volume>();
|
auto& volParam = specific.get<Parameter::Specific::volume>();
|
||||||
|
RETURN_IF(!inRange(volParam, kRanges), EX_ILLEGAL_ARGUMENT, "outOfRange");
|
||||||
auto tag = volParam.getTag();
|
auto tag = volParam.getTag();
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
@@ -177,11 +182,6 @@ IEffect::Status VolumeSw::effectProcessImpl(float* in, float* out, int samples)
|
|||||||
}
|
}
|
||||||
|
|
||||||
RetCode VolumeSwContext::setVolLevel(int level) {
|
RetCode VolumeSwContext::setVolLevel(int level) {
|
||||||
if (level < VolumeSw::kCapability.minLevelDb || level > VolumeSw::kCapability.maxLevelDb) {
|
|
||||||
LOG(ERROR) << __func__ << " invalid level " << level;
|
|
||||||
return RetCode::ERROR_ILLEGAL_PARAMETER;
|
|
||||||
}
|
|
||||||
// TODO : Add implementation to apply new level
|
|
||||||
mLevel = level;
|
mLevel = level;
|
||||||
return RetCode::SUCCESS;
|
return RetCode::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class VolumeSwContext final : public EffectContext {
|
|||||||
class VolumeSw final : public EffectImpl {
|
class VolumeSw final : public EffectImpl {
|
||||||
public:
|
public:
|
||||||
static const std::string kEffectName;
|
static const std::string kEffectName;
|
||||||
static const Volume::Capability kCapability;
|
static const Capability kCapability;
|
||||||
static const Descriptor kDescriptor;
|
static const Descriptor kDescriptor;
|
||||||
VolumeSw() { LOG(DEBUG) << __func__; }
|
VolumeSw() { LOG(DEBUG) << __func__; }
|
||||||
~VolumeSw() {
|
~VolumeSw() {
|
||||||
@@ -70,6 +70,7 @@ class VolumeSw final : public EffectImpl {
|
|||||||
std::string getEffectName() override { return kEffectName; }
|
std::string getEffectName() override { return kEffectName; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const std::vector<Range::VolumeRange> kRanges;
|
||||||
std::shared_ptr<VolumeSwContext> mContext;
|
std::shared_ptr<VolumeSwContext> mContext;
|
||||||
|
|
||||||
ndk::ScopedAStatus getParameterVolume(const Volume::Tag& tag, Parameter::Specific* specific);
|
ndk::ScopedAStatus getParameterVolume(const Volume::Tag& tag, Parameter::Specific* specific);
|
||||||
|
|||||||
Reference in New Issue
Block a user