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

Commit f042b9be authored by jiabin's avatar jiabin Committed by Eric Laurent
Browse files

Do not invalidate stream when the secondary outputs are changed.

When a dynamic policy is registered, the secondary outputs may be
changed. Instead of tearing down the tracks, only tracks whose secondary
outputs are changed will be updated with the new secondary outputs.

Bug: 181582467
Bug: 174123397
Test: atest AudioPlaybackCaptureTest audiopolicy_tests
Test: repo steps in the bug
Change-Id: I9a47a0a4b37ad3f4a1d554dd726ebffb27325141
(cherry picked from commit 10a03f17)
parent 844ef1be
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -2323,4 +2323,28 @@ legacy2aidl_audio_encapsulation_type_t_AudioEncapsulationType(
    return unexpected(BAD_VALUE);
}

ConversionResult<TrackSecondaryOutputInfoPair>
aidl2legacy_TrackSecondaryOutputInfo_TrackSecondaryOutputInfoPair(
        const media::TrackSecondaryOutputInfo& aidl) {
    TrackSecondaryOutputInfoPair trackSecondaryOutputInfoPair;
    trackSecondaryOutputInfoPair.first =
            VALUE_OR_RETURN(aidl2legacy_int32_t_audio_port_handle_t(aidl.portId));
    trackSecondaryOutputInfoPair.second =
            VALUE_OR_RETURN(convertContainer<std::vector<audio_port_handle_t>>(
                    aidl.secondaryOutputIds, aidl2legacy_int32_t_audio_io_handle_t));
    return trackSecondaryOutputInfoPair;
}

ConversionResult<media::TrackSecondaryOutputInfo>
legacy2aidl_TrackSecondaryOutputInfoPair_TrackSecondaryOutputInfo(
        const TrackSecondaryOutputInfoPair& legacy) {
    media::TrackSecondaryOutputInfo trackSecondaryOutputInfo;
    trackSecondaryOutputInfo.portId =
            VALUE_OR_RETURN(legacy2aidl_audio_port_handle_t_int32_t(legacy.first));
    trackSecondaryOutputInfo.secondaryOutputIds =
            VALUE_OR_RETURN(convertContainer<std::vector<int32_t>>(
                    legacy.second, legacy2aidl_audio_io_handle_t_int32_t));
    return trackSecondaryOutputInfo;
}

}  // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -351,6 +351,7 @@ aidl_interface {
        "aidl/android/media/AudioVibratorInfo.aidl",
        "aidl/android/media/EffectDescriptor.aidl",
        "aidl/android/media/ExtraAudioDescriptor.aidl",
        "aidl/android/media/TrackSecondaryOutputInfo.aidl",
    ],
    imports: [
        "audio_common-aidl",
+19 −0
Original line number Diff line number Diff line
@@ -743,6 +743,16 @@ status_t AudioFlingerClientAdapter::setVibratorInfos(
    return statusTFromBinderStatus(mDelegate->setVibratorInfos(vibratorInfos));
}

status_t AudioFlingerClientAdapter::updateSecondaryOutputs(
        const TrackSecondaryOutputsMap& trackSecondaryOutputs) {
    std::vector<media::TrackSecondaryOutputInfo> trackSecondaryOutputInfos =
            VALUE_OR_RETURN_STATUS(
                    convertContainer<std::vector<media::TrackSecondaryOutputInfo>>(
                            trackSecondaryOutputs,
                            legacy2aidl_TrackSecondaryOutputInfoPair_TrackSecondaryOutputInfo));
    return statusTFromBinderStatus(mDelegate->updateSecondaryOutputs(trackSecondaryOutputInfos));
}


////////////////////////////////////////////////////////////////////////////////////////////////////
// AudioFlingerServerAdapter
@@ -1199,4 +1209,13 @@ Status AudioFlingerServerAdapter::setVibratorInfos(
    return Status::fromStatusT(mDelegate->setVibratorInfos(vibratorInfos));
}

Status AudioFlingerServerAdapter::updateSecondaryOutputs(
        const std::vector<media::TrackSecondaryOutputInfo>& trackSecondaryOutputInfos) {
    TrackSecondaryOutputsMap trackSecondaryOutputs =
            VALUE_OR_RETURN_BINDER(convertContainer<TrackSecondaryOutputsMap>(
                    trackSecondaryOutputInfos,
                    aidl2legacy_TrackSecondaryOutputInfo_TrackSecondaryOutputInfoPair));
    return Status::fromStatusT(mDelegate->updateSecondaryOutputs(trackSecondaryOutputs));
}

} // namespace android
+6 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.media.IAudioRecord;
import android.media.IAudioTrack;
import android.media.MicrophoneInfoData;
import android.media.RenderPosition;
import android.media.TrackSecondaryOutputInfo;
import android.media.audio.common.AudioFormat;

/**
@@ -207,4 +208,9 @@ interface IAudioFlingerService {
    // Set vibrators' information.
    // The value will be used to initialize HapticGenerator.
    void setVibratorInfos(in AudioVibratorInfo[] vibratorInfos);

    // Update secondary outputs.
    // This usually happens when there is a dynamic policy registered.
    void updateSecondaryOutputs(
            in TrackSecondaryOutputInfo[] trackSecondaryOutputInfos);
}
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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;

/**
 * This is a class that contains port handle for a track and handles for all secondary
 * outputs of the track.
 * @hide
 */
parcelable TrackSecondaryOutputInfo {
    int portId; // audio_port_handle_t
    int[] secondaryOutputIds; // audio_io_handle_t[]
}
 No newline at end of file
Loading