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

Commit c3fc2d48 authored by Miller Liang's avatar Miller Liang Committed by Automerger Merge Worker
Browse files

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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/14352469

Change-Id: Ib6f60a8b50b1e0890543027a9133254e2f92b6e5
parents ad7ee295 f19f8f97
Loading
Loading
Loading
Loading
+11 −6
Original line number Original line Diff line number Diff line
@@ -80,18 +80,23 @@ aaudio_result_t AAudioServiceEndpointMMAP::open(const aaudio::AAudioStreamReques


    audio_format_t audioFormat = getFormat();
    audio_format_t audioFormat = getFormat();


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


    result = openWithFormat(audioFormat);
    result = openWithFormat(audioFormat);
    if (result == AAUDIO_OK) return result;
    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.
    // TODO The HAL and AudioFlinger should be recommending a format if the open fails.
    //      But that recommendation is not propagating back from the HAL.
    //      But that recommendation is not propagating back from the HAL.
    //      So for now just try something very likely to work.
    //      So for now just try something very likely to work.