audio: Update default effect HAL wrapper to support V7 am: f363ed4f96 am: 3fe3f23a47

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1530605

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I01c8ae0708fb182399021b2adb0e4f290179d963
This commit is contained in:
Mikhail Naganov 2020-12-16 21:06:47 +00:00 committed by Automerger Merge Worker
commit 423868c14f
30 changed files with 658 additions and 246 deletions

View file

@ -107,14 +107,14 @@ Return<Result> Effect::setInputDevice(const DeviceAddress& device) {
}
Return<void> Effect::getConfig(getConfig_cb _hidl_cb) {
const EffectConfig config = {{} /* inputCfg */,
// outputCfg
{{} /* buffer */,
48000 /* samplingRateHz */,
toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO),
toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT),
EffectBufferAccess::ACCESS_ACCUMULATE,
0 /* mask */}};
const EffectConfig config = {
{} /* inputCfg */,
// outputCfg
{{} /* buffer */,
{toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT), 48000 /* samplingRateHz */,
toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO)}, /* base */
EffectBufferAccess::ACCESS_ACCUMULATE,
0 /* mask */}};
_hidl_cb(Result::OK, config);
return Void();
}

View file

@ -46,23 +46,38 @@ interface IVirtualizerEffect extends IEffect {
*/
getStrength() generates (Result retval, uint16_t strength);
struct SpeakerAngle {
struct SpeakerAngles {
/** Speaker channel mask */
vec<AudioChannelMask> mask;
// all angles are expressed in degrees and
// are relative to the listener.
int16_t azimuth; // 0 is the direction the listener faces
// 180 is behind the listener
// -90 is to their left
int16_t elevation; // 0 is the horizontal plane
// +90 is above the listener, -90 is below
AudioChannelMask mask;
/**
* Horizontal speaker position angles for each channel ordered from LSb
* to MSb in the channel mask. The number of values is the number of
* channels in the channel mask.
*
* All angles are expressed in degrees and are relative to the listener.
* - 0 is the direction the listener faces;
* - 180 is behind the listener;
* - -90 is to their left.
*/
vec<int16_t> azimuth;
/**
* Vertical speaker position angles for each channel ordered from LSb
* to MSb in the channel mask. The number of values is the number of
* channels in the channel mask.
*
* All angles are expressed in degrees and are relative to the listener.
* - 0 is the horizontal plane of the listener;
* - +90 is above the listener;
* - -90 is below the listener.
*/
vec<int16_t> elevation;
};
/**
* Retrieves virtual speaker angles for the given channel mask on the
* specified device.
*/
getVirtualSpeakerAngles(vec<AudioChannelMask> mask, DeviceAddress device)
generates (Result retval, vec<SpeakerAngle> speakerAngles);
getVirtualSpeakerAngles(AudioChannelMask mask, DeviceAddress device)
generates (Result retval, SpeakerAngles speakerAngles);
/**
* Forces the virtualizer effect for the given output device.

View file

@ -271,9 +271,7 @@ enum EffectConfigParameters : int32_t {
*/
struct EffectBufferConfig {
AudioBuffer buffer;
uint32_t samplingRateHz;
AudioChannelMask channels;
AudioFormat format;
AudioConfigBase base;
EffectBufferAccess accessMode;
bitfield<EffectConfigParameters> mask;
};
@ -292,9 +290,9 @@ enum EffectFeature : int32_t {
struct EffectAuxChannelsConfig {
/** Channel mask for main channels. */
vec<AudioChannelMask> mainChannels;
AudioChannelMask mainChannels;
/** Channel mask for auxiliary channels. */
vec<AudioChannelMask> auxChannels;
AudioChannelMask auxChannels;
};
struct EffectOffloadParameter {

View file

@ -31,9 +31,7 @@ namespace CPP_VERSION {
namespace implementation {
AcousticEchoCancelerEffect::AcousticEchoCancelerEffect(effect_handle_t handle)
: mEffect(new Effect(handle)) {}
AcousticEchoCancelerEffect::~AcousticEchoCancelerEffect() {}
: mEffect(new Effect(true /*isInput*/, handle)) {}
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
Return<Result> AcousticEchoCancelerEffect::init() {
@ -58,10 +56,32 @@ Return<Result> AcousticEchoCancelerEffect::disable() {
return mEffect->disable();
}
#if MAJOR_VERSION <= 6
Return<Result> AcousticEchoCancelerEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> AcousticEchoCancelerEffect::setDevice(AudioDeviceBitfield device) {
return mEffect->setDevice(device);
}
Return<Result> AcousticEchoCancelerEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
#else
Return<Result> AcousticEchoCancelerEffect::setAudioSource(const AudioSource& source) {
return mEffect->setAudioSource(source);
}
Return<Result> AcousticEchoCancelerEffect::setDevice(const DeviceAddress& device) {
return mEffect->setDevice(device);
}
Return<Result> AcousticEchoCancelerEffect::setInputDevice(const DeviceAddress& device) {
return mEffect->setInputDevice(device);
}
#endif
Return<void> AcousticEchoCancelerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) {
return mEffect->setAndGetVolume(volumes, _hidl_cb);
@ -82,10 +102,6 @@ Return<Result> AcousticEchoCancelerEffect::setConfigReverse(
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
}
Return<Result> AcousticEchoCancelerEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
Return<void> AcousticEchoCancelerEffect::getConfig(getConfig_cb _hidl_cb) {
return mEffect->getConfig(_hidl_cb);
}
@ -108,10 +124,6 @@ Return<Result> AcousticEchoCancelerEffect::setAuxChannelsConfig(
return mEffect->setAuxChannelsConfig(config);
}
Return<Result> AcousticEchoCancelerEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> AcousticEchoCancelerEffect::offload(const EffectOffloadParameter& param) {
return mEffect->offload(param);
}

View file

@ -53,7 +53,15 @@ struct AcousticEchoCancelerEffect : public IAcousticEchoCancelerEffect {
Return<Result> reset() override;
Return<Result> enable() override;
Return<Result> disable() override;
#if MAJOR_VERSION <= 6
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> setDevice(AudioDeviceBitfield device) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
#else
Return<Result> setAudioSource(const AudioSource& source) override;
Return<Result> setDevice(const DeviceAddress& device) override;
Return<Result> setInputDevice(const DeviceAddress& device) override;
#endif
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) override;
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@ -61,14 +69,12 @@ struct AcousticEchoCancelerEffect : public IAcousticEchoCancelerEffect {
Return<Result> setConfigReverse(
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Return<void> getConfig(getConfig_cb _hidl_cb) override;
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Return<void> getSupportedAuxChannelsConfigs(
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> offload(const EffectOffloadParameter& param) override;
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@ -98,7 +104,7 @@ struct AcousticEchoCancelerEffect : public IAcousticEchoCancelerEffect {
private:
sp<Effect> mEffect;
virtual ~AcousticEchoCancelerEffect();
virtual ~AcousticEchoCancelerEffect() = default;
};
} // namespace implementation

View file

@ -105,7 +105,6 @@ cc_library_shared {
}
cc_library_shared {
enabled: false,
name: "android.hardware.audio.effect@7.0-impl",
defaults: ["android.hardware.audio.effect-impl_default"],
shared_libs: [

View file

@ -30,9 +30,7 @@ namespace CPP_VERSION {
namespace implementation {
AutomaticGainControlEffect::AutomaticGainControlEffect(effect_handle_t handle)
: mEffect(new Effect(handle)) {}
AutomaticGainControlEffect::~AutomaticGainControlEffect() {}
: mEffect(new Effect(true /*isInput*/, handle)) {}
void AutomaticGainControlEffect::propertiesFromHal(
const t_agc_settings& halProperties, IAutomaticGainControlEffect::AllProperties* properties) {
@ -71,10 +69,32 @@ Return<Result> AutomaticGainControlEffect::disable() {
return mEffect->disable();
}
#if MAJOR_VERSION <= 6
Return<Result> AutomaticGainControlEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> AutomaticGainControlEffect::setDevice(AudioDeviceBitfield device) {
return mEffect->setDevice(device);
}
Return<Result> AutomaticGainControlEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
#else
Return<Result> AutomaticGainControlEffect::setAudioSource(const AudioSource& source) {
return mEffect->setAudioSource(source);
}
Return<Result> AutomaticGainControlEffect::setDevice(const DeviceAddress& device) {
return mEffect->setDevice(device);
}
Return<Result> AutomaticGainControlEffect::setInputDevice(const DeviceAddress& device) {
return mEffect->setInputDevice(device);
}
#endif
Return<void> AutomaticGainControlEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) {
return mEffect->setAndGetVolume(volumes, _hidl_cb);
@ -95,10 +115,6 @@ Return<Result> AutomaticGainControlEffect::setConfigReverse(
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
}
Return<Result> AutomaticGainControlEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
Return<void> AutomaticGainControlEffect::getConfig(getConfig_cb _hidl_cb) {
return mEffect->getConfig(_hidl_cb);
}
@ -121,10 +137,6 @@ Return<Result> AutomaticGainControlEffect::setAuxChannelsConfig(
return mEffect->setAuxChannelsConfig(config);
}
Return<Result> AutomaticGainControlEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> AutomaticGainControlEffect::offload(const EffectOffloadParameter& param) {
return mEffect->offload(param);
}

View file

@ -55,7 +55,15 @@ struct AutomaticGainControlEffect : public IAutomaticGainControlEffect {
Return<Result> reset() override;
Return<Result> enable() override;
Return<Result> disable() override;
#if MAJOR_VERSION <= 6
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> setDevice(AudioDeviceBitfield device) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
#else
Return<Result> setAudioSource(const AudioSource& source) override;
Return<Result> setDevice(const DeviceAddress& device) override;
Return<Result> setInputDevice(const DeviceAddress& device) override;
#endif
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) override;
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@ -63,14 +71,12 @@ struct AutomaticGainControlEffect : public IAutomaticGainControlEffect {
Return<Result> setConfigReverse(
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Return<void> getConfig(getConfig_cb _hidl_cb) override;
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Return<void> getSupportedAuxChannelsConfigs(
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> offload(const EffectOffloadParameter& param) override;
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@ -107,7 +113,7 @@ struct AutomaticGainControlEffect : public IAutomaticGainControlEffect {
private:
sp<Effect> mEffect;
virtual ~AutomaticGainControlEffect();
virtual ~AutomaticGainControlEffect() = default;
void propertiesFromHal(const t_agc_settings& halProperties,
IAutomaticGainControlEffect::AllProperties* properties);

View file

@ -30,9 +30,8 @@ namespace effect {
namespace CPP_VERSION {
namespace implementation {
BassBoostEffect::BassBoostEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
BassBoostEffect::~BassBoostEffect() {}
BassBoostEffect::BassBoostEffect(effect_handle_t handle)
: mEffect(new Effect(false /*isInput*/, handle)) {}
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
Return<Result> BassBoostEffect::init() {
@ -57,10 +56,32 @@ Return<Result> BassBoostEffect::disable() {
return mEffect->disable();
}
#if MAJOR_VERSION <= 6
Return<Result> BassBoostEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> BassBoostEffect::setDevice(AudioDeviceBitfield device) {
return mEffect->setDevice(device);
}
Return<Result> BassBoostEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
#else
Return<Result> BassBoostEffect::setAudioSource(const AudioSource& source) {
return mEffect->setAudioSource(source);
}
Return<Result> BassBoostEffect::setDevice(const DeviceAddress& device) {
return mEffect->setDevice(device);
}
Return<Result> BassBoostEffect::setInputDevice(const DeviceAddress& device) {
return mEffect->setInputDevice(device);
}
#endif
Return<void> BassBoostEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) {
return mEffect->setAndGetVolume(volumes, _hidl_cb);
@ -80,10 +101,6 @@ Return<Result> BassBoostEffect::setConfigReverse(
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
}
Return<Result> BassBoostEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
Return<void> BassBoostEffect::getConfig(getConfig_cb _hidl_cb) {
return mEffect->getConfig(_hidl_cb);
}
@ -105,10 +122,6 @@ Return<Result> BassBoostEffect::setAuxChannelsConfig(const EffectAuxChannelsConf
return mEffect->setAuxChannelsConfig(config);
}
Return<Result> BassBoostEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> BassBoostEffect::offload(const EffectOffloadParameter& param) {
return mEffect->offload(param);
}

View file

@ -55,7 +55,15 @@ struct BassBoostEffect : public IBassBoostEffect {
Return<Result> reset() override;
Return<Result> enable() override;
Return<Result> disable() override;
#if MAJOR_VERSION <= 6
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> setDevice(AudioDeviceBitfield device) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
#else
Return<Result> setAudioSource(const AudioSource& source) override;
Return<Result> setDevice(const DeviceAddress& device) override;
Return<Result> setInputDevice(const DeviceAddress& device) override;
#endif
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) override;
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@ -63,14 +71,12 @@ struct BassBoostEffect : public IBassBoostEffect {
Return<Result> setConfigReverse(
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Return<void> getConfig(getConfig_cb _hidl_cb) override;
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Return<void> getSupportedAuxChannelsConfigs(
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> offload(const EffectOffloadParameter& param) override;
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@ -100,7 +106,7 @@ struct BassBoostEffect : public IBassBoostEffect {
private:
sp<Effect> mEffect;
virtual ~BassBoostEffect();
virtual ~BassBoostEffect() = default;
};
} // namespace implementation

View file

@ -30,9 +30,8 @@ namespace effect {
namespace CPP_VERSION {
namespace implementation {
DownmixEffect::DownmixEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
DownmixEffect::~DownmixEffect() {}
DownmixEffect::DownmixEffect(effect_handle_t handle)
: mEffect(new Effect(false /*isInput*/, handle)) {}
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
Return<Result> DownmixEffect::init() {
@ -57,10 +56,32 @@ Return<Result> DownmixEffect::disable() {
return mEffect->disable();
}
#if MAJOR_VERSION <= 6
Return<Result> DownmixEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> DownmixEffect::setDevice(AudioDeviceBitfield device) {
return mEffect->setDevice(device);
}
Return<Result> DownmixEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
#else
Return<Result> DownmixEffect::setAudioSource(const AudioSource& source) {
return mEffect->setAudioSource(source);
}
Return<Result> DownmixEffect::setDevice(const DeviceAddress& device) {
return mEffect->setDevice(device);
}
Return<Result> DownmixEffect::setInputDevice(const DeviceAddress& device) {
return mEffect->setInputDevice(device);
}
#endif
Return<void> DownmixEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) {
return mEffect->setAndGetVolume(volumes, _hidl_cb);
@ -80,10 +101,6 @@ Return<Result> DownmixEffect::setConfigReverse(
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
}
Return<Result> DownmixEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
Return<void> DownmixEffect::getConfig(getConfig_cb _hidl_cb) {
return mEffect->getConfig(_hidl_cb);
}
@ -105,10 +122,6 @@ Return<Result> DownmixEffect::setAuxChannelsConfig(const EffectAuxChannelsConfig
return mEffect->setAuxChannelsConfig(config);
}
Return<Result> DownmixEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> DownmixEffect::offload(const EffectOffloadParameter& param) {
return mEffect->offload(param);
}

View file

@ -53,7 +53,15 @@ struct DownmixEffect : public IDownmixEffect {
Return<Result> reset() override;
Return<Result> enable() override;
Return<Result> disable() override;
#if MAJOR_VERSION <= 6
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> setDevice(AudioDeviceBitfield device) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
#else
Return<Result> setAudioSource(const AudioSource& source) override;
Return<Result> setDevice(const DeviceAddress& device) override;
Return<Result> setInputDevice(const DeviceAddress& device) override;
#endif
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) override;
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@ -61,14 +69,12 @@ struct DownmixEffect : public IDownmixEffect {
Return<Result> setConfigReverse(
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Return<void> getConfig(getConfig_cb _hidl_cb) override;
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Return<void> getSupportedAuxChannelsConfigs(
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> offload(const EffectOffloadParameter& param) override;
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@ -97,7 +103,7 @@ struct DownmixEffect : public IDownmixEffect {
private:
sp<Effect> mEffect;
virtual ~DownmixEffect();
virtual ~DownmixEffect() = default;
};
} // namespace implementation

View file

@ -27,6 +27,7 @@
#define ATRACE_TAG ATRACE_TAG_AUDIO
#include <HidlUtils.h>
#include <android/log.h>
#include <media/EffectsFactoryApi.h>
#include <utils/Trace.h>
@ -40,7 +41,10 @@ namespace effect {
namespace CPP_VERSION {
namespace implementation {
#if MAJOR_VERSION <= 6
using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield;
#endif
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
namespace {
@ -136,9 +140,12 @@ bool ProcessThread::threadLoop() {
const char* Effect::sContextResultOfCommand = "returned status";
const char* Effect::sContextCallToCommand = "error";
const char* Effect::sContextCallFunction = sContextCallToCommand;
const char* Effect::sContextConversion = "conversion";
Effect::Effect(effect_handle_t handle)
: mHandle(handle), mEfGroup(nullptr), mStopProcessThread(false) {}
Effect::Effect(bool isInput, effect_handle_t handle)
: mIsInput(isInput), mHandle(handle), mEfGroup(nullptr), mStopProcessThread(false) {
(void)mIsInput; // prevent 'unused field' warnings in pre-V7 versions.
}
Effect::~Effect() {
ATRACE_CALL();
@ -180,7 +187,8 @@ std::unique_ptr<uint8_t[]> Effect::hidlVecToHal(const hidl_vec<T>& vec, uint32_t
return halData;
}
// static
#if MAJOR_VERSION <= 6
void Effect::effectAuxChannelsConfigFromHal(const channel_config_t& halConfig,
EffectAuxChannelsConfig* config) {
config->mainChannels = AudioChannelBitfield(halConfig.main_channels);
@ -194,7 +202,6 @@ void Effect::effectAuxChannelsConfigToHal(const EffectAuxChannelsConfig& config,
halConfig->aux_channels = static_cast<audio_channel_mask_t>(config.auxChannels);
}
// static
void Effect::effectBufferConfigFromHal(const buffer_config_t& halConfig,
EffectBufferConfig* config) {
config->buffer.id = 0;
@ -223,7 +230,56 @@ void Effect::effectBufferConfigToHal(const EffectBufferConfig& config, buffer_co
halConfig->mask = static_cast<uint8_t>(config.mask);
}
#else // MAJOR_VERSION <= 6
void Effect::effectAuxChannelsConfigFromHal(const channel_config_t& halConfig,
EffectAuxChannelsConfig* config) {
(void)HidlUtils::audioChannelMaskFromHal(halConfig.main_channels, mIsInput,
&config->mainChannels);
(void)HidlUtils::audioChannelMaskFromHal(halConfig.aux_channels, mIsInput,
&config->auxChannels);
}
// static
void Effect::effectAuxChannelsConfigToHal(const EffectAuxChannelsConfig& config,
channel_config_t* halConfig) {
(void)HidlUtils::audioChannelMaskToHal(config.mainChannels, &halConfig->main_channels);
(void)HidlUtils::audioChannelMaskToHal(config.auxChannels, &halConfig->aux_channels);
}
void Effect::effectBufferConfigFromHal(const buffer_config_t& halConfig,
EffectBufferConfig* config) {
config->buffer.id = 0;
config->buffer.frameCount = 0;
audio_config_base_t halConfigBase = {halConfig.samplingRate,
static_cast<audio_channel_mask_t>(halConfig.channels),
static_cast<audio_format_t>(halConfig.format)};
(void)HidlUtils::audioConfigBaseFromHal(halConfigBase, mIsInput, &config->base);
config->accessMode = EffectBufferAccess(halConfig.accessMode);
config->mask = static_cast<decltype(config->mask)>(halConfig.mask);
}
// static
void Effect::effectBufferConfigToHal(const EffectBufferConfig& config, buffer_config_t* halConfig) {
// Note: setting the buffers directly is considered obsolete. They need to be set
// using 'setProcessBuffers'.
halConfig->buffer.frameCount = 0;
halConfig->buffer.raw = nullptr;
audio_config_base_t halConfigBase;
(void)HidlUtils::audioConfigBaseToHal(config.base, &halConfigBase);
halConfig->samplingRate = halConfigBase.sample_rate;
halConfig->channels = halConfigBase.channel_mask;
halConfig->format = halConfigBase.format;
// Note: The framework code does not use BP.
halConfig->bufferProvider.cookie = nullptr;
halConfig->bufferProvider.getBuffer = nullptr;
halConfig->bufferProvider.releaseBuffer = nullptr;
halConfig->accessMode = static_cast<uint8_t>(config.accessMode);
halConfig->mask = static_cast<uint8_t>(config.mask);
}
#endif // MAJOR_VERSION <= 6
void Effect::effectConfigFromHal(const effect_config_t& halConfig, EffectConfig* config) {
effectBufferConfigFromHal(halConfig.inputCfg, &config->inputCfg);
effectBufferConfigFromHal(halConfig.outputCfg, &config->outputCfg);
@ -507,11 +563,65 @@ Return<Result> Effect::disable() {
return sendCommandReturningStatus(EFFECT_CMD_DISABLE, "DISABLE");
}
Return<Result> Effect::setAudioSource(
#if MAJOR_VERSION <= 6
AudioSource source
#else
const AudioSource& source
#endif
) {
audio_source_t halSource;
if (status_t status = HidlUtils::audioSourceToHal(source, &halSource); status == NO_ERROR) {
uint32_t halSourceParam = static_cast<uint32_t>(halSource);
return sendCommand(EFFECT_CMD_SET_AUDIO_SOURCE, "SET_AUDIO_SOURCE", sizeof(uint32_t),
&halSourceParam);
} else {
return analyzeStatus(__func__, "audioSourceToHal", sContextConversion, status);
}
}
#if MAJOR_VERSION <= 6
Return<Result> Effect::setDevice(AudioDeviceBitfield device) {
uint32_t halDevice = static_cast<uint32_t>(device);
return sendCommand(EFFECT_CMD_SET_DEVICE, "SET_DEVICE", sizeof(uint32_t), &halDevice);
}
Return<Result> Effect::setInputDevice(AudioDeviceBitfield device) {
uint32_t halDevice = static_cast<uint32_t>(device);
return sendCommand(EFFECT_CMD_SET_INPUT_DEVICE, "SET_INPUT_DEVICE", sizeof(uint32_t),
&halDevice);
}
#else // MAJOR_VERSION <= 6
Return<Result> Effect::setDevice(const DeviceAddress& device) {
audio_devices_t halDevice;
char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
if (status_t status = HidlUtils::deviceAddressToHal(device, &halDevice, halDeviceAddress);
status == NO_ERROR) {
uint32_t halDeviceParam = static_cast<uint32_t>(halDevice);
return sendCommand(EFFECT_CMD_SET_DEVICE, "SET_DEVICE", sizeof(uint32_t), &halDeviceParam);
} else {
return analyzeStatus(__func__, "deviceAddressToHal", sContextConversion, status);
}
}
Return<Result> Effect::setInputDevice(const DeviceAddress& device) {
audio_devices_t halDevice;
char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
if (status_t status = HidlUtils::deviceAddressToHal(device, &halDevice, halDeviceAddress);
status == NO_ERROR) {
uint32_t halDeviceParam = static_cast<uint32_t>(halDevice);
return sendCommand(EFFECT_CMD_SET_INPUT_DEVICE, "SET_INPUT_DEVICE", sizeof(uint32_t),
&halDeviceParam);
} else {
return analyzeStatus(__func__, "deviceAddressToHal", sContextConversion, status);
}
}
#endif // MAJOR_VERSION <= 6
Return<void> Effect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) {
uint32_t halDataSize;
@ -546,12 +656,6 @@ Return<Result> Effect::setConfigReverse(
inputBufferProvider, outputBufferProvider);
}
Return<Result> Effect::setInputDevice(AudioDeviceBitfield device) {
uint32_t halDevice = static_cast<uint32_t>(device);
return sendCommand(EFFECT_CMD_SET_INPUT_DEVICE, "SET_INPUT_DEVICE", sizeof(uint32_t),
&halDevice);
}
Return<void> Effect::getConfig(getConfig_cb _hidl_cb) {
getConfigImpl(EFFECT_CMD_GET_CONFIG, "GET_CONFIG", _hidl_cb);
return Void();
@ -598,12 +702,6 @@ Return<Result> Effect::setAuxChannelsConfig(const EffectAuxChannelsConfig& confi
"SET_FEATURE_CONFIG AUX_CHANNELS", halCmd.size(), &halCmd[0]);
}
Return<Result> Effect::setAudioSource(AudioSource source) {
uint32_t halSource = static_cast<uint32_t>(source);
return sendCommand(EFFECT_CMD_SET_AUDIO_SOURCE, "SET_AUDIO_SOURCE", sizeof(uint32_t),
&halSource);
}
Return<Result> Effect::offload(const EffectOffloadParameter& param) {
effect_offload_param_t halParam;
effectOffloadParamToHal(param, &halParam);

View file

@ -47,7 +47,9 @@ using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
#if MAJOR_VERSION <= 6
using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioDeviceBitfield;
#endif
using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::effect::CPP_VERSION;
@ -56,7 +58,7 @@ struct Effect : public IEffect {
using GetParameterSuccessCallback =
std::function<void(uint32_t valueSize, const void* valueData)>;
explicit Effect(effect_handle_t handle);
Effect(bool isInput, effect_handle_t handle);
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
Return<Result> init() override;
@ -66,7 +68,15 @@ struct Effect : public IEffect {
Return<Result> reset() override;
Return<Result> enable() override;
Return<Result> disable() override;
#if MAJOR_VERSION <= 6
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> setDevice(AudioDeviceBitfield device) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
#else
Return<Result> setAudioSource(const AudioSource& source) override;
Return<Result> setDevice(const DeviceAddress& device) override;
Return<Result> setInputDevice(const DeviceAddress& device) override;
#endif
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) override;
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@ -74,14 +84,12 @@ struct Effect : public IEffect {
Return<Result> setConfigReverse(
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Return<void> getConfig(getConfig_cb _hidl_cb) override;
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Return<void> getSupportedAuxChannelsConfigs(
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> offload(const EffectOffloadParameter& param) override;
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@ -104,6 +112,10 @@ struct Effect : public IEffect {
Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override;
// Utility methods for extending interfaces.
static const char* sContextConversion;
Result analyzeStatus(const char* funcName, const char* subFuncName,
const char* contextDescription, status_t status);
template <typename T>
Return<void> getIntegerParam(uint32_t paramId,
std::function<void(Result retval, T paramValue)> cb) {
@ -170,6 +182,7 @@ struct Effect : public IEffect {
static const char* sContextCallToCommand;
static const char* sContextCallFunction;
const bool mIsInput;
effect_handle_t mHandle;
sp<AudioBufferWrapper> mInBuffer;
sp<AudioBufferWrapper> mOutBuffer;
@ -186,15 +199,14 @@ struct Effect : public IEffect {
static size_t alignedSizeIn(size_t s);
template <typename T>
std::unique_ptr<uint8_t[]> hidlVecToHal(const hidl_vec<T>& vec, uint32_t* halDataSize);
static void effectAuxChannelsConfigFromHal(const channel_config_t& halConfig,
EffectAuxChannelsConfig* config);
void effectAuxChannelsConfigFromHal(const channel_config_t& halConfig,
EffectAuxChannelsConfig* config);
static void effectAuxChannelsConfigToHal(const EffectAuxChannelsConfig& config,
channel_config_t* halConfig);
static void effectBufferConfigFromHal(const buffer_config_t& halConfig,
EffectBufferConfig* config);
void effectBufferConfigFromHal(const buffer_config_t& halConfig, EffectBufferConfig* config);
static void effectBufferConfigToHal(const EffectBufferConfig& config,
buffer_config_t* halConfig);
static void effectConfigFromHal(const effect_config_t& halConfig, EffectConfig* config);
void effectConfigFromHal(const effect_config_t& halConfig, EffectConfig* config);
static void effectConfigToHal(const EffectConfig& config, effect_config_t* halConfig);
static void effectOffloadParamToHal(const EffectOffloadParameter& offload,
effect_offload_param_t* halOffload);
@ -202,8 +214,6 @@ struct Effect : public IEffect {
uint32_t valueSize, const void** valueData);
Result analyzeCommandStatus(const char* commandName, const char* context, status_t status);
Result analyzeStatus(const char* funcName, const char* subFuncName,
const char* contextDescription, status_t status);
void getConfigImpl(int commandCode, const char* commandName, GetConfigCallback cb);
Result getCurrentConfigImpl(uint32_t featureId, uint32_t configSize,
GetCurrentConfigSuccessCallback onSuccess);

View file

@ -82,7 +82,9 @@ sp<IEffect> EffectsFactory::dispatchEffectInstanceCreation(const effect_descript
} else if (memcmp(halUuid, SL_IID_VISUALIZATION, sizeof(effect_uuid_t)) == 0) {
return new VisualizerEffect(handle);
}
return new Effect(handle);
const bool isInput =
(halDescriptor.flags & EFFECT_FLAG_TYPE_PRE_PROC) == EFFECT_FLAG_TYPE_PRE_PROC;
return new Effect(isInput, handle);
}
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffectsFactory follow.

View file

@ -31,9 +31,7 @@ namespace CPP_VERSION {
namespace implementation {
EnvironmentalReverbEffect::EnvironmentalReverbEffect(effect_handle_t handle)
: mEffect(new Effect(handle)) {}
EnvironmentalReverbEffect::~EnvironmentalReverbEffect() {}
: mEffect(new Effect(false /*isInput*/, handle)) {}
void EnvironmentalReverbEffect::propertiesFromHal(
const t_reverb_settings& halProperties, IEnvironmentalReverbEffect::AllProperties* properties) {
@ -86,10 +84,32 @@ Return<Result> EnvironmentalReverbEffect::disable() {
return mEffect->disable();
}
#if MAJOR_VERSION <= 6
Return<Result> EnvironmentalReverbEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> EnvironmentalReverbEffect::setDevice(AudioDeviceBitfield device) {
return mEffect->setDevice(device);
}
Return<Result> EnvironmentalReverbEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
#else
Return<Result> EnvironmentalReverbEffect::setAudioSource(const AudioSource& source) {
return mEffect->setAudioSource(source);
}
Return<Result> EnvironmentalReverbEffect::setDevice(const DeviceAddress& device) {
return mEffect->setDevice(device);
}
Return<Result> EnvironmentalReverbEffect::setInputDevice(const DeviceAddress& device) {
return mEffect->setInputDevice(device);
}
#endif
Return<void> EnvironmentalReverbEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) {
return mEffect->setAndGetVolume(volumes, _hidl_cb);
@ -110,10 +130,6 @@ Return<Result> EnvironmentalReverbEffect::setConfigReverse(
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
}
Return<Result> EnvironmentalReverbEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
Return<void> EnvironmentalReverbEffect::getConfig(getConfig_cb _hidl_cb) {
return mEffect->getConfig(_hidl_cb);
}
@ -136,10 +152,6 @@ Return<Result> EnvironmentalReverbEffect::setAuxChannelsConfig(
return mEffect->setAuxChannelsConfig(config);
}
Return<Result> EnvironmentalReverbEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> EnvironmentalReverbEffect::offload(const EffectOffloadParameter& param) {
return mEffect->offload(param);
}

View file

@ -57,7 +57,15 @@ struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect {
Return<Result> reset() override;
Return<Result> enable() override;
Return<Result> disable() override;
#if MAJOR_VERSION <= 6
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> setDevice(AudioDeviceBitfield device) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
#else
Return<Result> setAudioSource(const AudioSource& source) override;
Return<Result> setDevice(const DeviceAddress& device) override;
Return<Result> setInputDevice(const DeviceAddress& device) override;
#endif
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) override;
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@ -65,14 +73,12 @@ struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect {
Return<Result> setConfigReverse(
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Return<void> getConfig(getConfig_cb _hidl_cb) override;
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Return<void> getSupportedAuxChannelsConfigs(
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> offload(const EffectOffloadParameter& param) override;
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@ -125,7 +131,7 @@ struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect {
private:
sp<Effect> mEffect;
virtual ~EnvironmentalReverbEffect();
virtual ~EnvironmentalReverbEffect() = default;
void propertiesFromHal(const t_reverb_settings& halProperties,
IEnvironmentalReverbEffect::AllProperties* properties);

View file

@ -31,9 +31,8 @@ namespace effect {
namespace CPP_VERSION {
namespace implementation {
EqualizerEffect::EqualizerEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
EqualizerEffect::~EqualizerEffect() {}
EqualizerEffect::EqualizerEffect(effect_handle_t handle)
: mEffect(new Effect(false /*isInput*/, handle)) {}
void EqualizerEffect::propertiesFromHal(const t_equalizer_settings& halProperties,
IEqualizerEffect::AllProperties* properties) {
@ -80,10 +79,32 @@ Return<Result> EqualizerEffect::disable() {
return mEffect->disable();
}
#if MAJOR_VERSION <= 6
Return<Result> EqualizerEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> EqualizerEffect::setDevice(AudioDeviceBitfield device) {
return mEffect->setDevice(device);
}
Return<Result> EqualizerEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
#else
Return<Result> EqualizerEffect::setAudioSource(const AudioSource& source) {
return mEffect->setAudioSource(source);
}
Return<Result> EqualizerEffect::setDevice(const DeviceAddress& device) {
return mEffect->setDevice(device);
}
Return<Result> EqualizerEffect::setInputDevice(const DeviceAddress& device) {
return mEffect->setInputDevice(device);
}
#endif
Return<void> EqualizerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) {
return mEffect->setAndGetVolume(volumes, _hidl_cb);
@ -103,10 +124,6 @@ Return<Result> EqualizerEffect::setConfigReverse(
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
}
Return<Result> EqualizerEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
Return<void> EqualizerEffect::getConfig(getConfig_cb _hidl_cb) {
return mEffect->getConfig(_hidl_cb);
}
@ -128,10 +145,6 @@ Return<Result> EqualizerEffect::setAuxChannelsConfig(const EffectAuxChannelsConf
return mEffect->setAuxChannelsConfig(config);
}
Return<Result> EqualizerEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> EqualizerEffect::offload(const EffectOffloadParameter& param) {
return mEffect->offload(param);
}

View file

@ -57,7 +57,15 @@ struct EqualizerEffect : public IEqualizerEffect {
Return<Result> reset() override;
Return<Result> enable() override;
Return<Result> disable() override;
#if MAJOR_VERSION <= 6
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> setDevice(AudioDeviceBitfield device) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
#else
Return<Result> setAudioSource(const AudioSource& source) override;
Return<Result> setDevice(const DeviceAddress& device) override;
Return<Result> setInputDevice(const DeviceAddress& device) override;
#endif
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) override;
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@ -65,14 +73,12 @@ struct EqualizerEffect : public IEqualizerEffect {
Return<Result> setConfigReverse(
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Return<void> getConfig(getConfig_cb _hidl_cb) override;
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Return<void> getSupportedAuxChannelsConfigs(
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> offload(const EffectOffloadParameter& param) override;
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@ -111,7 +117,7 @@ struct EqualizerEffect : public IEqualizerEffect {
private:
sp<Effect> mEffect;
virtual ~EqualizerEffect();
virtual ~EqualizerEffect() = default;
void propertiesFromHal(const t_equalizer_settings& halProperties,
IEqualizerEffect::AllProperties* properties);

View file

@ -33,9 +33,7 @@ namespace CPP_VERSION {
namespace implementation {
LoudnessEnhancerEffect::LoudnessEnhancerEffect(effect_handle_t handle)
: mEffect(new Effect(handle)) {}
LoudnessEnhancerEffect::~LoudnessEnhancerEffect() {}
: mEffect(new Effect(false /*isInput*/, handle)) {}
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
Return<Result> LoudnessEnhancerEffect::init() {
@ -60,10 +58,32 @@ Return<Result> LoudnessEnhancerEffect::disable() {
return mEffect->disable();
}
#if MAJOR_VERSION <= 6
Return<Result> LoudnessEnhancerEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> LoudnessEnhancerEffect::setDevice(AudioDeviceBitfield device) {
return mEffect->setDevice(device);
}
Return<Result> LoudnessEnhancerEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
#else
Return<Result> LoudnessEnhancerEffect::setAudioSource(const AudioSource& source) {
return mEffect->setAudioSource(source);
}
Return<Result> LoudnessEnhancerEffect::setDevice(const DeviceAddress& device) {
return mEffect->setDevice(device);
}
Return<Result> LoudnessEnhancerEffect::setInputDevice(const DeviceAddress& device) {
return mEffect->setInputDevice(device);
}
#endif
Return<void> LoudnessEnhancerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) {
return mEffect->setAndGetVolume(volumes, _hidl_cb);
@ -83,10 +103,6 @@ Return<Result> LoudnessEnhancerEffect::setConfigReverse(
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
}
Return<Result> LoudnessEnhancerEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
Return<void> LoudnessEnhancerEffect::getConfig(getConfig_cb _hidl_cb) {
return mEffect->getConfig(_hidl_cb);
}
@ -108,10 +124,6 @@ Return<Result> LoudnessEnhancerEffect::setAuxChannelsConfig(const EffectAuxChann
return mEffect->setAuxChannelsConfig(config);
}
Return<Result> LoudnessEnhancerEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> LoudnessEnhancerEffect::offload(const EffectOffloadParameter& param) {
return mEffect->offload(param);
}

View file

@ -53,7 +53,15 @@ struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect {
Return<Result> reset() override;
Return<Result> enable() override;
Return<Result> disable() override;
#if MAJOR_VERSION <= 6
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> setDevice(AudioDeviceBitfield device) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
#else
Return<Result> setAudioSource(const AudioSource& source) override;
Return<Result> setDevice(const DeviceAddress& device) override;
Return<Result> setInputDevice(const DeviceAddress& device) override;
#endif
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) override;
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@ -61,14 +69,12 @@ struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect {
Return<Result> setConfigReverse(
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Return<void> getConfig(getConfig_cb _hidl_cb) override;
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Return<void> getSupportedAuxChannelsConfigs(
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> offload(const EffectOffloadParameter& param) override;
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@ -98,7 +104,7 @@ struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect {
private:
sp<Effect> mEffect;
virtual ~LoudnessEnhancerEffect();
virtual ~LoudnessEnhancerEffect() = default;
};
} // namespace implementation

View file

@ -30,9 +30,7 @@ namespace CPP_VERSION {
namespace implementation {
NoiseSuppressionEffect::NoiseSuppressionEffect(effect_handle_t handle)
: mEffect(new Effect(handle)) {}
NoiseSuppressionEffect::~NoiseSuppressionEffect() {}
: mEffect(new Effect(true /*isInput*/, handle)) {}
void NoiseSuppressionEffect::propertiesFromHal(const t_ns_settings& halProperties,
INoiseSuppressionEffect::AllProperties* properties) {
@ -69,10 +67,32 @@ Return<Result> NoiseSuppressionEffect::disable() {
return mEffect->disable();
}
#if MAJOR_VERSION <= 6
Return<Result> NoiseSuppressionEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> NoiseSuppressionEffect::setDevice(AudioDeviceBitfield device) {
return mEffect->setDevice(device);
}
Return<Result> NoiseSuppressionEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
#else
Return<Result> NoiseSuppressionEffect::setAudioSource(const AudioSource& source) {
return mEffect->setAudioSource(source);
}
Return<Result> NoiseSuppressionEffect::setDevice(const DeviceAddress& device) {
return mEffect->setDevice(device);
}
Return<Result> NoiseSuppressionEffect::setInputDevice(const DeviceAddress& device) {
return mEffect->setInputDevice(device);
}
#endif
Return<void> NoiseSuppressionEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) {
return mEffect->setAndGetVolume(volumes, _hidl_cb);
@ -92,10 +112,6 @@ Return<Result> NoiseSuppressionEffect::setConfigReverse(
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
}
Return<Result> NoiseSuppressionEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
Return<void> NoiseSuppressionEffect::getConfig(getConfig_cb _hidl_cb) {
return mEffect->getConfig(_hidl_cb);
}
@ -117,10 +133,6 @@ Return<Result> NoiseSuppressionEffect::setAuxChannelsConfig(const EffectAuxChann
return mEffect->setAuxChannelsConfig(config);
}
Return<Result> NoiseSuppressionEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> NoiseSuppressionEffect::offload(const EffectOffloadParameter& param) {
return mEffect->offload(param);
}

View file

@ -55,7 +55,15 @@ struct NoiseSuppressionEffect : public INoiseSuppressionEffect {
Return<Result> reset() override;
Return<Result> enable() override;
Return<Result> disable() override;
#if MAJOR_VERSION <= 6
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> setDevice(AudioDeviceBitfield device) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
#else
Return<Result> setAudioSource(const AudioSource& source) override;
Return<Result> setDevice(const DeviceAddress& device) override;
Return<Result> setInputDevice(const DeviceAddress& device) override;
#endif
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) override;
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@ -63,14 +71,12 @@ struct NoiseSuppressionEffect : public INoiseSuppressionEffect {
Return<Result> setConfigReverse(
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Return<void> getConfig(getConfig_cb _hidl_cb) override;
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Return<void> getSupportedAuxChannelsConfigs(
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> offload(const EffectOffloadParameter& param) override;
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@ -105,7 +111,7 @@ struct NoiseSuppressionEffect : public INoiseSuppressionEffect {
private:
sp<Effect> mEffect;
virtual ~NoiseSuppressionEffect();
virtual ~NoiseSuppressionEffect() = default;
void propertiesFromHal(const t_ns_settings& halProperties,
INoiseSuppressionEffect::AllProperties* properties);

View file

@ -30,9 +30,8 @@ namespace effect {
namespace CPP_VERSION {
namespace implementation {
PresetReverbEffect::PresetReverbEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
PresetReverbEffect::~PresetReverbEffect() {}
PresetReverbEffect::PresetReverbEffect(effect_handle_t handle)
: mEffect(new Effect(false /*isInput*/, handle)) {}
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
Return<Result> PresetReverbEffect::init() {
@ -57,10 +56,32 @@ Return<Result> PresetReverbEffect::disable() {
return mEffect->disable();
}
#if MAJOR_VERSION <= 6
Return<Result> PresetReverbEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> PresetReverbEffect::setDevice(AudioDeviceBitfield device) {
return mEffect->setDevice(device);
}
Return<Result> PresetReverbEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
#else
Return<Result> PresetReverbEffect::setAudioSource(const AudioSource& source) {
return mEffect->setAudioSource(source);
}
Return<Result> PresetReverbEffect::setDevice(const DeviceAddress& device) {
return mEffect->setDevice(device);
}
Return<Result> PresetReverbEffect::setInputDevice(const DeviceAddress& device) {
return mEffect->setInputDevice(device);
}
#endif
Return<void> PresetReverbEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) {
return mEffect->setAndGetVolume(volumes, _hidl_cb);
@ -80,10 +101,6 @@ Return<Result> PresetReverbEffect::setConfigReverse(
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
}
Return<Result> PresetReverbEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
Return<void> PresetReverbEffect::getConfig(getConfig_cb _hidl_cb) {
return mEffect->getConfig(_hidl_cb);
}
@ -105,10 +122,6 @@ Return<Result> PresetReverbEffect::setAuxChannelsConfig(const EffectAuxChannelsC
return mEffect->setAuxChannelsConfig(config);
}
Return<Result> PresetReverbEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> PresetReverbEffect::offload(const EffectOffloadParameter& param) {
return mEffect->offload(param);
}

View file

@ -53,7 +53,15 @@ struct PresetReverbEffect : public IPresetReverbEffect {
Return<Result> reset() override;
Return<Result> enable() override;
Return<Result> disable() override;
#if MAJOR_VERSION <= 6
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> setDevice(AudioDeviceBitfield device) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
#else
Return<Result> setAudioSource(const AudioSource& source) override;
Return<Result> setDevice(const DeviceAddress& device) override;
Return<Result> setInputDevice(const DeviceAddress& device) override;
#endif
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) override;
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@ -61,14 +69,12 @@ struct PresetReverbEffect : public IPresetReverbEffect {
Return<Result> setConfigReverse(
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Return<void> getConfig(getConfig_cb _hidl_cb) override;
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Return<void> getSupportedAuxChannelsConfigs(
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> offload(const EffectOffloadParameter& param) override;
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@ -98,7 +104,7 @@ struct PresetReverbEffect : public IPresetReverbEffect {
private:
sp<Effect> mEffect;
virtual ~PresetReverbEffect();
virtual ~PresetReverbEffect() = default;
};
} // namespace implementation

View file

@ -19,7 +19,9 @@
#include "VirtualizerEffect.h"
#include <memory.h>
#include <stdlib.h>
#include <HidlUtils.h>
#include <android/log.h>
#include <system/audio_effects/effect_virtualizer.h>
@ -32,19 +34,10 @@ namespace effect {
namespace CPP_VERSION {
namespace implementation {
VirtualizerEffect::VirtualizerEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {}
using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
VirtualizerEffect::~VirtualizerEffect() {}
void VirtualizerEffect::speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
hidl_vec<SpeakerAngle>& speakerAngles) {
speakerAngles.resize(channelCount);
for (uint32_t i = 0; i < channelCount; ++i) {
speakerAngles[i].mask = AudioChannelBitfield(*halAngles++);
speakerAngles[i].azimuth = *halAngles++;
speakerAngles[i].elevation = *halAngles++;
}
}
VirtualizerEffect::VirtualizerEffect(effect_handle_t handle)
: mEffect(new Effect(false /*isInput*/, handle)) {}
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
Return<Result> VirtualizerEffect::init() {
@ -69,10 +62,32 @@ Return<Result> VirtualizerEffect::disable() {
return mEffect->disable();
}
#if MAJOR_VERSION <= 6
Return<Result> VirtualizerEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> VirtualizerEffect::setDevice(AudioDeviceBitfield device) {
return mEffect->setDevice(device);
}
Return<Result> VirtualizerEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
#else
Return<Result> VirtualizerEffect::setAudioSource(const AudioSource& source) {
return mEffect->setAudioSource(source);
}
Return<Result> VirtualizerEffect::setDevice(const DeviceAddress& device) {
return mEffect->setDevice(device);
}
Return<Result> VirtualizerEffect::setInputDevice(const DeviceAddress& device) {
return mEffect->setInputDevice(device);
}
#endif
Return<void> VirtualizerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) {
return mEffect->setAndGetVolume(volumes, _hidl_cb);
@ -92,10 +107,6 @@ Return<Result> VirtualizerEffect::setConfigReverse(
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
}
Return<Result> VirtualizerEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
Return<void> VirtualizerEffect::getConfig(getConfig_cb _hidl_cb) {
return mEffect->getConfig(_hidl_cb);
}
@ -117,10 +128,6 @@ Return<Result> VirtualizerEffect::setAuxChannelsConfig(const EffectAuxChannelsCo
return mEffect->setAuxChannelsConfig(config);
}
Return<Result> VirtualizerEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> VirtualizerEffect::offload(const EffectOffloadParameter& param) {
return mEffect->offload(param);
}
@ -192,43 +199,117 @@ Return<void> VirtualizerEffect::getStrength(getStrength_cb _hidl_cb) {
return mEffect->getIntegerParam(VIRTUALIZER_PARAM_STRENGTH, _hidl_cb);
}
Return<void> VirtualizerEffect::getVirtualSpeakerAngles(AudioChannelBitfield mask,
AudioDevice device,
getVirtualSpeakerAngles_cb _hidl_cb) {
uint32_t channelCount =
audio_channel_count_from_out_mask(static_cast<audio_channel_mask_t>(mask));
Return<void> VirtualizerEffect::getVirtualSpeakerAngles(
#if MAJOR_VERSION <= 6
AudioChannelBitfield mask, AudioDevice device, getVirtualSpeakerAngles_cb _hidl_cb) {
audio_channel_mask_t halChannelMask = static_cast<audio_channel_mask_t>(mask);
audio_devices_t halDeviceType = static_cast<audio_devices_t>(device);
#else
const AudioChannelMask& mask, const DeviceAddress& device,
getVirtualSpeakerAngles_cb _hidl_cb) {
audio_channel_mask_t halChannelMask;
if (status_t status = HidlUtils::audioChannelMaskToHal(mask, &halChannelMask);
status != NO_ERROR) {
_hidl_cb(mEffect->analyzeStatus(__func__, "audioChannelMaskToHal",
Effect::sContextConversion, status),
SpeakerAngles{});
return Void();
}
audio_devices_t halDeviceType;
char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
if (status_t status = HidlUtils::deviceAddressToHal(device, &halDeviceType, halDeviceAddress);
status != NO_ERROR) {
_hidl_cb(mEffect->analyzeStatus(__func__, "deviceAddressToHal", Effect::sContextConversion,
status),
SpeakerAngles{});
return Void();
}
#endif
uint32_t channelCount = audio_channel_count_from_out_mask(halChannelMask);
size_t halSpeakerAnglesSize = sizeof(int32_t) * 3 * channelCount;
uint32_t halParam[3] = {VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES,
static_cast<audio_channel_mask_t>(mask),
static_cast<audio_devices_t>(device)};
hidl_vec<SpeakerAngle> speakerAngles;
uint32_t halParam[3] = {VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES, halChannelMask,
halDeviceType};
SpeakerAngles speakerAngles;
status_t status = NO_ERROR;
Result retval = mEffect->getParameterImpl(
sizeof(halParam), halParam, halSpeakerAnglesSize,
[&](uint32_t valueSize, const void* valueData) {
if (valueSize > halSpeakerAnglesSize) {
valueSize = halSpeakerAnglesSize;
} else if (valueSize < halSpeakerAnglesSize) {
channelCount = valueSize / (sizeof(int32_t) * 3);
}
speakerAnglesFromHal(reinterpret_cast<const int32_t*>(valueData), channelCount,
speakerAngles);
});
sizeof(halParam), halParam, halSpeakerAnglesSize,
[&](uint32_t valueSize, const void* valueData) {
if (valueSize < halSpeakerAnglesSize) {
channelCount = valueSize / (sizeof(int32_t) * 3);
}
status = speakerAnglesFromHal(reinterpret_cast<const int32_t*>(valueData),
channelCount, speakerAngles);
});
if (retval == Result::OK) {
retval = mEffect->analyzeStatus(__func__, "speakerAnglesFromHal", "", status);
}
_hidl_cb(retval, speakerAngles);
return Void();
}
Return<Result> VirtualizerEffect::forceVirtualizationMode(AudioDevice device) {
return mEffect->setParam(VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE,
static_cast<audio_devices_t>(device));
}
Return<void> VirtualizerEffect::getVirtualizationMode(getVirtualizationMode_cb _hidl_cb) {
uint32_t halMode = 0;
Result retval = mEffect->getParam(VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE, halMode);
#if MAJOR_VERSION <= 6
_hidl_cb(retval, AudioDevice(halMode));
#else
DeviceAddress device;
(void)HidlUtils::deviceAddressFromHal(static_cast<audio_devices_t>(halMode), nullptr, &device);
_hidl_cb(retval, device);
#endif
return Void();
}
Return<Result> VirtualizerEffect::forceVirtualizationMode(
#if MAJOR_VERSION <= 6
AudioDevice device) {
audio_devices_t halDeviceType = static_cast<audio_devices_t>(device);
#else
const DeviceAddress& device) {
audio_devices_t halDeviceType;
char halDeviceAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
(void)HidlUtils::deviceAddressToHal(device, &halDeviceType, halDeviceAddress);
#endif
return mEffect->setParam(VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE, halDeviceType);
}
#if MAJOR_VERSION <= 6
// static
status_t VirtualizerEffect::speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
hidl_vec<SpeakerAngle>& speakerAngles) {
speakerAngles.resize(channelCount);
for (uint32_t i = 0; i < channelCount; ++i) {
speakerAngles[i].mask = AudioChannelBitfield(*halAngles++);
speakerAngles[i].azimuth = *halAngles++;
speakerAngles[i].elevation = *halAngles++;
}
return NO_ERROR;
}
#else
static int compare_channels(const void* lhs, const void* rhs) {
return *(int32_t*)lhs - *(int32_t*)rhs;
}
// static
status_t VirtualizerEffect::speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
SpeakerAngles& speakerAngles) {
speakerAngles.azimuth.resize(channelCount);
speakerAngles.elevation.resize(channelCount);
int32_t halAnglesSorted[channelCount * 3];
memcpy(halAnglesSorted, halAngles, sizeof(halAnglesSorted));
// Ensure that channels are ordered from LSb to MSb.
qsort(halAnglesSorted, channelCount, sizeof(int32_t) * 3, compare_channels);
audio_channel_mask_t halMask = AUDIO_CHANNEL_NONE;
int32_t* halAnglesPtr = halAnglesSorted;
for (uint32_t i = 0; i < channelCount; ++i) {
halMask = static_cast<audio_channel_mask_t>(halMask | *halAnglesPtr++);
speakerAngles.azimuth[i] = *halAnglesPtr++;
speakerAngles.elevation[i] = *halAnglesPtr++;
}
return HidlUtils::audioChannelMaskFromHal(halMask, false /*isInput*/, &speakerAngles.mask);
}
#endif
} // namespace implementation
} // namespace CPP_VERSION
} // namespace effect

View file

@ -39,7 +39,9 @@ using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
#if MAJOR_VERSION <= 6
using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield;
#endif
using namespace ::android::hardware::audio::common::CPP_VERSION;
using namespace ::android::hardware::audio::effect::CPP_VERSION;
@ -54,7 +56,15 @@ struct VirtualizerEffect : public IVirtualizerEffect {
Return<Result> reset() override;
Return<Result> enable() override;
Return<Result> disable() override;
#if MAJOR_VERSION <= 6
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> setDevice(AudioDeviceBitfield device) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
#else
Return<Result> setAudioSource(const AudioSource& source) override;
Return<Result> setDevice(const DeviceAddress& device) override;
Return<Result> setInputDevice(const DeviceAddress& device) override;
#endif
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) override;
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@ -62,14 +72,12 @@ struct VirtualizerEffect : public IVirtualizerEffect {
Return<Result> setConfigReverse(
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Return<void> getConfig(getConfig_cb _hidl_cb) override;
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Return<void> getSupportedAuxChannelsConfigs(
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> offload(const EffectOffloadParameter& param) override;
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@ -96,18 +104,27 @@ struct VirtualizerEffect : public IVirtualizerEffect {
Return<bool> isStrengthSupported() override;
Return<Result> setStrength(uint16_t strength) override;
Return<void> getStrength(getStrength_cb _hidl_cb) override;
Return<void> getVirtualizationMode(getVirtualizationMode_cb _hidl_cb) override;
#if MAJOR_VERSION <= 6
Return<void> getVirtualSpeakerAngles(AudioChannelBitfield mask, AudioDevice device,
getVirtualSpeakerAngles_cb _hidl_cb) override;
Return<Result> forceVirtualizationMode(AudioDevice device) override;
Return<void> getVirtualizationMode(getVirtualizationMode_cb _hidl_cb) override;
#else
Return<void> getVirtualSpeakerAngles(const AudioChannelMask& mask, const DeviceAddress& device,
getVirtualSpeakerAngles_cb _hidl_cb) override;
Return<Result> forceVirtualizationMode(const DeviceAddress& device) override;
#endif
private:
private:
sp<Effect> mEffect;
virtual ~VirtualizerEffect();
virtual ~VirtualizerEffect() = default;
void speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
hidl_vec<SpeakerAngle>& speakerAngles);
#if MAJOR_VERSION <= 6
using SpeakerAngles = hidl_vec<SpeakerAngle>;
#endif
static status_t speakerAnglesFromHal(const int32_t* halAngles, uint32_t channelCount,
SpeakerAngles& speakerAngles);
};
} // namespace implementation

View file

@ -31,9 +31,9 @@ namespace CPP_VERSION {
namespace implementation {
VisualizerEffect::VisualizerEffect(effect_handle_t handle)
: mEffect(new Effect(handle)), mCaptureSize(0), mMeasurementMode(MeasurementMode::NONE) {}
VisualizerEffect::~VisualizerEffect() {}
: mEffect(new Effect(false /*isInput*/, handle)),
mCaptureSize(0),
mMeasurementMode(MeasurementMode::NONE) {}
// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow.
Return<Result> VisualizerEffect::init() {
@ -58,10 +58,32 @@ Return<Result> VisualizerEffect::disable() {
return mEffect->disable();
}
#if MAJOR_VERSION <= 6
Return<Result> VisualizerEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> VisualizerEffect::setDevice(AudioDeviceBitfield device) {
return mEffect->setDevice(device);
}
Return<Result> VisualizerEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
#else
Return<Result> VisualizerEffect::setAudioSource(const AudioSource& source) {
return mEffect->setAudioSource(source);
}
Return<Result> VisualizerEffect::setDevice(const DeviceAddress& device) {
return mEffect->setDevice(device);
}
Return<Result> VisualizerEffect::setInputDevice(const DeviceAddress& device) {
return mEffect->setInputDevice(device);
}
#endif
Return<void> VisualizerEffect::setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) {
return mEffect->setAndGetVolume(volumes, _hidl_cb);
@ -81,10 +103,6 @@ Return<Result> VisualizerEffect::setConfigReverse(
return mEffect->setConfigReverse(config, inputBufferProvider, outputBufferProvider);
}
Return<Result> VisualizerEffect::setInputDevice(AudioDeviceBitfield device) {
return mEffect->setInputDevice(device);
}
Return<void> VisualizerEffect::getConfig(getConfig_cb _hidl_cb) {
return mEffect->getConfig(_hidl_cb);
}
@ -106,10 +124,6 @@ Return<Result> VisualizerEffect::setAuxChannelsConfig(const EffectAuxChannelsCon
return mEffect->setAuxChannelsConfig(config);
}
Return<Result> VisualizerEffect::setAudioSource(AudioSource source) {
return mEffect->setAudioSource(source);
}
Return<Result> VisualizerEffect::offload(const EffectOffloadParameter& param) {
return mEffect->offload(param);
}

View file

@ -53,7 +53,15 @@ struct VisualizerEffect : public IVisualizerEffect {
Return<Result> reset() override;
Return<Result> enable() override;
Return<Result> disable() override;
#if MAJOR_VERSION <= 6
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> setDevice(AudioDeviceBitfield device) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
#else
Return<Result> setAudioSource(const AudioSource& source) override;
Return<Result> setDevice(const DeviceAddress& device) override;
Return<Result> setInputDevice(const DeviceAddress& device) override;
#endif
Return<void> setAndGetVolume(const hidl_vec<uint32_t>& volumes,
setAndGetVolume_cb _hidl_cb) override;
Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override;
@ -61,14 +69,12 @@ struct VisualizerEffect : public IVisualizerEffect {
Return<Result> setConfigReverse(
const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider,
const sp<IEffectBufferProviderCallback>& outputBufferProvider) override;
Return<Result> setInputDevice(AudioDeviceBitfield device) override;
Return<void> getConfig(getConfig_cb _hidl_cb) override;
Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override;
Return<void> getSupportedAuxChannelsConfigs(
uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override;
Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override;
Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override;
Return<Result> setAudioSource(AudioSource source) override;
Return<Result> offload(const EffectOffloadParameter& param) override;
Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override;
Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override;
@ -107,7 +113,7 @@ struct VisualizerEffect : public IVisualizerEffect {
uint16_t mCaptureSize;
MeasurementMode mMeasurementMode;
virtual ~VisualizerEffect();
virtual ~VisualizerEffect() = default;
};
} // namespace implementation

View file

@ -263,7 +263,7 @@ void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) {
static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels));
#else
*channelCount = android::audio::policy::configuration::V7_0::getChannelCount(
currentConfig.outputCfg.channels);
currentConfig.outputCfg.base.channelMask);
ASSERT_NE(*channelCount, 0);
#endif
}
@ -353,8 +353,14 @@ inline bool operator==(const AudioBuffer& lhs, const AudioBuffer& rhs) {
}
inline bool operator==(const EffectBufferConfig& lhs, const EffectBufferConfig& rhs) {
return lhs.buffer == rhs.buffer && lhs.samplingRateHz == rhs.samplingRateHz &&
lhs.channels == rhs.channels && lhs.format == rhs.format &&
return lhs.buffer == rhs.buffer &&
#if MAJOR_VERSION <= 6
lhs.samplingRateHz == rhs.samplingRateHz && lhs.channels == rhs.channels &&
lhs.format == rhs.format &&
#else
lhs.base.sampleRateHz == rhs.base.sampleRateHz &&
lhs.base.channelMask == rhs.base.channelMask && lhs.base.format == rhs.base.format &&
#endif
lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask;
}