Commit 233a6909 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/chromeos: Duplicate fds of VideoFrame in CreateGpuMemoryBufferHandle()

VideoFrame might not have the same number of fds as the number of
planes. We duplicate the fd of the last plane of the VideoFrame
in CreateGpuMemoryBufferHandle() until the number of fds is the
same as the number of planes.

Bug: 1011281
Test: VDA test on hana
Change-Id: I6738e74ddc43f6c9457ba37beb44ee656866a633
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1978296Reviewed-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726698}
parent 90cb292a
......@@ -132,17 +132,24 @@ gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferHandle(
break;
case VideoFrame::STORAGE_DMABUFS: {
const size_t num_planes = VideoFrame::NumPlanes(video_frame->format());
if (num_planes != video_frame->DmabufFds().size()) {
VLOGF(1) << "The number of fds =" << video_frame->DmabufFds().size()
<< " is different from the number of planes =" << num_planes;
return handle;
std::vector<base::ScopedFD> duped_fds =
DuplicateFDs(video_frame->DmabufFds());
// TODO(crbug.com/1036174): Replace this duplication with a check.
// Duplicate the fd of the last plane until the number of fds are the same
// as the number of planes.
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;
}
duped_fds.emplace_back(duped_fd);
}
handle.type = gfx::NATIVE_PIXMAP;
DCHECK_EQ(video_frame->layout().planes().size(), num_planes);
handle.native_pixmap_handle.modifier = video_frame->layout().modifier();
std::vector<base::ScopedFD> duped_fds =
DuplicateFDs(video_frame->DmabufFds());
for (size_t i = 0; i < num_planes; ++i) {
const auto& plane = video_frame->layout().planes()[i];
handle.native_pixmap_handle.planes.emplace_back(
......
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