Skip to content
Snippets Groups Projects
Commit 0efa67ce authored by Tao Wu's avatar Tao Wu
Browse files

V4L2EncodeComponent: Better error handling when syncing buffer

Thanks Yiwei pointed out the buggy code which doesn't do error handling
and also we should only sync CPU writable buffer.

Bug: 268317650
Test: atest com.google.android.media.gts.RtcVideoCodecTest#testDynamicBitrateChangeVp8
Change-Id: I3c1019fb0d56180ef8460625843cf8e98301ddce
parent add5343b
No related branches found
No related tags found
No related merge requests found
...@@ -531,13 +531,18 @@ void V4L2EncodeComponent::queueTask(std::unique_ptr<C2Work> work) { ...@@ -531,13 +531,18 @@ void V4L2EncodeComponent::queueTask(std::unique_ptr<C2Work> work) {
uint64_t usage, igbpId; uint64_t usage, igbpId;
_UnwrapNativeCodec2GrallocMetadata(handle, &width, &height, &format, &usage, &stride, _UnwrapNativeCodec2GrallocMetadata(handle, &width, &height, &format, &usage, &stride,
&generation, &igbpId, &igbpSlot); &generation, &igbpId, &igbpSlot);
native_handle_t* gralloc_handle = UnwrapNativeCodec2GrallocHandle(handle); do {
sp<GraphicBuffer> buffer = if (!(usage & GRALLOC_USAGE_SW_WRITE_MASK)) break;
new GraphicBuffer(gralloc_handle, GraphicBuffer::CLONE_HANDLE, width, height, native_handle_t* gralloc_handle = UnwrapNativeCodec2GrallocHandle(handle);
format, 1, usage, stride); if (nullptr == gralloc_handle) break;
void* pixels; sp<GraphicBuffer> buffer =
buffer->lock(GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN, &pixels); new GraphicBuffer(gralloc_handle, GraphicBuffer::CLONE_HANDLE, width,
buffer->unlock(); height, format, 1, usage, stride);
native_handle_delete(gralloc_handle);
void* pixels;
if (buffer->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, &pixels)) break;
buffer->unlock();
} while (0);
} }
if (!encode(inputBlock, index, timestamp)) { if (!encode(inputBlock, index, timestamp)) {
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment