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

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

Issue 398163004: Fold DecoderSelector::Abort() into the dtor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only 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/decoder_selector.h ('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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 const SetDecryptorReadyCB& set_decryptor_ready_cb) 55 const SetDecryptorReadyCB& set_decryptor_ready_cb)
56 : task_runner_(task_runner), 56 : task_runner_(task_runner),
57 decoders_(decoders.Pass()), 57 decoders_(decoders.Pass()),
58 set_decryptor_ready_cb_(set_decryptor_ready_cb), 58 set_decryptor_ready_cb_(set_decryptor_ready_cb),
59 input_stream_(NULL), 59 input_stream_(NULL),
60 weak_ptr_factory_(this) {} 60 weak_ptr_factory_(this) {}
61 61
62 template <DemuxerStream::Type StreamType> 62 template <DemuxerStream::Type StreamType>
63 DecoderSelector<StreamType>::~DecoderSelector() { 63 DecoderSelector<StreamType>::~DecoderSelector() {
64 DVLOG(2) << __FUNCTION__; 64 DVLOG(2) << __FUNCTION__;
65 DCHECK(select_decoder_cb_.is_null()); 65 DCHECK(task_runner_->BelongsToCurrentThread());
66
67 if (!select_decoder_cb_.is_null())
68 ReturnNullDecoder();
69
70 decoder_.reset();
71 decrypted_stream_.reset();
66 } 72 }
67 73
68 template <DemuxerStream::Type StreamType> 74 template <DemuxerStream::Type StreamType>
69 void DecoderSelector<StreamType>::SelectDecoder( 75 void DecoderSelector<StreamType>::SelectDecoder(
70 DemuxerStream* stream, 76 DemuxerStream* stream,
71 bool low_delay, 77 bool low_delay,
72 const SelectDecoderCB& select_decoder_cb, 78 const SelectDecoderCB& select_decoder_cb,
73 const typename Decoder::OutputCB& output_cb) { 79 const typename Decoder::OutputCB& output_cb) {
74 DVLOG(2) << __FUNCTION__; 80 DVLOG(2) << __FUNCTION__;
75 DCHECK(task_runner_->BelongsToCurrentThread()); 81 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 29 matching lines...) Expand all
105 DecoderStreamTraits<StreamType>::Initialize( 111 DecoderStreamTraits<StreamType>::Initialize(
106 decoder_.get(), 112 decoder_.get(),
107 StreamTraits::GetDecoderConfig(*input_stream_), 113 StreamTraits::GetDecoderConfig(*input_stream_),
108 low_delay_, 114 low_delay_,
109 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone, 115 base::Bind(&DecoderSelector<StreamType>::DecryptingDecoderInitDone,
110 weak_ptr_factory_.GetWeakPtr()), 116 weak_ptr_factory_.GetWeakPtr()),
111 output_cb_); 117 output_cb_);
112 } 118 }
113 119
114 template <DemuxerStream::Type StreamType> 120 template <DemuxerStream::Type StreamType>
115 void DecoderSelector<StreamType>::Abort() {
116 DVLOG(2) << __FUNCTION__;
117 DCHECK(task_runner_->BelongsToCurrentThread());
118
119 // Invalidate all weak pointers so that pending callbacks won't fire.
120 weak_ptr_factory_.InvalidateWeakPtrs();
121
122 decoder_.reset();
123 decrypted_stream_.reset();
124
125 if (!select_decoder_cb_.is_null())
126 ReturnNullDecoder();
127 }
128
129 template <DemuxerStream::Type StreamType>
130 void DecoderSelector<StreamType>::DecryptingDecoderInitDone( 121 void DecoderSelector<StreamType>::DecryptingDecoderInitDone(
131 PipelineStatus status) { 122 PipelineStatus status) {
132 DVLOG(2) << __FUNCTION__; 123 DVLOG(2) << __FUNCTION__;
133 DCHECK(task_runner_->BelongsToCurrentThread()); 124 DCHECK(task_runner_->BelongsToCurrentThread());
134 125
135 if (status == PIPELINE_OK) { 126 if (status == PIPELINE_OK) {
136 base::ResetAndReturn(&select_decoder_cb_) 127 base::ResetAndReturn(&select_decoder_cb_)
137 .Run(decoder_.Pass(), scoped_ptr<DecryptingDemuxerStream>()); 128 .Run(decoder_.Pass(), scoped_ptr<DecryptingDemuxerStream>());
138 return; 129 return;
139 } 130 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 205
215 // These forward declarations tell the compiler that we will use 206 // These forward declarations tell the compiler that we will use
216 // DecoderSelector with these arguments, allowing us to keep these definitions 207 // DecoderSelector with these arguments, allowing us to keep these definitions
217 // in our .cc without causing linker errors. This also means if anyone tries to 208 // in our .cc without causing linker errors. This also means if anyone tries to
218 // instantiate a DecoderSelector with anything but these two specializations 209 // instantiate a DecoderSelector with anything but these two specializations
219 // they'll most likely get linker errors. 210 // they'll most likely get linker errors.
220 template class DecoderSelector<DemuxerStream::AUDIO>; 211 template class DecoderSelector<DemuxerStream::AUDIO>;
221 template class DecoderSelector<DemuxerStream::VIDEO>; 212 template class DecoderSelector<DemuxerStream::VIDEO>;
222 213
223 } // namespace media 214 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decoder_selector.h ('k') | media/filters/decoder_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698