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

Commit f19f8f97 authored by Miller Liang's avatar Miller Liang Committed by Android (Google) Code Review
Browse files

Merge "aaudio: Reqest 32_BIT in AAudio Service for MMAP streams" into sc-dev

parents ba72d94e a75a83f7
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -80,18 +80,23 @@ aaudio_result_t AAudioServiceEndpointMMAP::open(const aaudio::AAudioStreamReques

    audio_format_t audioFormat = getFormat();

    // FLOAT is not directly supported by the HAL so ask for a 24-bit.
    bool isHighResRequested = audioFormat == AUDIO_FORMAT_PCM_FLOAT
            || audioFormat == AUDIO_FORMAT_PCM_32_BIT;
    if (isHighResRequested) {
    // FLOAT is not directly supported by the HAL so ask for a 32-bit.
    if (audioFormat == AUDIO_FORMAT_PCM_FLOAT) {
        // TODO remove these logs when finished debugging.
        ALOGD("%s() change format from %d to 24_BIT_PACKED", __func__, audioFormat);
        audioFormat = AUDIO_FORMAT_PCM_24_BIT_PACKED;
        ALOGD("%s() change format from %d to 32_BIT", __func__, audioFormat);
        audioFormat = AUDIO_FORMAT_PCM_32_BIT;
    }

    result = openWithFormat(audioFormat);
    if (result == AAUDIO_OK) return result;

    if (result == AAUDIO_ERROR_UNAVAILABLE && audioFormat == AUDIO_FORMAT_PCM_32_BIT) {
        ALOGD("%s() 32_BIT failed, perhaps due to format. Try again with 24_BIT_PACKED", __func__);
        audioFormat = AUDIO_FORMAT_PCM_24_BIT_PACKED;
        result = openWithFormat(audioFormat);
    }
    if (result == AAUDIO_OK) return result;

    // TODO The HAL and AudioFlinger should be recommending a format if the open fails.
    //      But that recommendation is not propagating back from the HAL.
    //      So for now just try something very likely to work.