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

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

Issue 397953007: Fold DecryptingDemuxerStream::Stop() into the dtor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 5 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/audio_decoder_selector_unittest.cc ('k') | media/filters/decoder_stream.cc » ('j') | 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 "decoder_selector.h" 5 #include "decoder_selector.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/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone, 109 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone,
110 weak_ptr_factory_.GetWeakPtr()), 110 weak_ptr_factory_.GetWeakPtr()),
111 output_cb_); 111 output_cb_);
112 } 112 }
113 113
114 template <DemuxerStream::Type StreamType> 114 template <DemuxerStream::Type StreamType>
115 void DecoderSelector<StreamType>::Abort() { 115 void DecoderSelector<StreamType>::Abort() {
116 DVLOG(2) << __FUNCTION__; 116 DVLOG(2) << __FUNCTION__;
117 DCHECK(task_runner_->BelongsToCurrentThread()); 117 DCHECK(task_runner_->BelongsToCurrentThread());
118 118
119 // This could happen when SelectDecoder() was not called or when 119 // Invalidate all weak pointers so that pending callbacks won't fire.
120 // |select_decoder_cb_| was already posted but not fired (e.g. in the
121 // message loop queue).
122 if (select_decoder_cb_.is_null())
123 return;
124
125 // We must be trying to initialize the |decoder_| or the
126 // |decrypted_stream_|. Invalid all weak pointers so that all initialization
127 // callbacks won't fire.
128 weak_ptr_factory_.InvalidateWeakPtrs(); 120 weak_ptr_factory_.InvalidateWeakPtrs();
129 121
130 if (decoder_) { 122 decoder_.reset();
131 // |decrypted_stream_| is either NULL or already initialized. We don't 123 decrypted_stream_.reset();
132 // need to Stop() |decrypted_stream_| in either case. 124
133 decoder_.reset(); 125 if (!select_decoder_cb_.is_null())
134 ReturnNullDecoder(); 126 ReturnNullDecoder();
135 return;
136 }
137
138 if (decrypted_stream_) {
139 decrypted_stream_->Stop();
140 ReturnNullDecoder();
141 return;
142 }
143
144 NOTREACHED();
145 } 127 }
146 128
147 template <DemuxerStream::Type StreamType> 129 template <DemuxerStream::Type StreamType>
148 void DecoderSelector<StreamType>::DecryptingDecoderInitDone( 130 void DecoderSelector<StreamType>::DecryptingDecoderInitDone(
149 PipelineStatus status) { 131 PipelineStatus status) {
150 DVLOG(2) << __FUNCTION__; 132 DVLOG(2) << __FUNCTION__;
151 DCHECK(task_runner_->BelongsToCurrentThread()); 133 DCHECK(task_runner_->BelongsToCurrentThread());
152 134
153 if (status == PIPELINE_OK) { 135 if (status == PIPELINE_OK) {
154 base::ResetAndReturn(&select_decoder_cb_) 136 base::ResetAndReturn(&select_decoder_cb_)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 214
233 // These forward declarations tell the compiler that we will use 215 // These forward declarations tell the compiler that we will use
234 // DecoderSelector with these arguments, allowing us to keep these definitions 216 // DecoderSelector with these arguments, allowing us to keep these definitions
235 // in our .cc without causing linker errors. This also means if anyone tries to 217 // in our .cc without causing linker errors. This also means if anyone tries to
236 // instantiate a DecoderSelector with anything but these two specializations 218 // instantiate a DecoderSelector with anything but these two specializations
237 // they'll most likely get linker errors. 219 // they'll most likely get linker errors.
238 template class DecoderSelector<DemuxerStream::AUDIO>; 220 template class DecoderSelector<DemuxerStream::AUDIO>;
239 template class DecoderSelector<DemuxerStream::VIDEO>; 221 template class DecoderSelector<DemuxerStream::VIDEO>;
240 222
241 } // namespace media 223 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/audio_decoder_selector_unittest.cc ('k') | media/filters/decoder_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698