Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f363ed4f authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

audio: Update default effect HAL wrapper to support V7

During this conversion, the functionality of the V7 wrapper
hasn't been tested yet. This will be done in a separate CL
that will also include required updates to the VTS tests.

Since the changes were made to the code shared with pre-V7
versions, verified that V6 HAL didn't regress.

Bug: 142480271
Test: atest VtsHalAudioEffectV6_0TargetTest
Test: m VtsHalAudioEffectV7_0TargetTest
Test: m android.hardware.audio@7.0-service.example
Change-Id: I72389c8d564596bef22b47dfdcb2e77d636ef0a3
Merged-In: I72389c8d564596bef22b47dfdcb2e77d636ef0a3
parent e1a9c8f8
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -107,12 +107,12 @@ Return<Result> Effect::setInputDevice(const DeviceAddress& device) {
}

Return<void> Effect::getConfig(getConfig_cb _hidl_cb) {
    const EffectConfig config = {{} /* inputCfg */,
    const EffectConfig config = {
            {} /* inputCfg */,
            // outputCfg
            {{} /* buffer */,
                                  48000 /* samplingRateHz */,
                                  toString(xsd::AudioChannelMask::AUDIO_CHANNEL_OUT_STEREO),
                                  toString(xsd::AudioFormat::AUDIO_FORMAT_PCM_16_BIT),
             {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);
+26 −11
Original line number Diff line number Diff line
@@ -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.
+3 −5
Original line number Diff line number Diff line
@@ -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 {
+23 −11
Original line number Diff line number Diff line
@@ -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);
}
+9 −3
Original line number Diff line number Diff line
@@ -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
Loading