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

Commit a84e73a7 authored by Glenn Kasten's avatar Glenn Kasten Committed by Android Git Automerger
Browse files

am ad432203: Merge "Improve error handling for AudioTrack write with PTS" into mnc-dev

* commit 'ad432203':
  Improve error handling for AudioTrack write with PTS
parents 023973ec ad432203
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -1990,9 +1990,24 @@ public class AudioTrack
     *     The dead object error code is not returned if some data was successfully transferred.
     *     In this case, the error is returned at the next write().
     */
    public int write(ByteBuffer audioData, int sizeInBytes,
    public int write(@NonNull ByteBuffer audioData, int sizeInBytes,
            @WriteMode int writeMode, long timestamp) {

        if (mState == STATE_UNINITIALIZED) {
            Log.e(TAG, "AudioTrack.write() called in invalid state STATE_UNINITIALIZED");
            return ERROR_INVALID_OPERATION;
        }

        if ((writeMode != WRITE_BLOCKING) && (writeMode != WRITE_NON_BLOCKING)) {
            Log.e(TAG, "AudioTrack.write() called with invalid blocking mode");
            return ERROR_BAD_VALUE;
        }

        if (mDataLoadMode != MODE_STREAM) {
            Log.e(TAG, "AudioTrack.write() with timestamp called for non-streaming mode track");
            return ERROR_INVALID_OPERATION;
        }

        if ((mAttributes.getFlags() & AudioAttributes.FLAG_HW_AV_SYNC) == 0) {
            Log.d(TAG, "AudioTrack.write() called on a regular AudioTrack. Ignoring pts...");
            return write(audioData, sizeInBytes, writeMode);