Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: media/gpu/v4l2_video_decode_accelerator.cc

Issue 2337913004: V4L2VideoDecodeAccelerator: fix frame returned after processor destroys. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/gpu/v4l2_video_decode_accelerator.h" 5 #include "media/gpu/v4l2_video_decode_accelerator.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <linux/videodev2.h> 10 #include <linux/videodev2.h>
11 #include <poll.h> 11 #include <poll.h>
12 #include <string.h> 12 #include <string.h>
13 #include <sys/eventfd.h> 13 #include <sys/eventfd.h>
14 #include <sys/ioctl.h> 14 #include <sys/ioctl.h>
15 #include <sys/mman.h> 15 #include <sys/mman.h>
16 16
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
20 #include "base/numerics/safe_conversions.h" 20 #include "base/numerics/safe_conversions.h"
21 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
22 #include "base/threading/thread_task_runner_handle.h" 22 #include "base/threading/thread_task_runner_handle.h"
23 #include "base/trace_event/trace_event.h" 23 #include "base/trace_event/trace_event.h"
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 #include "media/base/bind_to_current_loop.h"
26 #include "media/base/media_switches.h" 25 #include "media/base/media_switches.h"
27 #include "media/filters/h264_parser.h" 26 #include "media/filters/h264_parser.h"
28 #include "media/gpu/shared_memory_region.h" 27 #include "media/gpu/shared_memory_region.h"
29 #include "ui/gfx/geometry/rect.h" 28 #include "ui/gfx/geometry/rect.h"
30 #include "ui/gl/gl_context.h" 29 #include "ui/gl/gl_context.h"
31 #include "ui/gl/scoped_binders.h" 30 #include "ui/gl/scoped_binders.h"
32 31
33 #define LOGF(level) LOG(level) << __FUNCTION__ << "(): " 32 #define LOGF(level) LOG(level) << __FUNCTION__ << "(): "
34 #define DLOGF(level) DLOG(level) << __FUNCTION__ << "(): " 33 #define DLOGF(level) DLOG(level) << __FUNCTION__ << "(): "
35 #define DVLOGF(level) DVLOG(level) << __FUNCTION__ << "(): " 34 #define DVLOGF(level) DVLOG(level) << __FUNCTION__ << "(): "
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 image_processor_bitstream_buffer_ids_.push(bitstream_buffer_id); 1219 image_processor_bitstream_buffer_ids_.push(bitstream_buffer_id);
1221 std::vector<int> fds; 1220 std::vector<int> fds;
1222 for (auto& fd : output_record.fds) { 1221 for (auto& fd : output_record.fds) {
1223 fds.push_back(fd.get()); 1222 fds.push_back(fd.get());
1224 } 1223 }
1225 scoped_refptr<VideoFrame> frame = VideoFrame::WrapExternalDmabufs( 1224 scoped_refptr<VideoFrame> frame = VideoFrame::WrapExternalDmabufs(
1226 V4L2Device::V4L2PixFmtToVideoPixelFormat(output_format_fourcc_), 1225 V4L2Device::V4L2PixFmtToVideoPixelFormat(output_format_fourcc_),
1227 coded_size_, gfx::Rect(visible_size_), visible_size_, fds, 1226 coded_size_, gfx::Rect(visible_size_), visible_size_, fds,
1228 base::TimeDelta()); 1227 base::TimeDelta());
1229 // Unretained is safe because |this| owns image processor and there will 1228 // Unretained is safe because |this| owns image processor and there will
1230 // be no callbacks after processor destroys. Also, this class ensures it 1229 // be no callbacks after processor destroys.
1231 // is safe to post a task from child thread to decoder thread using
1232 // Unretained.
1233 image_processor_->Process( 1230 image_processor_->Process(
1234 frame, dqbuf.index, 1231 frame, dqbuf.index,
1235 BindToCurrentLoop( 1232 base::Bind(&V4L2VideoDecodeAccelerator::FrameProcessed,
1236 base::Bind(&V4L2VideoDecodeAccelerator::FrameProcessed, 1233 base::Unretained(this), bitstream_buffer_id));
1237 base::Unretained(this), bitstream_buffer_id)));
1238 } else { 1234 } else {
1239 output_record.state = kAtClient; 1235 output_record.state = kAtClient;
1240 decoder_frames_at_client_++; 1236 decoder_frames_at_client_++;
1241 const Picture picture(output_record.picture_id, bitstream_buffer_id, 1237 const Picture picture(output_record.picture_id, bitstream_buffer_id,
1242 gfx::Rect(visible_size_), false); 1238 gfx::Rect(visible_size_), false);
1243 pending_picture_ready_.push( 1239 pending_picture_ready_.push(
1244 PictureRecord(output_record.cleared, picture)); 1240 PictureRecord(output_record.cleared, picture));
1245 SendPictureReady(); 1241 SendPictureReady();
1246 output_record.cleared = true; 1242 output_record.cleared = true;
1247 } 1243 }
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 Enqueue(); 2285 Enqueue();
2290 } 2286 }
2291 } 2287 }
2292 2288
2293 void V4L2VideoDecodeAccelerator::ImageProcessorError() { 2289 void V4L2VideoDecodeAccelerator::ImageProcessorError() {
2294 LOGF(ERROR) << "Image processor error"; 2290 LOGF(ERROR) << "Image processor error";
2295 NOTIFY_ERROR(PLATFORM_FAILURE); 2291 NOTIFY_ERROR(PLATFORM_FAILURE);
2296 } 2292 }
2297 2293
2298 } // namespace media 2294 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698