Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/audio_renderer_impl.h" | 5 #include "media/filters/audio_renderer_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 rendered_end_of_stream_ = false; | 175 rendered_end_of_stream_ = false; |
| 176 preroll_aborted_ = false; | 176 preroll_aborted_ = false; |
| 177 | 177 |
| 178 earliest_end_time_ = now_cb_.Run(); | 178 earliest_end_time_ = now_cb_.Run(); |
| 179 splicer_->Reset(); | 179 splicer_->Reset(); |
| 180 algorithm_->FlushBuffers(); | 180 algorithm_->FlushBuffers(); |
| 181 | 181 |
| 182 base::ResetAndReturn(&flush_cb_).Run(); | 182 base::ResetAndReturn(&flush_cb_).Run(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void AudioRendererImpl::StopDecoder() { | |
| 186 DCHECK(task_runner_->BelongsToCurrentThread()); | |
| 187 decoder_->Stop(BindToCurrentLoop( | |
| 188 base::Bind(&AudioRendererImpl::StopDecoderDone, weak_this_))); | |
| 189 } | |
| 190 | |
| 191 void AudioRendererImpl::StopDecoderDone() { | |
| 192 base::AutoLock auto_lock(lock_); | |
|
DaleCurtis
2014/01/08 00:30:54
Previous method doesn't run this under lock. It m
rileya (GONE FROM CHROMIUM)
2014/01/08 21:05:50
Which previous method do you mean?
DaleCurtis
2014/01/08 21:51:45
See line 236 in Stop() below. callback.Run() occur
rileya (GONE FROM CHROMIUM)
2014/01/08 22:02:55
Ahh, gotcha. Looks like ResetDecoderDone also call
DaleCurtis
2014/01/08 23:56:14
sgtm
| |
| 193 if (state_ == kStopped) | |
| 194 return; | |
| 195 | |
| 196 DCHECK(!stop_cb_.is_null()); | |
| 197 | |
| 198 ChangeState_Locked(kStopped); | |
| 199 algorithm_.reset(NULL); | |
|
DaleCurtis
2014/01/08 00:30:54
drop NULL.
| |
| 200 init_cb_.Reset(); | |
| 201 underflow_cb_.Reset(); | |
| 202 time_cb_.Reset(); | |
| 203 flush_cb_.Reset(); | |
|
xhwang
2014/01/08 01:33:37
Wrap 199-203 in a helper function so it can be sha
rileya (GONE FROM CHROMIUM)
2014/01/08 21:05:50
StopDecoderDone was already basically this, so per
| |
| 204 | |
| 205 base::ResetAndReturn(&stop_cb_).Run(); | |
| 206 } | |
| 207 | |
| 185 void AudioRendererImpl::Stop(const base::Closure& callback) { | 208 void AudioRendererImpl::Stop(const base::Closure& callback) { |
| 186 DCHECK(task_runner_->BelongsToCurrentThread()); | 209 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 187 DCHECK(!callback.is_null()); | 210 DCHECK(!callback.is_null()); |
| 188 | 211 |
| 189 // TODO(scherkus): Consider invalidating |weak_factory_| and replacing | 212 // TODO(scherkus): Consider invalidating |weak_factory_| and replacing |
| 190 // task-running guards that check |state_| with DCHECK(). | 213 // task-running guards that check |state_| with DCHECK(). |
| 191 | 214 |
| 192 if (sink_) { | 215 if (sink_) { |
| 193 sink_->Stop(); | 216 sink_->Stop(); |
| 194 sink_ = NULL; | 217 sink_ = NULL; |
| 195 } | 218 } |
| 196 | 219 |
| 220 if (decoder_) { | |
| 221 stop_cb_ = callback; | |
| 222 StopDecoder(); | |
|
DaleCurtis
2014/01/08 00:30:54
You can probably drop the StopDecoder() method in
rileya (GONE FROM CHROMIUM)
2014/01/08 21:05:50
Done.
| |
| 223 return; | |
| 224 } | |
| 225 | |
| 197 { | 226 { |
|
DaleCurtis
2014/01/08 00:30:54
Just call StopDecoderDone here?
rileya (GONE FROM CHROMIUM)
2014/01/08 21:05:50
Makes sense, done.
| |
| 198 base::AutoLock auto_lock(lock_); | 227 base::AutoLock auto_lock(lock_); |
| 199 ChangeState_Locked(kStopped); | 228 ChangeState_Locked(kStopped); |
| 200 algorithm_.reset(NULL); | 229 algorithm_.reset(NULL); |
| 201 init_cb_.Reset(); | 230 init_cb_.Reset(); |
|
xhwang
2014/01/08 01:33:37
If Init() didn't succeed, Stop() should not be cal
rileya (GONE FROM CHROMIUM)
2014/01/08 21:05:50
Alright, added a check (line 191).
| |
| 202 underflow_cb_.Reset(); | 231 underflow_cb_.Reset(); |
| 203 time_cb_.Reset(); | 232 time_cb_.Reset(); |
| 204 flush_cb_.Reset(); | 233 flush_cb_.Reset(); |
| 205 } | 234 } |
| 206 | 235 |
| 207 callback.Run(); | 236 callback.Run(); |
| 208 } | 237 } |
| 209 | 238 |
| 210 void AudioRendererImpl::Preroll(base::TimeDelta time, | 239 void AudioRendererImpl::Preroll(base::TimeDelta time, |
| 211 const PipelineStatusCB& cb) { | 240 const PipelineStatusCB& cb) { |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 } | 729 } |
| 701 } | 730 } |
| 702 | 731 |
| 703 void AudioRendererImpl::ChangeState_Locked(State new_state) { | 732 void AudioRendererImpl::ChangeState_Locked(State new_state) { |
| 704 DVLOG(1) << __FUNCTION__ << " : " << state_ << " -> " << new_state; | 733 DVLOG(1) << __FUNCTION__ << " : " << state_ << " -> " << new_state; |
| 705 lock_.AssertAcquired(); | 734 lock_.AssertAcquired(); |
| 706 state_ = new_state; | 735 state_ = new_state; |
| 707 } | 736 } |
| 708 | 737 |
| 709 } // namespace media | 738 } // namespace media |
| OLD | NEW |