commit | 6824ce0589be8d548a27c92d4a0f4c4b6647f87b | [log] [tgz] |
---|---|---|
author | Stan Iliev <stani@google.com> | Fri Jul 17 15:04:51 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri Jul 17 15:04:51 2020 +0000 |
tree | 5bc4942b01f746a803ffe4019217cf97275caa3a | |
parent | e42c7447815c8ab3661b664a8a4f06f3e40098d4 [diff] | |
parent | df8a0739f7ab42ce59e2370867d26ed2793b6228 [diff] |
Fix TextureView calling eglCreateImage with a destructed buffer am: df8a0739f7 Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/12174650 Change-Id: Iacd4ab78866e190e6f57343c188c4d676a5f8b1a
diff --git a/libs/nativedisplay/include/surfacetexture/surface_texture_platform.h b/libs/nativedisplay/include/surfacetexture/surface_texture_platform.h index e2d036b..f371667 100644 --- a/libs/nativedisplay/include/surfacetexture/surface_texture_platform.h +++ b/libs/nativedisplay/include/surfacetexture/surface_texture_platform.h
@@ -79,6 +79,8 @@ /** * ASurfaceTexture_dequeueBuffer returns the next available AHardwareBuffer. + * The caller gets ownership of the buffer and need to release it with + * AHardwareBuffer_release. */ AHardwareBuffer* ASurfaceTexture_dequeueBuffer(ASurfaceTexture* st, int* outSlotid, android_dataspace* outDataspace,
diff --git a/libs/nativedisplay/surfacetexture/surface_texture.cpp b/libs/nativedisplay/surfacetexture/surface_texture.cpp index d1bcd8d..ebe4484 100644 --- a/libs/nativedisplay/surfacetexture/surface_texture.cpp +++ b/libs/nativedisplay/surfacetexture/surface_texture.cpp
@@ -208,7 +208,15 @@ *outNewContent = true; } } while (buffer.get() && (!queueEmpty)); - return reinterpret_cast<AHardwareBuffer*>(buffer.get()); + AHardwareBuffer* result = nullptr; + if (buffer.get()) { + result = buffer->toAHardwareBuffer(); + // add a reference to keep the hardware buffer alive, even if + // BufferQueueProducer is disconnected. This is needed, because + // sp reference is destroyed at the end of this function. + AHardwareBuffer_acquire(result); + } + return result; } } // namespace android