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

Commit 8eebebaa authored by millerliang's avatar millerliang
Browse files

aaudio: add support for FLOAT pcm

Add to support for AUDIO_FORMAT_PCM_FLOAT.

Request AUDIO_FORMAT_PCM_FLOAT for MMAP	streams.
Change the format to 32_BIT if openWithFormat returns error
and the format is float.

Bug: 201398105
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: If1ce1b31746dccba82d4eb9493d16946e39720b4
parent ddc0e301
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -80,14 +80,14 @@ 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 32-bit.
    if (audioFormat == AUDIO_FORMAT_PCM_FLOAT) {
        // TODO remove these logs when finished debugging.
        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_FLOAT) {
        ALOGD("%s() FLOAT failed, perhaps due to format. Try again with 32_BIT", __func__);
        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) {