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

Commit 5a4e5db4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use returned config to retry opening MMAP stream when fails."

parents b573b57e f1c7397e
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -1015,7 +1015,7 @@ status_t AudioSystem::getOutputForAttr(audio_attributes_t* attr,
                                       audio_session_t session,
                                       audio_stream_type_t* stream,
                                       const AttributionSourceState& attributionSource,
                                       const audio_config_t* config,
                                       audio_config_t* config,
                                       audio_output_flags_t flags,
                                       audio_port_handle_t* selectedDeviceId,
                                       audio_port_handle_t* portId,
@@ -1057,9 +1057,18 @@ status_t AudioSystem::getOutputForAttr(audio_attributes_t* attr,

    media::GetOutputForAttrResponse responseAidl;

    RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
    status_t status = statusTFromBinderStatus(
            aps->getOutputForAttr(attrAidl, sessionAidl, attributionSource, configAidl, flagsAidl,
                                  selectedDeviceIdAidl, &responseAidl)));
                                  selectedDeviceIdAidl, &responseAidl));
    if (status != NO_ERROR) {
        config->format = VALUE_OR_RETURN_STATUS(
            aidl2legacy_AudioFormatDescription_audio_format_t(responseAidl.configBase.format));
        config->channel_mask = VALUE_OR_RETURN_STATUS(
            aidl2legacy_AudioChannelLayout_audio_channel_mask_t(
                    responseAidl.configBase.channelMask, false /*isInput*/));
        config->sample_rate = responseAidl.configBase.sampleRate;
        return status;
    }

    *output = VALUE_OR_RETURN_STATUS(
            aidl2legacy_int32_t_audio_io_handle_t(responseAidl.output));
@@ -1114,7 +1123,7 @@ status_t AudioSystem::getInputForAttr(const audio_attributes_t* attr,
                                      audio_unique_id_t riid,
                                      audio_session_t session,
                                      const AttributionSourceState &attributionSource,
                                      const audio_config_base_t* config,
                                      audio_config_base_t* config,
                                      audio_input_flags_t flags,
                                      audio_port_handle_t* selectedDeviceId,
                                      audio_port_handle_t* portId) {
@@ -1151,9 +1160,14 @@ status_t AudioSystem::getInputForAttr(const audio_attributes_t* attr,

    media::GetInputForAttrResponse response;

    RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
    status_t status = statusTFromBinderStatus(
            aps->getInputForAttr(attrAidl, inputAidl, riidAidl, sessionAidl, attributionSource,
                configAidl, flagsAidl, selectedDeviceIdAidl, &response)));
                configAidl, flagsAidl, selectedDeviceIdAidl, &response));
    if (status != NO_ERROR) {
        *config = VALUE_OR_RETURN_STATUS(
                aidl2legacy_AudioConfigBase_audio_config_base_t(response.config, true /*isInput*/));
        return status;
    }

    *input = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_io_handle_t(response.input));
    *selectedDeviceId = VALUE_OR_RETURN_STATUS(
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.media;

import android.media.audio.common.AudioConfigBase;

/**
 * {@hide}
 */
@@ -26,4 +28,6 @@ parcelable GetInputForAttrResponse {
    int selectedDeviceId;
    /** Interpreted as audio_port_handle_t. */
    int portId;
    /** The suggested config if fails to get an input. **/
    AudioConfigBase config;
}
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.media;

import android.media.audio.common.AudioConfigBase;
import android.media.audio.common.AudioStreamType;

/**
@@ -33,4 +34,6 @@ parcelable GetOutputForAttrResponse {
    int[] secondaryOutputs;
    /** True if the track is connected to a spatializer mixer and actually spatialized */
    boolean isSpatialized;
    /** The suggested audio config if fails to get an output. **/
    AudioConfigBase configBase;
}
+41 −5
Original line number Diff line number Diff line
@@ -282,12 +282,31 @@ public:
    static status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config);
    static audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage);

    /**
     * Get output stream for given parameters.
     *
     * @param[in] attr the requested audio attributes
     * @param[in|out] output the io handle of the output for the playback. It is specified when
     *                       starting mmap thread.
     * @param[in] session the session id for the client
     * @param[in|out] stream the stream type used for the playback
     * @param[in] attributionSource a source to which access to permission protected data
     * @param[in|out] config the requested configuration client, the suggested configuration will
     *                       be returned if no proper output is found for requested configuration
     * @param[in] flags the requested output flag from client
     * @param[in|out] selectedDeviceId the requested device id for playback, the actual device id
     *                                 for playback will be returned
     * @param[out] portId the generated port id to identify the client
     * @param[out] secondaryOutputs collection of io handle for secondary outputs
     * @param[out] isSpatialized true if the playback will be spatialized
     * @return if the call is successful or not
     */
    static status_t getOutputForAttr(audio_attributes_t *attr,
                                     audio_io_handle_t *output,
                                     audio_session_t session,
                                     audio_stream_type_t *stream,
                                     const AttributionSourceState& attributionSource,
                                     const audio_config_t *config,
                                     audio_config_t *config,
                                     audio_output_flags_t flags,
                                     audio_port_handle_t *selectedDeviceId,
                                     audio_port_handle_t *portId,
@@ -297,14 +316,31 @@ public:
    static status_t stopOutput(audio_port_handle_t portId);
    static void releaseOutput(audio_port_handle_t portId);

    // Client must successfully hand off the handle reference to AudioFlinger via createRecord(),
    // or release it with releaseInput().
    /**
     * Get input stream for given parameters.
     * Client must successfully hand off the handle reference to AudioFlinger via createRecord(),
     * or release it with releaseInput().
     *
     * @param[in] attr the requested audio attributes
     * @param[in|out] input the io handle of the input for the capture. It is specified when
     *                      starting mmap thread.
     * @param[in] riid an unique id to identify the record client
     * @param[in] session the session id for the client
     * @param[in] attributionSource a source to which access to permission protected data
     * @param[in|out] config the requested configuration client, the suggested configuration will
     *                       be returned if no proper input is found for requested configuration
     * @param[in] flags the requested input flag from client
     * @param[in|out] selectedDeviceId the requested device id for playback, the actual device id
     *                                 for playback will be returned
     * @param[out] portId the generated port id to identify the client
     * @return if the call is successful or not
     */
    static status_t getInputForAttr(const audio_attributes_t *attr,
                                    audio_io_handle_t *input,
                                    audio_unique_id_t riid,
                                    audio_session_t session,
                                    const AttributionSourceState& attributionSource,
                                    const audio_config_base_t *config,
                                    audio_config_base_t *config,
                                    audio_input_flags_t flags,
                                    audio_port_handle_t *selectedDeviceId,
                                    audio_port_handle_t *portId);
+5 −0
Original line number Diff line number Diff line
@@ -597,6 +597,11 @@ status_t AudioFlinger::openMmapStream(MmapStreamInterface::stream_direction_t di
                                            (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_MMAP_NOIRQ |
                                                    AUDIO_OUTPUT_FLAG_DIRECT),
                                            deviceId, &portId, &secondaryOutputs, &isSpatialized);
        if (ret != NO_ERROR) {
            config->sample_rate = fullConfig.sample_rate;
            config->channel_mask = fullConfig.channel_mask;
            config->format = fullConfig.format;
        }
        ALOGW_IF(!secondaryOutputs.empty(),
                 "%s does not support secondary outputs, ignoring them", __func__);
    } else {
Loading