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

Commit cf423d26 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "aaudio: allow AudioRecord to use FAST mode for TRANSFER_SYNC" into oc-dev

parents 433ecd85 382d11ac
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -576,10 +576,17 @@ status_t AudioRecord::openRecord_l(const Modulo<uint32_t> &epoch, const String16
    // Client can only express a preference for FAST.  Server will perform additional tests.
    if (mFlags & AUDIO_INPUT_FLAG_FAST) {
        bool useCaseAllowed =
            // either of these use cases:
            // any of these use cases:
            // use case 1: callback transfer mode
            (mTransfer == TRANSFER_CALLBACK) ||
            // use case 2: obtain/release mode
            // use case 2: blocking read mode
            // The default buffer capacity at 48 kHz is 2048 frames, or ~42.6 ms.
            // That's enough for double-buffering with our standard 20 ms rule of thumb for
            // the minimum period of a non-SCHED_FIFO thread.
            // This is needed so that AAudio apps can do a low latency non-blocking read from a
            // callback running with SCHED_FIFO.
            (mTransfer == TRANSFER_SYNC) ||
            // use case 3: obtain/release mode
            (mTransfer == TRANSFER_OBTAIN);
        // sample rates must also match
        bool fastAllowed = useCaseAllowed && (mSampleRate == afSampleRate);