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/base/audio_renderer_mixer.h" | 5 #include "media/base/audio_renderer_mixer.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 enum { kPauseDelaySeconds = 10 }; | 16 enum { kPauseDelaySeconds = 10 }; |
| 17 | 17 |
| 18 AudioRendererMixer::AudioRendererMixer( | 18 AudioRendererMixer::AudioRendererMixer(const AudioParameters& output_params, |
|
miu
2016/05/19 22:27:15
nit: The order of args is opposite the order of th
o1ka
2016/05/23 16:16:55
Done (another way around)
| |
| 19 const AudioParameters& output_params, | 19 scoped_refptr<AudioRendererSink> sink) |
| 20 const scoped_refptr<AudioRendererSink>& sink) | |
| 21 : audio_sink_(sink), | 20 : audio_sink_(sink), |
|
miu
2016/05/19 22:27:15
std::move(sink)
o1ka
2016/05/23 16:16:54
Done.
| |
| 22 output_params_(output_params), | 21 output_params_(output_params), |
| 23 master_converter_(output_params, output_params, true), | 22 master_converter_(output_params, output_params, true), |
| 24 pause_delay_(base::TimeDelta::FromSeconds(kPauseDelaySeconds)), | 23 pause_delay_(base::TimeDelta::FromSeconds(kPauseDelaySeconds)), |
| 25 last_play_time_(base::TimeTicks::Now()), | 24 last_play_time_(base::TimeTicks::Now()), |
| 26 // Initialize |playing_| to true since Start() results in an auto-play. | 25 // Initialize |playing_| to true since Start() results in an auto-play. |
| 27 playing_(true) { | 26 playing_(true) { |
| 27 DCHECK(audio_sink_); | |
| 28 audio_sink_->Initialize(output_params, this); | 28 audio_sink_->Initialize(output_params, this); |
| 29 audio_sink_->Start(); | 29 audio_sink_->Start(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 AudioRendererMixer::~AudioRendererMixer() { | 32 AudioRendererMixer::~AudioRendererMixer() { |
| 33 // AudioRendererSinks must be stopped before being destructed. | 33 // AudioRendererSink must be stopped before mixer is destructed. |
| 34 audio_sink_->Stop(); | 34 audio_sink_->Stop(); |
| 35 | 35 |
| 36 // Ensure that all mixer inputs have removed themselves prior to destruction. | 36 // Ensure that all mixer inputs have removed themselves prior to destruction. |
| 37 DCHECK(master_converter_.empty()); | 37 DCHECK(master_converter_.empty()); |
| 38 DCHECK(converters_.empty()); | 38 DCHECK(converters_.empty()); |
| 39 DCHECK_EQ(error_callbacks_.size(), 0U); | 39 DCHECK_EQ(error_callbacks_.size(), 0U); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void AudioRendererMixer::AddMixerInput(const AudioParameters& input_params, | 42 void AudioRendererMixer::AddMixerInput(const AudioParameters& input_params, |
| 43 AudioConverter::InputCallback* input) { | 43 AudioConverter::InputCallback* input) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 } | 146 } |
| 147 | 147 |
| 148 void AudioRendererMixer::OnRenderError() { | 148 void AudioRendererMixer::OnRenderError() { |
| 149 // Call each mixer input and signal an error. | 149 // Call each mixer input and signal an error. |
| 150 base::AutoLock auto_lock(lock_); | 150 base::AutoLock auto_lock(lock_); |
| 151 for (const auto& cb : error_callbacks_) | 151 for (const auto& cb : error_callbacks_) |
| 152 cb.Run(); | 152 cb.Run(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace media | 155 } // namespace media |
| OLD | NEW |