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

Commit 1f336eb8 authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "AudioFlinger: Return volume and muted on startOutput" into main

parents 5604464b 207ec5c3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -465,6 +465,7 @@ aidl_interface {
        "aidl/android/media/IAudioPolicyService.aidl",
        "aidl/android/media/IAudioPolicyServiceClient.aidl",
        "aidl/android/media/RecordClientInfo.aidl",
        "aidl/android/media/StartOutputResponse.aidl",
    ],
    defaults: [
        "latest_android_media_audio_common_types_import_interface",
+10 −7
Original line number Diff line number Diff line
@@ -1305,9 +1305,7 @@ status_t AudioSystem::getOutputForAttr(audio_attributes_t* attr,
                                       audio_port_handle_t* portId,
                                       std::vector<audio_io_handle_t>* secondaryOutputs,
                                       bool *isSpatialized,
                                       bool *isBitPerfect,
                                       float *volume,
                                       bool *muted) {
                                       bool *isBitPerfect) {
    if (attr == nullptr) {
        ALOGE("%s NULL audio attributes", __func__);
        return BAD_VALUE;
@@ -1373,18 +1371,23 @@ status_t AudioSystem::getOutputForAttr(audio_attributes_t* attr,
    *isBitPerfect = responseAidl.isBitPerfect;
    *attr = VALUE_OR_RETURN_STATUS(
            aidl2legacy_AudioAttributes_audio_attributes_t(responseAidl.attr));
    *volume = responseAidl.volume;
    *muted = responseAidl.muted;

    return OK;
}

status_t AudioSystem::startOutput(audio_port_handle_t portId) {
status_t AudioSystem::startOutput(
        audio_port_handle_t portId, float* volume, bool* muted) {
    const sp<IAudioPolicyService> aps = get_audio_policy_service();
    if (aps == nullptr) return AudioPolicyServiceTraits::getError();

    int32_t portIdAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_port_handle_t_int32_t(portId));
    return statusTFromBinderStatus(aps->startOutput(portIdAidl));
    media::StartOutputResponse responseAidl;
    status_t status = statusTFromBinderStatus(aps->startOutput(portIdAidl, &responseAidl));
    if (status != NO_ERROR) return status;

    *volume = responseAidl.volume;
    *muted = responseAidl.muted;
    return OK;
}

status_t AudioSystem::stopOutput(audio_port_handle_t portId) {
+0 −4
Original line number Diff line number Diff line
@@ -39,8 +39,4 @@ parcelable GetOutputForAttrResponse {
    boolean isBitPerfect;
    /** The corrected audio attributes. **/
    AudioAttributes attr;
    /** initial port volume for the new audio track */
    float volume;
    /** initial port muted state for the new audio track */
    boolean muted;
}
+2 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.media.IAudioPolicyServiceClient;
import android.media.ICaptureStateListener;
import android.media.INativeSpatializerCallback;
import android.media.SoundTriggerSession;
import android.media.StartOutputResponse;
import android.media.audio.common.AudioAttributes;
import android.media.audio.common.AudioConfig;
import android.media.audio.common.AudioConfigBase;
@@ -97,7 +98,7 @@ interface IAudioPolicyService {
                                              int /* Bitmask, indexed by AudioOutputFlags */ flags,
                                              in int[] /* audio_port_handle_t */ selectedDeviceIds);

    void startOutput(int /* audio_port_handle_t */ portId);
    StartOutputResponse startOutput(int /* audio_port_handle_t */ portId);

    void stopOutput(int /* audio_port_handle_t */ portId);

+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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;

/**
 * {@hide}
 */
parcelable StartOutputResponse {
    /** port volume for the audio track */
    float volume;
    /** port muted state for the audio track */
    boolean muted;
}
Loading