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 | |
220 DestroyTextures(); | 218 DestroyTextures(); |
221 #endif | |
222 } | 219 } |
223 | 220 |
224 void GpuVideoDecoder::Read(const ReadCB& read_cb) { | 221 void GpuVideoDecoder::Read(const ReadCB& read_cb) { |
225 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { | 222 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { |
226 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 223 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
227 &GpuVideoDecoder::Read, this, read_cb)); | 224 &GpuVideoDecoder::Read, this, read_cb)); |
228 return; | 225 return; |
229 } | 226 } |
230 | 227 |
231 if (error_occured_) { | 228 if (error_occured_) { |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 delete available_shm_segments_[i]; | 533 delete available_shm_segments_[i]; |
537 } | 534 } |
538 available_shm_segments_.clear(); | 535 available_shm_segments_.clear(); |
539 for (std::map<int32, BufferPair>::iterator it = | 536 for (std::map<int32, BufferPair>::iterator it = |
540 bitstream_buffers_in_decoder_.begin(); | 537 bitstream_buffers_in_decoder_.begin(); |
541 it != bitstream_buffers_in_decoder_.end(); ++it) { | 538 it != bitstream_buffers_in_decoder_.end(); ++it) { |
542 it->second.shm_buffer->shm->Close(); | 539 it->second.shm_buffer->shm->Close(); |
543 } | 540 } |
544 bitstream_buffers_in_decoder_.clear(); | 541 bitstream_buffers_in_decoder_.clear(); |
545 | 542 |
546 // TODO(posciak): enable for all. | |
547 #ifdef OS_CHROMEOS | |
548 DestroyTextures(); | 543 DestroyTextures(); |
549 #endif | |
550 } | 544 } |
551 | 545 |
552 void GpuVideoDecoder::EnsureDemuxOrDecode() { | 546 void GpuVideoDecoder::EnsureDemuxOrDecode() { |
553 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); | 547 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); |
554 if (demuxer_read_in_progress_) | 548 if (demuxer_read_in_progress_) |
555 return; | 549 return; |
556 demuxer_read_in_progress_ = true; | 550 demuxer_read_in_progress_ = true; |
557 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 551 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
558 &DemuxerStream::Read, demuxer_stream_.get(), | 552 &DemuxerStream::Read, demuxer_stream_.get(), |
559 base::Bind(&GpuVideoDecoder::RequestBufferDecode, this))); | 553 base::Bind(&GpuVideoDecoder::RequestBufferDecode, this))); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 | 601 |
608 error_occured_ = true; | 602 error_occured_ = true; |
609 | 603 |
610 if (!pending_read_cb_.is_null()) { | 604 if (!pending_read_cb_.is_null()) { |
611 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); | 605 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); |
612 return; | 606 return; |
613 } | 607 } |
614 } | 608 } |
615 | 609 |
616 } // namespace media | 610 } // namespace media |
OLD | NEW |