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( |
19 const AudioParameters& output_params, | 19 const AudioParameters& output_params, |
20 const scoped_refptr<AudioRendererSink>& sink) | 20 scoped_refptr<media::AudioRendererSink> sink) |
DaleCurtis
2016/05/17 19:13:48
Ditto.
o1ka
2016/05/18 13:15:12
Done.
| |
21 : audio_sink_(sink), | 21 : audio_sink_(sink), |
22 output_params_(output_params), | 22 output_params_(output_params), |
23 master_converter_(output_params, output_params, true), | 23 master_converter_(output_params, output_params, true), |
24 pause_delay_(base::TimeDelta::FromSeconds(kPauseDelaySeconds)), | 24 pause_delay_(base::TimeDelta::FromSeconds(kPauseDelaySeconds)), |
25 last_play_time_(base::TimeTicks::Now()), | 25 last_play_time_(base::TimeTicks::Now()), |
26 // Initialize |playing_| to true since Start() results in an auto-play. | 26 // Initialize |playing_| to true since Start() results in an auto-play. |
27 playing_(true) { | 27 playing_(true) { |
28 DCHECK(audio_sink_); | |
28 audio_sink_->Initialize(output_params, this); | 29 audio_sink_->Initialize(output_params, this); |
29 audio_sink_->Start(); | 30 audio_sink_->Start(); |
30 } | 31 } |
31 | 32 |
32 AudioRendererMixer::~AudioRendererMixer() { | 33 AudioRendererMixer::~AudioRendererMixer() { |
33 // AudioRendererSinks must be stopped before being destructed. | 34 // AudioRendererSink must be stopped before mixer is destructed. |
34 audio_sink_->Stop(); | 35 audio_sink_->Stop(); |
35 | 36 |
36 // Ensure that all mixer inputs have removed themselves prior to destruction. | 37 // Ensure that all mixer inputs have removed themselves prior to destruction. |
37 DCHECK(master_converter_.empty()); | 38 DCHECK(master_converter_.empty()); |
38 DCHECK(converters_.empty()); | 39 DCHECK(converters_.empty()); |
39 DCHECK_EQ(error_callbacks_.size(), 0U); | 40 DCHECK_EQ(error_callbacks_.size(), 0U); |
40 } | 41 } |
41 | 42 |
42 void AudioRendererMixer::AddMixerInput(const AudioParameters& input_params, | 43 void AudioRendererMixer::AddMixerInput(const AudioParameters& input_params, |
43 AudioConverter::InputCallback* input) { | 44 AudioConverter::InputCallback* input) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 } | 147 } |
147 | 148 |
148 void AudioRendererMixer::OnRenderError() { | 149 void AudioRendererMixer::OnRenderError() { |
149 // Call each mixer input and signal an error. | 150 // Call each mixer input and signal an error. |
150 base::AutoLock auto_lock(lock_); | 151 base::AutoLock auto_lock(lock_); |
151 for (const auto& cb : error_callbacks_) | 152 for (const auto& cb : error_callbacks_) |
152 cb.Run(); | 153 cb.Run(); |
153 } | 154 } |
154 | 155 |
155 } // namespace media | 156 } // namespace media |
OLD | NEW |