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

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

Issue 185403020: Make VEA client of command buffer; move sync. IPC to VDA/VEA::Initialize() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 56683e7a Rebase. Created 6 years, 9 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 | Annotate | Revision Log
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 <dlfcn.h> 5 #include <dlfcn.h>
6 #include <errno.h> 6 #include <errno.h>
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <libdrm/drm_fourcc.h> 8 #include <libdrm/drm_fourcc.h>
9 #include <linux/videodev2.h> 9 #include <linux/videodev2.h>
10 #include <poll.h> 10 #include <poll.h>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 V4L2VideoDecodeAccelerator::PictureRecord::~PictureRecord() {} 153 V4L2VideoDecodeAccelerator::PictureRecord::~PictureRecord() {}
154 154
155 V4L2VideoDecodeAccelerator::V4L2VideoDecodeAccelerator( 155 V4L2VideoDecodeAccelerator::V4L2VideoDecodeAccelerator(
156 EGLDisplay egl_display, 156 EGLDisplay egl_display,
157 const base::WeakPtr<Client>& io_client, 157 const base::WeakPtr<Client>& io_client,
158 const base::Callback<bool(void)>& make_context_current, 158 const base::Callback<bool(void)>& make_context_current,
159 scoped_ptr<V4L2Device> device, 159 scoped_ptr<V4L2Device> device,
160 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy) 160 const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy)
161 : child_message_loop_proxy_(base::MessageLoopProxy::current()), 161 : child_message_loop_proxy_(base::MessageLoopProxy::current()),
162 io_message_loop_proxy_(io_message_loop_proxy), 162 io_message_loop_proxy_(io_message_loop_proxy),
163 weak_this_(base::AsWeakPtr(this)),
164 io_client_(io_client), 163 io_client_(io_client),
165 decoder_thread_("V4L2DecoderThread"), 164 decoder_thread_("V4L2DecoderThread"),
166 decoder_state_(kUninitialized), 165 decoder_state_(kUninitialized),
167 device_(device.Pass()), 166 device_(device.Pass()),
168 decoder_delay_bitstream_buffer_id_(-1), 167 decoder_delay_bitstream_buffer_id_(-1),
169 decoder_current_input_buffer_(-1), 168 decoder_current_input_buffer_(-1),
170 decoder_decode_buffer_tasks_scheduled_(0), 169 decoder_decode_buffer_tasks_scheduled_(0),
171 decoder_frames_at_client_(0), 170 decoder_frames_at_client_(0),
172 decoder_flushing_(false), 171 decoder_flushing_(false),
173 resolution_change_pending_(false), 172 resolution_change_pending_(false),
174 resolution_change_reset_pending_(false), 173 resolution_change_reset_pending_(false),
175 decoder_partial_frame_pending_(false), 174 decoder_partial_frame_pending_(false),
176 input_streamon_(false), 175 input_streamon_(false),
177 input_buffer_queued_count_(0), 176 input_buffer_queued_count_(0),
178 output_streamon_(false), 177 output_streamon_(false),
179 output_buffer_queued_count_(0), 178 output_buffer_queued_count_(0),
180 output_buffer_pixelformat_(0), 179 output_buffer_pixelformat_(0),
181 output_dpb_size_(0), 180 output_dpb_size_(0),
182 picture_clearing_count_(0), 181 picture_clearing_count_(0),
183 pictures_assigned_(false, false), 182 pictures_assigned_(false, false),
184 device_poll_thread_("V4L2DevicePollThread"), 183 device_poll_thread_("V4L2DevicePollThread"),
185 make_context_current_(make_context_current), 184 make_context_current_(make_context_current),
186 egl_display_(egl_display), 185 egl_display_(egl_display),
187 video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN) {} 186 video_profile_(media::VIDEO_CODEC_PROFILE_UNKNOWN),
187 weak_this_factory_(this) {
188 weak_this_ = weak_this_factory_.GetWeakPtr();
189 }
188 190
189 V4L2VideoDecodeAccelerator::~V4L2VideoDecodeAccelerator() { 191 V4L2VideoDecodeAccelerator::~V4L2VideoDecodeAccelerator() {
190 DCHECK(!decoder_thread_.IsRunning()); 192 DCHECK(!decoder_thread_.IsRunning());
191 DCHECK(!device_poll_thread_.IsRunning()); 193 DCHECK(!device_poll_thread_.IsRunning());
192 194
193 DestroyInputBuffers(); 195 DestroyInputBuffers();
194 DestroyOutputBuffers(); 196 DestroyOutputBuffers();
195 197
196 // These maps have members that should be manually destroyed, e.g. file 198 // These maps have members that should be manually destroyed, e.g. file
197 // descriptors, mmap() segments, etc. 199 // descriptors, mmap() segments, etc.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 decoder_h264_parser_.reset(new media::H264Parser()); 284 decoder_h264_parser_.reset(new media::H264Parser());
283 } 285 }
284 286
285 if (!decoder_thread_.Start()) { 287 if (!decoder_thread_.Start()) {
286 DLOG(ERROR) << "Initialize(): decoder thread failed to start"; 288 DLOG(ERROR) << "Initialize(): decoder thread failed to start";
287 NOTIFY_ERROR(PLATFORM_FAILURE); 289 NOTIFY_ERROR(PLATFORM_FAILURE);
288 return false; 290 return false;
289 } 291 }
290 292
291 SetDecoderState(kInitialized); 293 SetDecoderState(kInitialized);
292
293 child_message_loop_proxy_->PostTask(FROM_HERE, base::Bind(
294 &Client::NotifyInitializeDone, client_));
295 return true; 294 return true;
296 } 295 }
297 296
298 void V4L2VideoDecodeAccelerator::Decode( 297 void V4L2VideoDecodeAccelerator::Decode(
299 const media::BitstreamBuffer& bitstream_buffer) { 298 const media::BitstreamBuffer& bitstream_buffer) {
300 DVLOG(1) << "Decode(): input_id=" << bitstream_buffer.id() 299 DVLOG(1) << "Decode(): input_id=" << bitstream_buffer.id()
301 << ", size=" << bitstream_buffer.size(); 300 << ", size=" << bitstream_buffer.size();
302 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 301 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
303 302
304 // DecodeTask() will take care of running a DecodeBufferTask(). 303 // DecodeTask() will take care of running a DecodeBufferTask().
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 420 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
422 &V4L2VideoDecodeAccelerator::ResetTask, base::Unretained(this))); 421 &V4L2VideoDecodeAccelerator::ResetTask, base::Unretained(this)));
423 } 422 }
424 423
425 void V4L2VideoDecodeAccelerator::Destroy() { 424 void V4L2VideoDecodeAccelerator::Destroy() {
426 DVLOG(3) << "Destroy()"; 425 DVLOG(3) << "Destroy()";
427 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); 426 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread());
428 427
429 // We're destroying; cancel all callbacks. 428 // We're destroying; cancel all callbacks.
430 client_ptr_factory_.reset(); 429 client_ptr_factory_.reset();
430 weak_this_factory_.InvalidateWeakPtrs();
431 431
432 // If the decoder thread is running, destroy using posted task. 432 // If the decoder thread is running, destroy using posted task.
433 if (decoder_thread_.IsRunning()) { 433 if (decoder_thread_.IsRunning()) {
434 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 434 decoder_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
435 &V4L2VideoDecodeAccelerator::DestroyTask, base::Unretained(this))); 435 &V4L2VideoDecodeAccelerator::DestroyTask, base::Unretained(this)));
436 pictures_assigned_.Signal(); 436 pictures_assigned_.Signal();
437 // DestroyTask() will cause the decoder_thread_ to flush all tasks. 437 // DestroyTask() will cause the decoder_thread_ to flush all tasks.
438 decoder_thread_.Stop(); 438 decoder_thread_.Stop();
439 } else { 439 } else {
440 // Otherwise, call the destroy task directly. 440 // Otherwise, call the destroy task directly.
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 1919
1920 void V4L2VideoDecodeAccelerator::PictureCleared() { 1920 void V4L2VideoDecodeAccelerator::PictureCleared() {
1921 DVLOG(3) << "PictureCleared(). clearing count=" << picture_clearing_count_; 1921 DVLOG(3) << "PictureCleared(). clearing count=" << picture_clearing_count_;
1922 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); 1922 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current());
1923 DCHECK_GT(picture_clearing_count_, 0); 1923 DCHECK_GT(picture_clearing_count_, 0);
1924 picture_clearing_count_--; 1924 picture_clearing_count_--;
1925 SendPictureReady(); 1925 SendPictureReady();
1926 } 1926 }
1927 1927
1928 } // namespace content 1928 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698