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

Side by Side Diff: media/filters/gpu_video_decoder.cc

Issue 10918172: Remove VideoDecoder::PrepareForShutdownHack() and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah Created 8 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | media/filters/video_renderer_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/filters/gpu_video_decoder.h" 5 #include "media/filters/gpu_video_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 const scoped_refptr<Factories>& factories) 49 const scoped_refptr<Factories>& factories)
50 : message_loop_factory_cb_(message_loop_factory_cb), 50 : message_loop_factory_cb_(message_loop_factory_cb),
51 gvd_loop_proxy_(NULL), 51 gvd_loop_proxy_(NULL),
52 vda_loop_proxy_(vda_loop_proxy), 52 vda_loop_proxy_(vda_loop_proxy),
53 factories_(factories), 53 factories_(factories),
54 state_(kNormal), 54 state_(kNormal),
55 demuxer_read_in_progress_(false), 55 demuxer_read_in_progress_(false),
56 decoder_texture_target_(0), 56 decoder_texture_target_(0),
57 next_picture_buffer_id_(0), 57 next_picture_buffer_id_(0),
58 next_bitstream_buffer_id_(0), 58 next_bitstream_buffer_id_(0),
59 shutting_down_(false),
60 error_occured_(false) { 59 error_occured_(false) {
61 DCHECK(!message_loop_factory_cb_.is_null()); 60 DCHECK(!message_loop_factory_cb_.is_null());
62 DCHECK(factories_); 61 DCHECK(factories_);
63 } 62 }
64 63
65 void GpuVideoDecoder::Reset(const base::Closure& closure) { 64 void GpuVideoDecoder::Reset(const base::Closure& closure) {
66 if (!gvd_loop_proxy_->BelongsToCurrentThread() || 65 if (!gvd_loop_proxy_->BelongsToCurrentThread() ||
67 state_ == kDrainingDecoder) { 66 state_ == kDrainingDecoder) {
68 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( 67 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
69 &GpuVideoDecoder::Reset, this, closure)); 68 &GpuVideoDecoder::Reset, this, closure));
70 return; 69 return;
71 } 70 }
72 71
73 // Throw away any already-decoded, not-yet-delivered frames. 72 // Throw away any already-decoded, not-yet-delivered frames.
74 ready_video_frames_.clear(); 73 ready_video_frames_.clear();
75 74
76 if (!vda_.get()) { 75 if (!vda_.get()) {
77 closure.Run(); 76 closure.Run();
78 return; 77 return;
79 } 78 }
80 79
81 DCHECK(pending_reset_cb_.is_null()); 80 DCHECK(pending_reset_cb_.is_null());
82 DCHECK(!closure.is_null()); 81 DCHECK(!closure.is_null());
83 82
84 // VideoRendererBase::Flush() can't complete while it has a pending read to 83 // VideoRendererBase::Flush() can't complete while it has a pending read to
85 // us, so we fulfill such a read here. 84 // us, so we fulfill such a read here.
86 if (!pending_read_cb_.is_null()) 85 if (!pending_read_cb_.is_null())
87 EnqueueFrameAndTriggerFrameDelivery(VideoFrame::CreateEmptyFrame()); 86 EnqueueFrameAndTriggerFrameDelivery(VideoFrame::CreateEmptyFrame());
88 87
89 if (shutting_down_) { 88 pending_reset_cb_ = closure;
90 // Immediately fire the callback instead of waiting for the reset to
91 // complete (which will happen after PipelineImpl::Stop() completes).
92 gvd_loop_proxy_->PostTask(FROM_HERE, closure);
93 } else {
94 pending_reset_cb_ = closure;
95 }
96
97 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind( 89 vda_loop_proxy_->PostTask(FROM_HERE, base::Bind(
98 &VideoDecodeAccelerator::Reset, weak_vda_)); 90 &VideoDecodeAccelerator::Reset, weak_vda_));
99 } 91 }
100 92
101 void GpuVideoDecoder::Stop(const base::Closure& closure) { 93 void GpuVideoDecoder::Stop(const base::Closure& closure) {
102 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { 94 if (!gvd_loop_proxy_->BelongsToCurrentThread()) {
103 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( 95 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
104 &GpuVideoDecoder::Stop, this, closure)); 96 &GpuVideoDecoder::Stop, this, closure));
105 return; 97 return;
106 } 98 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 *natural_size = it->natural_size; 294 *natural_size = it->natural_size;
303 return; 295 return;
304 } 296 }
305 NOTREACHED() << "Missing bitstreambuffer id: " << id; 297 NOTREACHED() << "Missing bitstreambuffer id: " << id;
306 } 298 }
307 299
308 bool GpuVideoDecoder::HasAlpha() const { 300 bool GpuVideoDecoder::HasAlpha() const {
309 return true; 301 return true;
310 } 302 }
311 303
312 void GpuVideoDecoder::PrepareForShutdownHack() {
313 if (!gvd_loop_proxy_->BelongsToCurrentThread()) {
314 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
315 &GpuVideoDecoder::PrepareForShutdownHack, this));
316 return;
317 }
318 shutting_down_ = true;
319 }
320
321 void GpuVideoDecoder::NotifyInitializeDone() { 304 void GpuVideoDecoder::NotifyInitializeDone() {
322 NOTREACHED() << "GpuVideoDecodeAcceleratorHost::Initialize is synchronous!"; 305 NOTREACHED() << "GpuVideoDecodeAcceleratorHost::Initialize is synchronous!";
323 } 306 }
324 307
325 void GpuVideoDecoder::ProvidePictureBuffers(uint32 count, 308 void GpuVideoDecoder::ProvidePictureBuffers(uint32 count,
326 const gfx::Size& size, 309 const gfx::Size& size,
327 uint32 texture_target) { 310 uint32 texture_target) {
328 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { 311 if (!gvd_loop_proxy_->BelongsToCurrentThread()) {
329 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( 312 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
330 &GpuVideoDecoder::ProvidePictureBuffers, this, count, size, 313 &GpuVideoDecoder::ProvidePictureBuffers, this, count, size,
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 545
563 error_occured_ = true; 546 error_occured_ = true;
564 547
565 if (!pending_read_cb_.is_null()) { 548 if (!pending_read_cb_.is_null()) {
566 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); 549 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL);
567 return; 550 return;
568 } 551 }
569 } 552 }
570 553
571 } // namespace media 554 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | media/filters/video_renderer_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698