summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-07-18 01:00:48 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-07-18 01:00:48 +0000
commitb8293fd0e0fdf278b0adc7315bf04fafd48b9ca7 (patch)
tree5bc4942b01f746a803ffe4019217cf97275caa3a
parentb072f658a5b01ed99abeb6e988842e81b837772d (diff)
parentdf8a0739f7ab42ce59e2370867d26ed2793b6228 (diff)
downloadnative-android-cts-11.0_r1.tar.gz
Snap for 6690197 from df8a0739f7ab42ce59e2370867d26ed2793b6228 to rvc-releaseandroid-vts-11.0_r1android-cts-11.0_r1android-11.0.0_r3android-11.0.0_r2android-11.0.0_r1
Change-Id: I23608aee49209430c8b06c4a822a2abd13171305
-rw-r--r--libs/nativedisplay/include/surfacetexture/surface_texture_platform.h2
-rw-r--r--libs/nativedisplay/surfacetexture/surface_texture.cpp10
2 files changed, 11 insertions, 1 deletions
diff --git a/libs/nativedisplay/include/surfacetexture/surface_texture_platform.h b/libs/nativedisplay/include/surfacetexture/surface_texture_platform.h
index e2d036bfb0..f3716674c5 100644
--- a/libs/nativedisplay/include/surfacetexture/surface_texture_platform.h
+++ b/libs/nativedisplay/include/surfacetexture/surface_texture_platform.h
@@ -79,6 +79,8 @@ typedef int (*ASurfaceTexture_fenceWait)(int fence, void* fencePassThroughHandle
/**
* 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 d1bcd8d1b1..ebe4484873 100644
--- a/libs/nativedisplay/surfacetexture/surface_texture.cpp
+++ b/libs/nativedisplay/surfacetexture/surface_texture.cpp
@@ -208,7 +208,15 @@ AHardwareBuffer* ASurfaceTexture_dequeueBuffer(ASurfaceTexture* st, int* outSlot
*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