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

Commit 7a81f843 authored by jiabin's avatar jiabin
Browse files

Add bit-perfect mixer behavior.

The bit-perfect mixer behavior is used by preferred mixer attributes
APIs. With setting the mixer behavior as bit-perfect, the audio data can
be sent bit-perfectly down to the HAL.

Bug: 239435816
Test: make
Change-Id: I86a3826e22ec04a861d033afe669b7ea44d81217
parent 89f87edf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -20818,6 +20818,7 @@ package android.media {
    method public int getMixerBehavior();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.media.AudioMixerAttributes> CREATOR;
    field public static final int MIXER_BEHAVIOR_BIT_PERFECT = 1; // 0x1
    field public static final int MIXER_BEHAVIOR_DEFAULT = 0; // 0x0
  }
+5 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@

// Keep sync with AudioMixerAttributes.java
#define MIXER_BEHAVIOR_DEFAULT 0
#define MIXER_BEHAVIOR_BIT_PERFECT 1
// Invalid value is not added in JAVA API, but keep sync with native value
#define MIXER_BEHAVIOR_INVALID -1

@@ -28,6 +29,8 @@ static inline audio_mixer_behavior_t audioMixerBehaviorToNative(int mixerBehavio
    switch (mixerBehavior) {
        case MIXER_BEHAVIOR_DEFAULT:
            return AUDIO_MIXER_BEHAVIOR_DEFAULT;
        case MIXER_BEHAVIOR_BIT_PERFECT:
            return AUDIO_MIXER_BEHAVIOR_BIT_PERFECT;
        default:
            return AUDIO_MIXER_BEHAVIOR_INVALID;
    }
@@ -37,6 +40,8 @@ static inline jint audioMixerBehaviorFromNative(audio_mixer_behavior_t mixerBeha
    switch (mixerBehavior) {
        case AUDIO_MIXER_BEHAVIOR_DEFAULT:
            return MIXER_BEHAVIOR_DEFAULT;
        case AUDIO_MIXER_BEHAVIOR_BIT_PERFECT:
            return MIXER_BEHAVIOR_BIT_PERFECT;
        case AUDIO_MIXER_BEHAVIOR_INVALID:
        default:
            return MIXER_BEHAVIOR_INVALID;
+14 −3
Original line number Diff line number Diff line
@@ -37,10 +37,17 @@ public final class AudioMixerAttributes implements Parcelable {
     */
    public static final int MIXER_BEHAVIOR_DEFAULT = 0;

    /**
     * Constant indicating the audio mixer behavior is bit-perfect, which indicates there will
     * not be mixing happen, the audio data will be sent as is down to the HAL.
     */
    public static final int MIXER_BEHAVIOR_BIT_PERFECT = 1;

    /** @hide */
    @IntDef(flag = false, prefix = "MIXER_BEHAVIOR_", value = {
            MIXER_BEHAVIOR_DEFAULT }
    )
            MIXER_BEHAVIOR_DEFAULT,
            MIXER_BEHAVIOR_BIT_PERFECT
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface MixerBehavior {}

@@ -103,12 +110,14 @@ public final class AudioMixerAttributes implements Parcelable {

        /**
         * Sets the mixer behavior for the audio mixer
         * @param mixerBehavior must be {@link #MIXER_BEHAVIOR_DEFAULT}.
         * @param mixerBehavior must be {@link #MIXER_BEHAVIOR_DEFAULT} or
         *                      {@link #MIXER_BEHAVIOR_BIT_PERFECT}.
         * @return the same Builder instance.
         */
        public @NonNull Builder setMixerBehavior(@MixerBehavior int mixerBehavior) {
            switch (mixerBehavior) {
                case MIXER_BEHAVIOR_DEFAULT:
                case MIXER_BEHAVIOR_BIT_PERFECT:
                    mMixerBehavior = mixerBehavior;
                    break;
                default:
@@ -137,6 +146,8 @@ public final class AudioMixerAttributes implements Parcelable {
        switch (mixerBehavior) {
            case MIXER_BEHAVIOR_DEFAULT:
                return "default";
            case MIXER_BEHAVIOR_BIT_PERFECT:
                return "bit-perfect";
            default:
                return "unknown";
        }