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

Commit c8d1b107 authored by Zhijun He's avatar Zhijun He Committed by Android Git Automerger
Browse files

am 217814bf: Merge "ImageReader: free direct byte buffers once Image is returned" into lmp-mr1-dev

* commit '217814bf':
  ImageReader: free direct byte buffers once Image is returned
parents 75371fd7 217814bf
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.view.Surface;
import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.NioUtils;

/**
 * <p>The ImageReader class allows direct application access to image data
@@ -688,6 +689,15 @@ public class ImageReader implements AutoCloseable {
            }

            private void clearBuffer() {
                // Need null check first, as the getBuffer() may not be called before an image
                // is closed.
                if (mBuffer == null) {
                    return;
                }

                if (mBuffer.isDirect()) {
                    NioUtils.freeDirectBuffer(mBuffer);
                }
                mBuffer = null;
            }