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

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

audio: Add effect attachment to devices and streams

Add the following methods:
  - IModule.{add|remove}DeviceEffect;
  - IStream.{add|remove}Effect.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I4066e2d10a8e08d634010cfe9eb8f832157e725f
parent 383cd427
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ aidl_interface {
        "android.hardware.common-V2",
        "android.hardware.common.fmq-V1",
        "android.hardware.audio.common-V1",
        "android.hardware.audio.effect-V1",
        "android.media.audio.common.types-V2",
    ],
    backend: {
+2 −0
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ interface IModule {
  int generateHwAvSyncId();
  android.hardware.audio.core.VendorParameter[] getVendorParameters(in @utf8InCpp String[] ids);
  void setVendorParameters(in android.hardware.audio.core.VendorParameter[] parameters, boolean async);
  void addDeviceEffect(int portConfigId, in android.hardware.audio.effect.IEffect effect);
  void removeDeviceEffect(int portConfigId, in android.hardware.audio.effect.IEffect effect);
  @VintfStability
  parcelable OpenInputStreamArguments {
    int portConfigId;
+2 −0
Original line number Diff line number Diff line
@@ -38,4 +38,6 @@ interface IStreamCommon {
  void updateHwAvSyncId(int hwAvSyncId);
  android.hardware.audio.core.VendorParameter[] getVendorParameters(in @utf8InCpp String[] ids);
  void setVendorParameters(in android.hardware.audio.core.VendorParameter[] parameters, boolean async);
  void addEffect(in android.hardware.audio.effect.IEffect effect);
  void removeEffect(in android.hardware.audio.effect.IEffect effect);
}
+33 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.hardware.audio.core.MicrophoneInfo;
import android.hardware.audio.core.ModuleDebug;
import android.hardware.audio.core.StreamDescriptor;
import android.hardware.audio.core.VendorParameter;
import android.hardware.audio.effect.IEffect;
import android.media.audio.common.AudioOffloadInfo;
import android.media.audio.common.AudioPort;
import android.media.audio.common.AudioPortConfig;
@@ -515,7 +516,8 @@ interface IModule {
     * @throws EX_ILLEGAL_ARGUMENT If the port config can not be found by the ID.
     * @throws EX_ILLEGAL_STATE In the following cases:
     *                          - If the port config has a stream opened on it;
     *                          - If the port config is used by a patch.
     *                          - If the port config is used by a patch;
     *                          - If the port config has an audio effect on it.
     */
    void resetAudioPortConfig(int portConfigId);

@@ -728,4 +730,34 @@ interface IModule {
     * @throws EX_UNSUPPORTED_OPERATION If the module does not support vendor parameters.
     */
    void setVendorParameters(in VendorParameter[] parameters, boolean async);

    /**
     * Apply an audio effect to a device port.
     *
     * The audio effect applies to all audio input or output on the specific
     * configuration of the device audio port. The effect is inserted according
     * to its insertion preference specified by the 'flags.insert' field of the
     * EffectDescriptor.
     *
     * @param portConfigId The ID of the audio port config.
     * @param effect The effect instance.
     * @throws EX_ILLEGAL_ARGUMENT If the device port config can not be found by the ID,
     *                             or the effect reference is invalid.
     * @throws EX_UNSUPPORTED_OPERATION If the module does not support device port effects.
     */
    void addDeviceEffect(int portConfigId, in IEffect effect);

    /**
     * Stop applying an audio effect to a device port.
     *
     * Undo the action of the 'addDeviceEffect' method.
     *
     * @param portConfigId The ID of the audio port config.
     * @param effect The effect instance.
     * @throws EX_ILLEGAL_ARGUMENT If the device port config can not be found by the ID,
     *                             or the effect reference is invalid, or the effect is
     *                             not currently applied to the port config.
     * @throws EX_UNSUPPORTED_OPERATION If the module does not support device port effects.
     */
    void removeDeviceEffect(int portConfigId, in IEffect effect);
}
+27 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.hardware.audio.core;

import android.hardware.audio.core.VendorParameter;
import android.hardware.audio.effect.IEffect;

/**
 * This interface contains operations that are common to input and output
@@ -86,4 +87,30 @@ interface IStreamCommon {
     * @throws EX_UNSUPPORTED_OPERATION If the stream does not support vendor parameters.
     */
    void setVendorParameters(in VendorParameter[] parameters, boolean async);

    /**
     * Apply an audio effect to the stream.
     *
     * This method is intended for the cases when the effect has an offload
     * implementation, since software effects can be applied at the client side.
     *
     * @param effect The effect instance.
     * @throws EX_ILLEGAL_ARGUMENT If the effect reference is invalid.
     * @throws EX_ILLEGAL_STATE If the stream is closed.
     * @throws EX_UNSUPPORTED_OPERATION If the module does not support audio effects.
     */
    void addEffect(in IEffect effect);

    /**
     * Stop applying an audio effect to the stream.
     *
     * Undo the action of the 'addEffect' method.
     *
     * @param effect The effect instance.
     * @throws EX_ILLEGAL_ARGUMENT If the effect reference is invalid, or the effect is
     *                             not currently applied to the stream.
     * @throws EX_ILLEGAL_STATE If the stream is closed.
     * @throws EX_UNSUPPORTED_OPERATION If the module does not support audio effects.
     */
    void removeEffect(in IEffect effect);
}
Loading