OLD | NEW |
---|---|
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 MessageLoop* vda_loop, | 46 MessageLoop* vda_loop, |
47 const scoped_refptr<Factories>& factories) | 47 const scoped_refptr<Factories>& factories) |
48 : gvd_loop_proxy_(message_loop->message_loop_proxy()), | 48 : gvd_loop_proxy_(message_loop->message_loop_proxy()), |
49 vda_loop_proxy_(vda_loop->message_loop_proxy()), | 49 vda_loop_proxy_(vda_loop->message_loop_proxy()), |
50 factories_(factories), | 50 factories_(factories), |
51 state_(kNormal), | 51 state_(kNormal), |
52 demuxer_read_in_progress_(false), | 52 demuxer_read_in_progress_(false), |
53 decoder_texture_target_(0), | 53 decoder_texture_target_(0), |
54 next_picture_buffer_id_(0), | 54 next_picture_buffer_id_(0), |
55 next_bitstream_buffer_id_(0), | 55 next_bitstream_buffer_id_(0), |
56 shutting_down_(false) { | 56 shutting_down_(false), |
57 pending_error_count_(0) { | |
57 DCHECK(gvd_loop_proxy_ && factories_); | 58 DCHECK(gvd_loop_proxy_ && factories_); |
58 } | 59 } |
59 | 60 |
60 GpuVideoDecoder::~GpuVideoDecoder() { | 61 GpuVideoDecoder::~GpuVideoDecoder() { |
61 DCHECK(!vda_); // Stop should have been already called. | 62 DCHECK(!vda_); // Stop should have been already called. |
62 DCHECK(pending_read_cb_.is_null()); | 63 DCHECK(pending_read_cb_.is_null()); |
63 for (size_t i = 0; i < available_shm_segments_.size(); ++i) { | 64 for (size_t i = 0; i < available_shm_segments_.size(); ++i) { |
64 available_shm_segments_[i]->shm->Close(); | 65 available_shm_segments_[i]->shm->Close(); |
65 delete available_shm_segments_[i]; | 66 delete available_shm_segments_[i]; |
66 } | 67 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 status_cb.Run(PIPELINE_OK); | 186 status_cb.Run(PIPELINE_OK); |
186 } | 187 } |
187 | 188 |
188 void GpuVideoDecoder::Read(const ReadCB& read_cb) { | 189 void GpuVideoDecoder::Read(const ReadCB& read_cb) { |
189 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { | 190 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { |
190 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 191 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
191 &GpuVideoDecoder::Read, this, read_cb)); | 192 &GpuVideoDecoder::Read, this, read_cb)); |
192 return; | 193 return; |
193 } | 194 } |
194 | 195 |
196 CHECK_GE(pending_error_count_, 0); | |
Ami GONE FROM CHROMIUM
2012/04/27 16:49:14
unnecessary, IMO
xhwang
2012/04/27 23:22:30
Done.
| |
197 if (pending_error_count_ > 0) { | |
198 read_cb.Run(NULL, kDecodeError); | |
199 pending_error_count_--; | |
scherkus (not reviewing)
2012/04/27 18:27:56
fischman: is there a case where we'd report an err
Ami GONE FROM CHROMIUM
2012/04/27 18:31:16
No; pending_error_count_ only goes positive when N
xhwang
2012/04/27 23:22:30
Done.
xhwang
2012/04/27 23:22:30
Done.
| |
200 return; | |
201 } | |
202 | |
195 if (!vda_) { | 203 if (!vda_) { |
196 read_cb.Run(VideoFrame::CreateEmptyFrame()); | 204 read_cb.Run(VideoFrame::CreateEmptyFrame(), kOk); |
197 return; | 205 return; |
198 } | 206 } |
199 | 207 |
200 DCHECK(pending_reset_cb_.is_null()); | 208 DCHECK(pending_reset_cb_.is_null()); |
201 DCHECK(pending_read_cb_.is_null()); | 209 DCHECK(pending_read_cb_.is_null()); |
202 pending_read_cb_ = read_cb; | 210 pending_read_cb_ = read_cb; |
203 | 211 |
204 if (!ready_video_frames_.empty()) { | 212 if (!ready_video_frames_.empty()) { |
205 EnqueueFrameAndTriggerFrameDelivery(NULL); | 213 EnqueueFrameAndTriggerFrameDelivery(NULL); |
206 return; | 214 return; |
(...skipping 19 matching lines...) Expand all Loading... | |
226 &GpuVideoDecoder::RequestBufferDecode, this, buffer)); | 234 &GpuVideoDecoder::RequestBufferDecode, this, buffer)); |
227 return; | 235 return; |
228 } | 236 } |
229 demuxer_read_in_progress_ = false; | 237 demuxer_read_in_progress_ = false; |
230 | 238 |
231 if (!buffer) { | 239 if (!buffer) { |
232 if (pending_read_cb_.is_null()) | 240 if (pending_read_cb_.is_null()) |
233 return; | 241 return; |
234 | 242 |
235 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 243 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
236 pending_read_cb_, scoped_refptr<VideoFrame>())); | 244 pending_read_cb_, scoped_refptr<VideoFrame>(), kOk)); |
237 pending_read_cb_.Reset(); | 245 pending_read_cb_.Reset(); |
238 return; | 246 return; |
239 } | 247 } |
240 | 248 |
241 if (!vda_) { | 249 if (!vda_) { |
242 EnqueueFrameAndTriggerFrameDelivery(VideoFrame::CreateEmptyFrame()); | 250 EnqueueFrameAndTriggerFrameDelivery(VideoFrame::CreateEmptyFrame()); |
243 return; | 251 return; |
244 } | 252 } |
245 | 253 |
246 if (buffer->IsEndOfStream()) { | 254 if (buffer->IsEndOfStream()) { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 | 416 |
409 if (frame) | 417 if (frame) |
410 ready_video_frames_.push_back(frame); | 418 ready_video_frames_.push_back(frame); |
411 else | 419 else |
412 DCHECK(!ready_video_frames_.empty()); | 420 DCHECK(!ready_video_frames_.empty()); |
413 | 421 |
414 if (pending_read_cb_.is_null()) | 422 if (pending_read_cb_.is_null()) |
415 return; | 423 return; |
416 | 424 |
417 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 425 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
418 pending_read_cb_, ready_video_frames_.front())); | 426 pending_read_cb_, ready_video_frames_.front(), kOk)); |
419 pending_read_cb_.Reset(); | 427 pending_read_cb_.Reset(); |
420 ready_video_frames_.pop_front(); | 428 ready_video_frames_.pop_front(); |
421 } | 429 } |
422 | 430 |
423 void GpuVideoDecoder::ReusePictureBuffer(int64 picture_buffer_id) { | 431 void GpuVideoDecoder::ReusePictureBuffer(int64 picture_buffer_id) { |
424 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { | 432 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { |
425 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 433 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
426 &GpuVideoDecoder::ReusePictureBuffer, this, picture_buffer_id)); | 434 &GpuVideoDecoder::ReusePictureBuffer, this, picture_buffer_id)); |
427 return; | 435 return; |
428 } | 436 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
529 void GpuVideoDecoder::NotifyError(media::VideoDecodeAccelerator::Error error) { | 537 void GpuVideoDecoder::NotifyError(media::VideoDecodeAccelerator::Error error) { |
530 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { | 538 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { |
531 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 539 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
532 &GpuVideoDecoder::NotifyError, this, error)); | 540 &GpuVideoDecoder::NotifyError, this, error)); |
533 return; | 541 return; |
534 } | 542 } |
535 if (!vda_) | 543 if (!vda_) |
536 return; | 544 return; |
537 vda_ = NULL; | 545 vda_ = NULL; |
538 DLOG(ERROR) << "VDA Error: " << error; | 546 DLOG(ERROR) << "VDA Error: " << error; |
539 if (host()) | 547 |
540 host()->SetError(PIPELINE_ERROR_DECODE); | 548 if (!pending_read_cb_.is_null()) { |
549 base::ResetAndReturn(&pending_read_cb_).Run(NULL, kDecodeError); | |
550 return; | |
551 } | |
552 | |
553 CHECK_GE(pending_error_count_, 0); | |
Ami GONE FROM CHROMIUM
2012/04/27 16:49:14
unnecessary.
xhwang
2012/04/27 23:22:30
Done.
| |
554 pending_error_count_++; | |
541 } | 555 } |
542 | 556 |
543 } // namespace media | 557 } // namespace media |
OLD | NEW |