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

Commit c9e68882 authored by Jiabin Huang's avatar Jiabin Huang Committed by Automerger Merge Worker
Browse files

Merge "Support float data on aaudio legacy record fast path." into tm-dev am: 0ea7ae4b

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

Change-Id: I691045db97ed16e1a8a211f292f971bbbdf35b7a
parents 493371ff 0ea7ae4b
Loading
Loading
Loading
Loading
+2 −23
Original line number Diff line number Diff line
@@ -96,29 +96,8 @@ aaudio_result_t AudioStreamRecord::open(const AudioStreamBuilder& builder)
        setFormat(AUDIO_FORMAT_PCM_FLOAT);
    }

    // Maybe change device format to get a FAST path.
    // AudioRecord does not support FAST mode for FLOAT data.
    // TODO AudioRecord should allow FLOAT data paths for FAST tracks.
    // So IF the user asks for low latency FLOAT
    // AND the sampleRate is likely to be compatible with FAST
    // THEN request I16 and convert to FLOAT when passing to user.
    // Note that hard coding 48000 Hz is not ideal because the sampleRate
    // for a FAST path might not be 48000 Hz.
    // It normally is but there is a chance that it is not.
    // And there is no reliable way to know that in advance.
    // Luckily the consequences of a wrong guess are minor.
    // We just may not get a FAST track.
    // But we wouldn't have anyway without this hack.
    constexpr int32_t kMostLikelySampleRateForFast = 48000;
    if (getFormat() == AUDIO_FORMAT_PCM_FLOAT
            && perfMode == AAUDIO_PERFORMANCE_MODE_LOW_LATENCY
            && (audio_channel_count_from_in_mask(channelMask) <= 2) // FAST only for mono and stereo
            && (getSampleRate() == kMostLikelySampleRateForFast
                || getSampleRate() == AAUDIO_UNSPECIFIED)) {
        setDeviceFormat(AUDIO_FORMAT_PCM_16_BIT);
    } else {

    setDeviceFormat(getFormat());
    }

    // To avoid glitching, let AudioFlinger pick the optimal burst size.
    uint32_t notificationFrames = 0;