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

Commit 957af4ce authored by Glenn Kasten's avatar Glenn Kasten Committed by Android (Google) Code Review
Browse files

Merge "AudioRecord::read() can be non-blocking to match AudioTrack"

parents 343dad3c 3622cdff
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -402,8 +402,11 @@ public:
     *      WOULD_BLOCK         when obtainBuffer() returns same, or
     *                          AudioRecord was stopped during the read
     *      or any other error code returned by IAudioRecord::start() or restoreRecord_l().
     * Default behavior is to only return when all data has been transferred. Set 'blocking' to
     * false for the method to return immediately without waiting to try multiple times to read
     * the full content of the buffer.
     */
            ssize_t     read(void* buffer, size_t size);
            ssize_t     read(void* buffer, size_t size, bool blocking = true);

    /* Return the number of input frames lost in the audio driver since the last call of this
     * function.  Audio driver is expected to reset the value to 0 and restart counting upon
+3 −2
Original line number Diff line number Diff line
@@ -721,7 +721,7 @@ audio_io_handle_t AudioRecord::getInputPrivate() const

// -------------------------------------------------------------------------

ssize_t AudioRecord::read(void* buffer, size_t userSize)
ssize_t AudioRecord::read(void* buffer, size_t userSize, bool blocking)
{
    if (mTransfer != TRANSFER_SYNC) {
        return INVALID_OPERATION;
@@ -740,7 +740,8 @@ ssize_t AudioRecord::read(void* buffer, size_t userSize)
    while (userSize >= mFrameSize) {
        audioBuffer.frameCount = userSize / mFrameSize;

        status_t err = obtainBuffer(&audioBuffer, &ClientProxy::kForever);
        status_t err = obtainBuffer(&audioBuffer,
                blocking ? &ClientProxy::kForever : &ClientProxy::kNonBlocking);
        if (err < 0) {
            if (read > 0) {
                break;