Commit 5dadc60b authored by Andres Calderon Jaramillo's avatar Andres Calderon Jaramillo Committed by Commit Bot

media: CHECK on CreateGMBHandle() dup() failure.

This CL adds some CHECKs to assert that duping dma-buf FDs is
successful. See referenced bug for more details.

Bug: 1097956
Test: None
Change-Id: I766a8729cf34635892c69b297f4b09b2d8a9c471
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2366293Reviewed-by: default avatarMiguel Casas <mcasas@chromium.org>
Reviewed-by: default avatarJorge Lucangeli Obes <jorgelo@chromium.org>
Commit-Queue: Andres Calderon Jaramillo <andrescj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800729}
parent 3424c6a0
......@@ -176,6 +176,11 @@ gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferHandle(
switch (video_frame->storage_type()) {
case VideoFrame::STORAGE_GPU_MEMORY_BUFFER:
handle = video_frame->GetGpuMemoryBuffer()->CloneHandle();
// TODO(crbug.com/1097956): handle a failure gracefully.
CHECK_EQ(handle.type, gfx::NATIVE_PIXMAP)
<< "The cloned handle has an unexpected type: " << handle.type;
CHECK(!handle.native_pixmap_handle.planes.empty())
<< "The cloned handle has no planes";
break;
case VideoFrame::STORAGE_DMABUFS: {
const size_t num_planes = VideoFrame::NumPlanes(video_frame->format());
......@@ -187,10 +192,8 @@ gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferHandle(
while (num_planes != duped_fds.size()) {
int duped_fd = -1;
duped_fd = HANDLE_EINTR(dup(duped_fds.back().get()));
if (duped_fd == -1) {
DLOG(ERROR) << "Failed duplicating dmabuf fd";
return handle;
}
// TODO(crbug.com/1097956): handle a failure gracefully.
PCHECK(duped_fd >= 0) << "Failed duplicating a dma-buf fd";
duped_fds.emplace_back(duped_fd);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment