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

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

Issue 1939993002: Ignore calls to Reset() when in error state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « media/filters/decoder_stream.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/decoder_stream.h" 5 #include "media/filters/decoder_stream.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 template <DemuxerStream::Type StreamType> 150 template <DemuxerStream::Type StreamType>
151 void DecoderStream<StreamType>::Reset(const base::Closure& closure) { 151 void DecoderStream<StreamType>::Reset(const base::Closure& closure) {
152 FUNCTION_DVLOG(2); 152 FUNCTION_DVLOG(2);
153 DCHECK(task_runner_->BelongsToCurrentThread()); 153 DCHECK(task_runner_->BelongsToCurrentThread());
154 DCHECK_NE(state_, STATE_UNINITIALIZED); 154 DCHECK_NE(state_, STATE_UNINITIALIZED);
155 DCHECK(reset_cb_.is_null()); 155 DCHECK(reset_cb_.is_null());
156 156
157 reset_cb_ = closure; 157 reset_cb_ = closure;
158 158
159 if (!read_cb_.is_null()) { 159 if (!read_cb_.is_null()) {
160 task_runner_->PostTask(FROM_HERE, base::Bind( 160 task_runner_->PostTask(FROM_HERE,
161 base::ResetAndReturn(&read_cb_), ABORTED, scoped_refptr<Output>())); 161 base::Bind(base::ResetAndReturn(&read_cb_), ABORTED,
162 scoped_refptr<Output>()));
162 } 163 }
163 164
164 ready_outputs_.clear(); 165 ready_outputs_.clear();
165 166
167 // It's possible to have received a DECODE_ERROR and entered STATE_ERROR right
168 // before a Reset() is executed. See crbug.com/597605 or crbug.com/607454.
sandersd (OOO until July 31) 2016/05/02 22:57:03 or -> and.
tguilbert 2016/05/03 00:06:41 Done.
169 if (state_ == STATE_ERROR) {
170 task_runner_->PostTask(FROM_HERE, base::ResetAndReturn(&reset_cb_));
sandersd (OOO until July 31) 2016/05/02 22:57:03 Should this be below the |read_cb_| check? It seem
tguilbert 2016/05/03 00:06:41 This is something that I considered. The comments
171 return;
172 }
173
166 // During decoder reinitialization, the Decoder does not need to be and 174 // During decoder reinitialization, the Decoder does not need to be and
167 // cannot be Reset(). |decrypting_demuxer_stream_| was reset before decoder 175 // cannot be Reset(). |decrypting_demuxer_stream_| was reset before decoder
168 // reinitialization. 176 // reinitialization.
169 if (state_ == STATE_REINITIALIZING_DECODER) 177 if (state_ == STATE_REINITIALIZING_DECODER)
170 return; 178 return;
171 179
172 // During pending demuxer read and when not using DecryptingDemuxerStream, 180 // During pending demuxer read and when not using DecryptingDemuxerStream,
173 // the Decoder will be reset after demuxer read is returned 181 // the Decoder will be reset after demuxer read is returned
174 // (in OnBufferReady()). 182 // (in OnBufferReady()).
175 if (state_ == STATE_PENDING_DEMUXER_READ && !decrypting_demuxer_stream_) 183 if (state_ == STATE_PENDING_DEMUXER_READ && !decrypting_demuxer_stream_)
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 } 711 }
704 712
705 ReadFromDemuxerStream(); 713 ReadFromDemuxerStream();
706 } 714 }
707 715
708 template <DemuxerStream::Type StreamType> 716 template <DemuxerStream::Type StreamType>
709 void DecoderStream<StreamType>::ResetDecoder() { 717 void DecoderStream<StreamType>::ResetDecoder() {
710 FUNCTION_DVLOG(2); 718 FUNCTION_DVLOG(2);
711 DCHECK(task_runner_->BelongsToCurrentThread()); 719 DCHECK(task_runner_->BelongsToCurrentThread());
712 DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER || 720 DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER ||
713 state_ == STATE_ERROR || state_ == STATE_END_OF_STREAM) << state_; 721 state_ == STATE_END_OF_STREAM)
722 << state_;
714 DCHECK(!reset_cb_.is_null()); 723 DCHECK(!reset_cb_.is_null());
715 724
716 decoder_->Reset(base::Bind(&DecoderStream<StreamType>::OnDecoderReset, 725 decoder_->Reset(base::Bind(&DecoderStream<StreamType>::OnDecoderReset,
717 weak_factory_.GetWeakPtr())); 726 weak_factory_.GetWeakPtr()));
718 } 727 }
719 728
720 template <DemuxerStream::Type StreamType> 729 template <DemuxerStream::Type StreamType>
721 void DecoderStream<StreamType>::OnDecoderReset() { 730 void DecoderStream<StreamType>::OnDecoderReset() {
722 FUNCTION_DVLOG(2); 731 FUNCTION_DVLOG(2);
723 DCHECK(task_runner_->BelongsToCurrentThread()); 732 DCHECK(task_runner_->BelongsToCurrentThread());
724 DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER || 733 DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER ||
725 state_ == STATE_ERROR || state_ == STATE_END_OF_STREAM) << state_; 734 state_ == STATE_END_OF_STREAM)
735 << state_;
726 // If Reset() was called during pending read, read callback should be fired 736 // If Reset() was called during pending read, read callback should be fired
727 // before the reset callback is fired. 737 // before the reset callback is fired.
728 DCHECK(read_cb_.is_null()); 738 DCHECK(read_cb_.is_null());
729 DCHECK(!reset_cb_.is_null()); 739 DCHECK(!reset_cb_.is_null());
730 740
731 // Make sure we read directly from the demuxer after a reset. 741 // Make sure we read directly from the demuxer after a reset.
732 fallback_buffers_.clear(); 742 fallback_buffers_.clear();
733 pending_buffers_.clear(); 743 pending_buffers_.clear();
734 744
735 if (state_ != STATE_FLUSHING_DECODER) { 745 if (state_ != STATE_FLUSHING_DECODER) {
736 state_ = STATE_NORMAL; 746 state_ = STATE_NORMAL;
737 active_splice_ = false; 747 active_splice_ = false;
738 base::ResetAndReturn(&reset_cb_).Run(); 748 base::ResetAndReturn(&reset_cb_).Run();
739 return; 749 return;
740 } 750 }
741 751
742 // The resetting process will be continued in OnDecoderReinitialized(). 752 // The resetting process will be continued in OnDecoderReinitialized().
743 ReinitializeDecoder(); 753 ReinitializeDecoder();
744 } 754 }
745 755
746 template class DecoderStream<DemuxerStream::VIDEO>; 756 template class DecoderStream<DemuxerStream::VIDEO>;
747 template class DecoderStream<DemuxerStream::AUDIO>; 757 template class DecoderStream<DemuxerStream::AUDIO>;
748 758
749 } // namespace media 759 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decoder_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698