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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 base::Bind(status_cb, PIPELINE_OK)); | 187 base::Bind(status_cb, PIPELINE_OK)); |
188 } | 188 } |
189 | 189 |
190 void GpuVideoDecoder::SetVDA(VideoDecodeAccelerator* vda) { | 190 void GpuVideoDecoder::SetVDA(VideoDecodeAccelerator* vda) { |
191 DCHECK(vda_loop_proxy_->BelongsToCurrentThread()); | 191 DCHECK(vda_loop_proxy_->BelongsToCurrentThread()); |
192 DCHECK(!vda_.get()); | 192 DCHECK(!vda_.get()); |
193 vda_.reset(vda); | 193 vda_.reset(vda); |
194 weak_vda_ = vda->AsWeakPtr(); | 194 weak_vda_ = vda->AsWeakPtr(); |
195 } | 195 } |
196 | 196 |
197 void GpuVideoDecoder::DestroyTextures() { | |
198 // It's safe to delete textures here, as the VDA should be keeping its own | |
Ami GONE FROM CHROMIUM
2012/10/17 00:48:10
The explanation you give here, in the CL descripti
| |
199 // references to the textures. This happens commonly via binding them | |
200 // to EGLImages or XPixmaps, which ups refcounts on textures in the graphics | |
201 // drivers. | |
202 for (std::map<int32, PictureBuffer>::iterator it = | |
203 picture_buffers_in_decoder_.begin(); | |
204 it != picture_buffers_in_decoder_.end(); ++it) { | |
205 factories_->DeleteTexture(it->second.texture_id()); | |
206 } | |
207 picture_buffers_in_decoder_.clear(); | |
208 } | |
209 | |
197 void GpuVideoDecoder::DestroyVDA() { | 210 void GpuVideoDecoder::DestroyVDA() { |
198 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); | 211 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); |
199 VideoDecodeAccelerator* vda ALLOW_UNUSED = vda_.release(); | 212 VideoDecodeAccelerator* vda ALLOW_UNUSED = vda_.release(); |
200 // Tricky: |this| needs to stay alive until after VDA::Destroy is actually | 213 // Tricky: |this| needs to stay alive until after VDA::Destroy is actually |
201 // called, not just posted, so we take an artificial ref to |this| and release | 214 // called, not just posted, so we take an artificial ref to |this| and release |
202 // it as |reply| after VDA::Destroy() returns. | 215 // it as |reply| after VDA::Destroy() returns. |
203 AddRef(); | 216 AddRef(); |
204 vda_loop_proxy_->PostTaskAndReply( | 217 vda_loop_proxy_->PostTaskAndReply( |
205 FROM_HERE, | 218 FROM_HERE, |
206 base::Bind(&VideoDecodeAccelerator::Destroy, weak_vda_), | 219 base::Bind(&VideoDecodeAccelerator::Destroy, weak_vda_), |
207 base::Bind(&GpuVideoDecoder::Release, this)); | 220 base::Bind(&GpuVideoDecoder::Release, this)); |
221 | |
222 DestroyTextures(); | |
208 } | 223 } |
209 | 224 |
210 void GpuVideoDecoder::Read(const ReadCB& read_cb) { | 225 void GpuVideoDecoder::Read(const ReadCB& read_cb) { |
211 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { | 226 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { |
212 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 227 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
213 &GpuVideoDecoder::Read, this, read_cb)); | 228 &GpuVideoDecoder::Read, this, read_cb)); |
214 return; | 229 return; |
215 } | 230 } |
216 | 231 |
217 if (error_occured_) { | 232 if (error_occured_) { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 available_shm_segments_[i]->shm->Close(); | 536 available_shm_segments_[i]->shm->Close(); |
522 delete available_shm_segments_[i]; | 537 delete available_shm_segments_[i]; |
523 } | 538 } |
524 available_shm_segments_.clear(); | 539 available_shm_segments_.clear(); |
525 for (std::map<int32, BufferPair>::iterator it = | 540 for (std::map<int32, BufferPair>::iterator it = |
526 bitstream_buffers_in_decoder_.begin(); | 541 bitstream_buffers_in_decoder_.begin(); |
527 it != bitstream_buffers_in_decoder_.end(); ++it) { | 542 it != bitstream_buffers_in_decoder_.end(); ++it) { |
528 it->second.shm_buffer->shm->Close(); | 543 it->second.shm_buffer->shm->Close(); |
529 } | 544 } |
530 bitstream_buffers_in_decoder_.clear(); | 545 bitstream_buffers_in_decoder_.clear(); |
546 | |
547 DestroyTextures(); | |
531 } | 548 } |
532 | 549 |
533 void GpuVideoDecoder::EnsureDemuxOrDecode() { | 550 void GpuVideoDecoder::EnsureDemuxOrDecode() { |
534 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); | 551 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); |
535 if (demuxer_read_in_progress_) | 552 if (demuxer_read_in_progress_) |
536 return; | 553 return; |
537 demuxer_read_in_progress_ = true; | 554 demuxer_read_in_progress_ = true; |
538 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 555 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
539 &DemuxerStream::Read, demuxer_stream_.get(), | 556 &DemuxerStream::Read, demuxer_stream_.get(), |
540 base::Bind(&GpuVideoDecoder::RequestBufferDecode, this))); | 557 base::Bind(&GpuVideoDecoder::RequestBufferDecode, this))); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
588 | 605 |
589 error_occured_ = true; | 606 error_occured_ = true; |
590 | 607 |
591 if (!pending_read_cb_.is_null()) { | 608 if (!pending_read_cb_.is_null()) { |
592 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); | 609 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); |
593 return; | 610 return; |
594 } | 611 } |
595 } | 612 } |
596 | 613 |
597 } // namespace media | 614 } // namespace media |
OLD | NEW |