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

Commit a75a83f7 authored by millerliang's avatar millerliang
Browse files

aaudio: Reqest 32_BIT in AAudio Service for MMAP streams

Change the format to 32_BIT if the format is float.

Bug: 175673727
Test: The formats listed are the internal AudioFlinger formats:
Test: 1=16_BIT, 3=32_BIT, 4=8_24_BIT, 5=FLOAT, 6=24_BIT_PACKED
Change-Id: I68972a3529e60725aaf44cfd3d35ddcc4523039e
parent 279dbc40
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.