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

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

Issue 11189027: GVD: DestroyTextures() when destroying. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ~ Created 8 years, 2 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') | no next file » | 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/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
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 for (std::map<int32, PictureBuffer>::iterator it =
199 picture_buffers_in_decoder_.begin();
200 it != picture_buffers_in_decoder_.end(); ++it) {
201 factories_->DeleteTexture(it->second.texture_id());
202 }
203 picture_buffers_in_decoder_.clear();
204 }
205
197 void GpuVideoDecoder::DestroyVDA() { 206 void GpuVideoDecoder::DestroyVDA() {
198 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); 207 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread());
199 VideoDecodeAccelerator* vda ALLOW_UNUSED = vda_.release(); 208 VideoDecodeAccelerator* vda ALLOW_UNUSED = vda_.release();
200 // 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
201 // 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
202 // it as |reply| after VDA::Destroy() returns. 211 // it as |reply| after VDA::Destroy() returns.
203 AddRef(); 212 AddRef();
204 vda_loop_proxy_->PostTaskAndReply( 213 vda_loop_proxy_->PostTaskAndReply(
205 FROM_HERE, 214 FROM_HERE,
206 base::Bind(&VideoDecodeAccelerator::Destroy, weak_vda_), 215 base::Bind(&VideoDecodeAccelerator::Destroy, weak_vda_),
207 base::Bind(&GpuVideoDecoder::Release, this)); 216 base::Bind(&GpuVideoDecoder::Release, this));
217
218 DestroyTextures();
208 } 219 }
209 220
210 void GpuVideoDecoder::Read(const ReadCB& read_cb) { 221 void GpuVideoDecoder::Read(const ReadCB& read_cb) {
211 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { 222 if (!gvd_loop_proxy_->BelongsToCurrentThread()) {
212 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( 223 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
213 &GpuVideoDecoder::Read, this, read_cb)); 224 &GpuVideoDecoder::Read, this, read_cb));
214 return; 225 return;
215 } 226 }
216 227
217 if (error_occured_) { 228 if (error_occured_) {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 available_shm_segments_[i]->shm->Close(); 532 available_shm_segments_[i]->shm->Close();
522 delete available_shm_segments_[i]; 533 delete available_shm_segments_[i];
523 } 534 }
524 available_shm_segments_.clear(); 535 available_shm_segments_.clear();
525 for (std::map<int32, BufferPair>::iterator it = 536 for (std::map<int32, BufferPair>::iterator it =
526 bitstream_buffers_in_decoder_.begin(); 537 bitstream_buffers_in_decoder_.begin();
527 it != bitstream_buffers_in_decoder_.end(); ++it) { 538 it != bitstream_buffers_in_decoder_.end(); ++it) {
528 it->second.shm_buffer->shm->Close(); 539 it->second.shm_buffer->shm->Close();
529 } 540 }
530 bitstream_buffers_in_decoder_.clear(); 541 bitstream_buffers_in_decoder_.clear();
542
543 DestroyTextures();
531 } 544 }
532 545
533 void GpuVideoDecoder::EnsureDemuxOrDecode() { 546 void GpuVideoDecoder::EnsureDemuxOrDecode() {
534 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); 547 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread());
535 if (demuxer_read_in_progress_) 548 if (demuxer_read_in_progress_)
536 return; 549 return;
537 demuxer_read_in_progress_ = true; 550 demuxer_read_in_progress_ = true;
538 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( 551 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
539 &DemuxerStream::Read, demuxer_stream_.get(), 552 &DemuxerStream::Read, demuxer_stream_.get(),
540 base::Bind(&GpuVideoDecoder::RequestBufferDecode, this))); 553 base::Bind(&GpuVideoDecoder::RequestBufferDecode, this)));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 601
589 error_occured_ = true; 602 error_occured_ = true;
590 603
591 if (!pending_read_cb_.is_null()) { 604 if (!pending_read_cb_.is_null()) {
592 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); 605 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL);
593 return; 606 return;
594 } 607 }
595 } 608 }
596 609
597 } // namespace media 610 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698