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

Commit 220eea1b authored by jiabin's avatar jiabin
Browse files

Concurrent playback behavior when bit-perfect client is active.

1. Mute system sound on bit-perfect output thread. System sound such as
   touch sound can be triggered often. To provide better bit-perfect
   playback experience, mute system sound on bit-perfect output thread.
2. Mute bit-perfect track when there are other clients playing. When
   there are other clients, such as notification, playing, the
   bit-perfect client can no longer be played bit-perfectly. As the
   bit-perfect client can turn out to be noise if it cannot be played
   bit-perfectly, mute bit-perfect client when there are other clients
   playing.
3. Do not allow creating bit-perfect client if there is any other high
   priority use case, such as ringtone, alarm, active. The reason is
   that the high priority clients will always take the audio focus for
   the playback and there is no need for those clients to be played over
   bit-perfect path.

Bug: 339515899
Test: atest audiopolicy_tests
Test: Manually
Change-Id: I8483d08085fd4076fa64ed4de278e45e6f6c0af0
parent 40e082a3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -315,6 +315,7 @@ aidl_interface {
        "aidl/android/media/DeviceConnectedState.aidl",
        "aidl/android/media/EffectDescriptor.aidl",
        "aidl/android/media/SurroundSoundConfig.aidl",
        "aidl/android/media/TrackInternalMuteInfo.aidl",
        "aidl/android/media/TrackSecondaryOutputInfo.aidl",
    ],
    defaults: [
+10 −0
Original line number Diff line number Diff line
@@ -918,6 +918,11 @@ status_t AudioFlingerClientAdapter::getAudioMixPort(const struct audio_port_v7 *
    return OK;
}

status_t AudioFlingerClientAdapter::setTracksInternalMute(
        const std::vector<media::TrackInternalMuteInfo>& tracksInternalMuted) {
    return statusTFromBinderStatus(mDelegate->setTracksInternalMute(tracksInternalMuted));
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// AudioFlingerServerAdapter
AudioFlingerServerAdapter::AudioFlingerServerAdapter(
@@ -1477,4 +1482,9 @@ Status AudioFlingerServerAdapter::getAudioMixPort(const media::AudioPortFw &devi
    return Status::ok();
}

Status AudioFlingerServerAdapter::setTracksInternalMute(
        const std::vector<media::TrackInternalMuteInfo>& tracksInternalMute) {
    return Status::fromStatusT(mDelegate->setTracksInternalMute(tracksInternalMute));
}

} // namespace android
+6 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.media.ISoundDose;
import android.media.ISoundDoseCallback;
import android.media.MicrophoneInfoFw;
import android.media.RenderPosition;
import android.media.TrackInternalMuteInfo;
import android.media.TrackSecondaryOutputInfo;
import android.media.audio.common.AudioChannelLayout;
import android.media.audio.common.AudioFormatDescription;
@@ -293,6 +294,11 @@ interface IAudioFlingerService {
     */
    AudioPortFw getAudioMixPort(in AudioPortFw devicePort, in AudioPortFw mixPort);

    /**
     * Set internal mute for a list of tracks.
     */
    void setTracksInternalMute(in TrackInternalMuteInfo[] tracksInternalMute);

    // When adding a new method, please review and update
    // IAudioFlinger.h AudioFlingerServerAdapter::Delegate::TransactionCode
    // AudioFlinger.cpp AudioFlinger::onTransactWrapper()
+23 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media;

parcelable TrackInternalMuteInfo {
    /* Interpreted as audio_port_handle_t. */
    int portId;
    boolean muted;
}
+9 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@
#include "android/media/OpenInputResponse.h"
#include "android/media/OpenOutputRequest.h"
#include "android/media/OpenOutputResponse.h"
#include "android/media/TrackInternalMuteInfo.h"
#include "android/media/TrackSecondaryOutputInfo.h"

namespace android {
@@ -388,6 +389,9 @@ public:

    virtual status_t getAudioMixPort(const struct audio_port_v7 *devicePort,
                                     struct audio_port_v7 *mixPort) const = 0;

    virtual status_t setTracksInternalMute(
            const std::vector<media::TrackInternalMuteInfo>& tracksInternalMute) = 0;
};

/**
@@ -504,6 +508,8 @@ public:
    status_t getAudioPolicyConfig(media::AudioPolicyConfig* output) override;
    status_t getAudioMixPort(const struct audio_port_v7 *devicePort,
                             struct audio_port_v7 *mixPort) const override;
    status_t setTracksInternalMute(
            const std::vector<media::TrackInternalMuteInfo>& tracksInternalMute) override;

private:
    const sp<media::IAudioFlingerService> mDelegate;
@@ -606,6 +612,7 @@ public:
            GET_AUDIO_POLICY_CONFIG =
                    media::BnAudioFlingerService::TRANSACTION_getAudioPolicyConfig,
            GET_AUDIO_MIX_PORT = media::BnAudioFlingerService::TRANSACTION_getAudioMixPort,
            SET_TRACKS_INTERNAL_MUTE = media::BnAudioFlingerService::TRANSACTION_setTracksInternalMute,
        };

    protected:
@@ -742,6 +749,8 @@ public:
    Status getAudioMixPort(const media::AudioPortFw& devicePort,
                           const media::AudioPortFw& mixPort,
                           media::AudioPortFw* _aidl_return) override;
    Status setTracksInternalMute(
            const std::vector<media::TrackInternalMuteInfo>& tracksInternalMute) override;
private:
    const sp<AudioFlingerServerAdapter::Delegate> mDelegate;
};
Loading