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

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

Issue 13585003: GpuVideoDecoder not to use DemuxerStream after it's stopped. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 void GpuVideoDecoder::Stop(const base::Closure& closure) { 102 void GpuVideoDecoder::Stop(const base::Closure& closure) {
103 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); 103 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread());
104 if (vda_.get()) 104 if (vda_.get())
105 DestroyVDA(); 105 DestroyVDA();
106 if (!pending_read_cb_.is_null()) 106 if (!pending_read_cb_.is_null())
107 EnqueueFrameAndTriggerFrameDelivery(VideoFrame::CreateEmptyFrame()); 107 EnqueueFrameAndTriggerFrameDelivery(VideoFrame::CreateEmptyFrame());
108 if (!pending_reset_cb_.is_null()) 108 if (!pending_reset_cb_.is_null())
109 base::ResetAndReturn(&pending_reset_cb_).Run(); 109 base::ResetAndReturn(&pending_reset_cb_).Run();
110 demuxer_stream_ = NULL;
110 BindToCurrentLoop(closure).Run(); 111 BindToCurrentLoop(closure).Run();
111 } 112 }
112 113
113 void GpuVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream, 114 void GpuVideoDecoder::Initialize(const scoped_refptr<DemuxerStream>& stream,
114 const PipelineStatusCB& orig_status_cb, 115 const PipelineStatusCB& orig_status_cb,
115 const StatisticsCB& statistics_cb) { 116 const StatisticsCB& statistics_cb) {
116 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); 117 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread());
117 PipelineStatusCB status_cb = CreateUMAReportingPipelineCB( 118 PipelineStatusCB status_cb = CreateUMAReportingPipelineCB(
118 "Media.GpuVideoDecoderInitializeStatus", 119 "Media.GpuVideoDecoderInitializeStatus",
119 BindToCurrentLoop(orig_status_cb)); 120 BindToCurrentLoop(orig_status_cb));
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 for (std::map<int32, BufferPair>::iterator it = 543 for (std::map<int32, BufferPair>::iterator it =
543 bitstream_buffers_in_decoder_.begin(); 544 bitstream_buffers_in_decoder_.begin();
544 it != bitstream_buffers_in_decoder_.end(); ++it) { 545 it != bitstream_buffers_in_decoder_.end(); ++it) {
545 it->second.shm_buffer->shm->Close(); 546 it->second.shm_buffer->shm->Close();
546 } 547 }
547 bitstream_buffers_in_decoder_.clear(); 548 bitstream_buffers_in_decoder_.clear();
548 549
549 DestroyTextures(); 550 DestroyTextures();
550 } 551 }
551 552
553 void GpuVideoDecoder::ReadFromDemuxerStream() {
554 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread());
555 DCHECK(demuxer_read_in_progress_);
556
557 // This can happen during the tear-down process. GpuVideoDecoder::Stop()
558 // returns the |pending_read_cb_| immediately without waiting for the demuxer
559 // read to be returned. Therefore, this function could be called even after
560 // the decoder has been stopped.
561 if (!demuxer_stream_) {
562 demuxer_read_in_progress_ = false;
563 return;
564 }
565
566 demuxer_stream_->Read(base::Bind(
567 &GpuVideoDecoder::RequestBufferDecode, this));
568 }
569
552 void GpuVideoDecoder::EnsureDemuxOrDecode() { 570 void GpuVideoDecoder::EnsureDemuxOrDecode() {
553 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread()); 571 DCHECK(gvd_loop_proxy_->BelongsToCurrentThread());
554 if (demuxer_read_in_progress_) 572 if (demuxer_read_in_progress_)
555 return; 573 return;
556 demuxer_read_in_progress_ = true; 574 demuxer_read_in_progress_ = true;
557 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( 575 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
558 &DemuxerStream::Read, demuxer_stream_.get(), 576 &GpuVideoDecoder::ReadFromDemuxerStream, this));
Ami GONE FROM CHROMIUM 2013/04/04 03:43:22 Do you see a reason not to simply run the Read() h
xhwang 2013/04/04 04:15:23 I think there are two reasons why we always post:
xhwang 2013/04/04 17:05:33 Done.
559 base::Bind(&GpuVideoDecoder::RequestBufferDecode, this)));
560 } 577 }
561 578
562 void GpuVideoDecoder::NotifyFlushDone() { 579 void GpuVideoDecoder::NotifyFlushDone() {
563 if (!gvd_loop_proxy_->BelongsToCurrentThread()) { 580 if (!gvd_loop_proxy_->BelongsToCurrentThread()) {
564 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind( 581 gvd_loop_proxy_->PostTask(FROM_HERE, base::Bind(
565 &GpuVideoDecoder::NotifyFlushDone, this)); 582 &GpuVideoDecoder::NotifyFlushDone, this));
566 return; 583 return;
567 } 584 }
568 DCHECK_EQ(state_, kDrainingDecoder); 585 DCHECK_EQ(state_, kDrainingDecoder);
569 state_ = kDecoderDrained; 586 state_ = kDecoderDrained;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 621
605 error_occured_ = true; 622 error_occured_ = true;
606 623
607 if (!pending_read_cb_.is_null()) { 624 if (!pending_read_cb_.is_null()) {
608 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL); 625 base::ResetAndReturn(&pending_read_cb_).Run(kDecodeError, NULL);
609 return; 626 return;
610 } 627 }
611 } 628 }
612 629
613 } // namespace media 630 } // namespace media
OLDNEW
« media/base/video_decoder.h ('K') | « media/filters/gpu_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698