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/cpu.h" | 9 #include "base/cpu.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 VideoDecodeAccelerator* vda ALLOW_UNUSED = vda_.release(); | 208 VideoDecodeAccelerator* vda ALLOW_UNUSED = vda_.release(); |
209 // Tricky: |this| needs to stay alive until after VDA::Destroy is actually | 209 // Tricky: |this| needs to stay alive until after VDA::Destroy is actually |
210 // called, not just posted, so we take an artificial ref to |this| and release | 210 // called, not just posted, so we take an artificial ref to |this| and release |
211 // it as |reply| after VDA::Destroy() returns. | 211 // it as |reply| after VDA::Destroy() returns. |
212 AddRef(); | 212 AddRef(); |
213 vda_loop_proxy_->PostTaskAndReply( | 213 vda_loop_proxy_->PostTaskAndReply( |
214 FROM_HERE, | 214 FROM_HERE, |
215 base::Bind(&VideoDecodeAccelerator::Destroy, weak_vda_), | 215 base::Bind(&VideoDecodeAccelerator::Destroy, weak_vda_), |
216 base::Bind(&GpuVideoDecoder::Release, this)); | 216 base::Bind(&GpuVideoDecoder::Release, this)); |
217 | 217 |
| 218 // TODO(posciak): enable for all. |
| 219 #ifdef OS_CHROMEOS |
218 DestroyTextures(); | 220 DestroyTextures(); |
| 221 #endif |
219 } | 222 } |
220 | 223 |
221 void GpuVideoDecoder::Read(const ReadCB& read_cb) { | 224 void GpuVideoDecoder::Read(const ReadCB& read_cb) { |
222 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { | 225 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { |
223 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 226 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
224 &GpuVideoDecoder::Read, this, read_cb)); | 227 &GpuVideoDecoder::Read, this, read_cb)); |
225 return; | 228 return; |
226 } | 229 } |
227 | 230 |
228 if (error_occured_) { | 231 if (error_occured_) { |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 delete available_shm_segments_[i]; | 536 delete available_shm_segments_[i]; |
534 } | 537 } |
535 available_shm_segments_.clear(); | 538 available_shm_segments_.clear(); |
536 for (std::map<int32, BufferPair>::iterator it = | 539 for (std::map<int32, BufferPair>::iterator it = |
537 bitstream_buffers_in_decoder_.begin(); | 540 bitstream_buffers_in_decoder_.begin(); |
538 it != bitstream_buffers_in_decoder_.end(); ++it) { | 541 it != bitstream_buffers_in_decoder_.end(); ++it) { |
539 it->second.shm_buffer->shm->Close(); | 542 it->second.shm_buffer->shm->Close(); |
540 } | 543 } |
541 bitstream_buffers_in_decoder_.clear(); | 544 bitstream_buffers_in_decoder_.clear(); |
542 | 545 |
| 546 // TODO(posciak): enable for all. |
| 547 #ifdef OS_CHROMEOS |
543 DestroyTextures(); | 548 DestroyTextures(); |
| 549 #endif |
544 } | 550 } |
545 | 551 |
546 void GpuVideoDecoder::EnsureDemuxOrDecode() { | 552 void GpuVideoDecoder::EnsureDemuxOrDecode() { |
547 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); | 553 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); |
548 if (demuxer_read_in_progress_) | 554 if (demuxer_read_in_progress_) |
549 return; | 555 return; |
550 demuxer_read_in_progress_ = true; | 556 demuxer_read_in_progress_ = true; |
551 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 557 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
552 &DemuxerStream::Read, demuxer_stream_.get(), | 558 &DemuxerStream::Read, demuxer_stream_.get(), |
553 base::Bind(&GpuVideoDecoder::RequestBufferDecode, this))); | 559 base::Bind(&GpuVideoDecoder::RequestBufferDecode, this))); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 607 |
602 error_occured_ = true; | 608 error_occured_ = true; |
603 | 609 |
604 if (!pending_read_cb_.is_null()) { | 610 if (!pending_read_cb_.is_null()) { |
605 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); | 611 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); |
606 return; | 612 return; |
607 } | 613 } |
608 } | 614 } |
609 | 615 |
610 } // namespace media | 616 } // namespace media |
OLD | NEW |