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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
11 namespace media { | 11 namespace media { |
12 | 12 |
13 enum { kPauseDelaySeconds = 10 }; | 13 enum { kPauseDelaySeconds = 10 }; |
14 | 14 |
15 AudioRendererMixer::AudioRendererMixer( | 15 AudioRendererMixer::AudioRendererMixer( |
16 const AudioParameters& input_params, const AudioParameters& output_params, | 16 const AudioParameters& input_params, const AudioParameters& output_params, |
17 const scoped_refptr<AudioRendererSink>& sink) | 17 const scoped_refptr<AudioRendererSink>& sink) |
18 : audio_sink_(sink), | 18 : audio_sink_(sink), |
19 audio_converter_(input_params, output_params, true), | 19 audio_converter_(input_params, output_params, true), |
20 pause_delay_(base::TimeDelta::FromSeconds(kPauseDelaySeconds)), | 20 pause_delay_(base::TimeDelta::FromSeconds(kPauseDelaySeconds)), |
21 last_play_time_(base::Time::Now()), | 21 last_play_time_(base::Time::Now()), |
22 // Initialize |playing_| to true since Start() results in an auto-play. | 22 // Initialize |playing_| to true since Start() results in an auto-play. |
23 playing_(true) { | 23 playing_(true), |
| 24 input_params_(input_params), |
| 25 output_params_(output_params) { |
24 audio_sink_->Initialize(output_params, this); | 26 audio_sink_->Initialize(output_params, this); |
25 audio_sink_->Start(); | 27 audio_sink_->Start(); |
26 } | 28 } |
27 | 29 |
28 AudioRendererMixer::~AudioRendererMixer() { | 30 AudioRendererMixer::~AudioRendererMixer() { |
29 // AudioRendererSinks must be stopped before being destructed. | 31 // AudioRendererSinks must be stopped before being destructed. |
30 audio_sink_->Stop(); | 32 audio_sink_->Stop(); |
31 | 33 |
32 // Ensures that all mixer inputs have stopped themselves prior to destruction | 34 // Ensures that all mixer inputs have stopped themselves prior to destruction |
33 // and have called RemoveMixerInput(). | 35 // and have called RemoveMixerInput(). |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 void AudioRendererMixer::OnRenderError() { | 85 void AudioRendererMixer::OnRenderError() { |
84 base::AutoLock auto_lock(mixer_inputs_lock_); | 86 base::AutoLock auto_lock(mixer_inputs_lock_); |
85 | 87 |
86 // Call each mixer input and signal an error. | 88 // Call each mixer input and signal an error. |
87 for (AudioRendererMixerInputSet::iterator it = mixer_inputs_.begin(); | 89 for (AudioRendererMixerInputSet::iterator it = mixer_inputs_.begin(); |
88 it != mixer_inputs_.end(); ++it) { | 90 it != mixer_inputs_.end(); ++it) { |
89 (*it)->OnRenderError(); | 91 (*it)->OnRenderError(); |
90 } | 92 } |
91 } | 93 } |
92 | 94 |
| 95 void AudioRendererMixer::OnDeviceChange() { |
| 96 base::AutoLock auto_lock(mixer_inputs_lock_); |
| 97 |
| 98 // Iterate and remove elements which receive an updated mixer. |
| 99 for (AudioRendererMixerInputSet::iterator it = mixer_inputs_.begin(); |
| 100 it != mixer_inputs_.end(); ++it) { |
| 101 (*it)->OnDeviceChange(); |
| 102 } |
| 103 } |
| 104 |
| 105 |
93 } // namespace media | 106 } // namespace media |
OLD | NEW |