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/audio/audio_output_resampler.h" | 5 #include "media/audio/audio_output_resampler.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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return AudioParameters( | 141 return AudioParameters( |
142 AudioParameters::AUDIO_PCM_LINEAR, input_params.channel_layout(), | 142 AudioParameters::AUDIO_PCM_LINEAR, input_params.channel_layout(), |
143 input_params.sample_rate(), input_params.bits_per_sample(), | 143 input_params.sample_rate(), input_params.bits_per_sample(), |
144 frames_per_buffer); | 144 frames_per_buffer); |
145 } | 145 } |
146 #endif | 146 #endif |
147 | 147 |
148 AudioOutputResampler::AudioOutputResampler(AudioManager* audio_manager, | 148 AudioOutputResampler::AudioOutputResampler(AudioManager* audio_manager, |
149 const AudioParameters& input_params, | 149 const AudioParameters& input_params, |
150 const AudioParameters& output_params, | 150 const AudioParameters& output_params, |
| 151 const std::string& input_device_id, |
151 const base::TimeDelta& close_delay) | 152 const base::TimeDelta& close_delay) |
152 : AudioOutputDispatcher(audio_manager, input_params), | 153 : AudioOutputDispatcher(audio_manager, input_params, input_device_id), |
153 close_delay_(close_delay), | 154 close_delay_(close_delay), |
154 output_params_(output_params), | 155 output_params_(output_params), |
| 156 input_device_id_(input_device_id), |
155 streams_opened_(false) { | 157 streams_opened_(false) { |
156 DCHECK(input_params.IsValid()); | 158 DCHECK(input_params.IsValid()); |
157 DCHECK(output_params.IsValid()); | 159 DCHECK(output_params.IsValid()); |
158 DCHECK_EQ(output_params_.format(), AudioParameters::AUDIO_PCM_LOW_LATENCY); | 160 DCHECK_EQ(output_params_.format(), AudioParameters::AUDIO_PCM_LOW_LATENCY); |
159 | 161 |
160 // Record UMA statistics for the hardware configuration. | 162 // Record UMA statistics for the hardware configuration. |
161 RecordStats(output_params); | 163 RecordStats(output_params); |
162 | 164 |
163 Initialize(); | 165 Initialize(); |
164 } | 166 } |
165 | 167 |
166 AudioOutputResampler::~AudioOutputResampler() { | 168 AudioOutputResampler::~AudioOutputResampler() { |
167 DCHECK(callbacks_.empty()); | 169 DCHECK(callbacks_.empty()); |
168 } | 170 } |
169 | 171 |
170 void AudioOutputResampler::Initialize() { | 172 void AudioOutputResampler::Initialize() { |
171 DCHECK(!streams_opened_); | 173 DCHECK(!streams_opened_); |
172 DCHECK(callbacks_.empty()); | 174 DCHECK(callbacks_.empty()); |
173 dispatcher_ = new AudioOutputDispatcherImpl( | 175 dispatcher_ = new AudioOutputDispatcherImpl( |
174 audio_manager_, output_params_, close_delay_); | 176 audio_manager_, output_params_, input_device_id_, close_delay_); |
175 } | 177 } |
176 | 178 |
177 bool AudioOutputResampler::OpenStream() { | 179 bool AudioOutputResampler::OpenStream() { |
178 DCHECK_EQ(base::MessageLoop::current(), message_loop_); | 180 DCHECK_EQ(base::MessageLoop::current(), message_loop_); |
179 | 181 |
180 if (dispatcher_->OpenStream()) { | 182 if (dispatcher_->OpenStream()) { |
181 // Only record the UMA statistic if we didn't fallback during construction | 183 // Only record the UMA statistic if we didn't fallback during construction |
182 // and only for the first stream we open. | 184 // and only for the first stream we open. |
183 if (!streams_opened_ && | 185 if (!streams_opened_ && |
184 output_params_.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) { | 186 output_params_.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 source_callback_->OnError(stream); | 393 source_callback_->OnError(stream); |
392 } | 394 } |
393 | 395 |
394 void OnMoreDataConverter::WaitTillDataReady() { | 396 void OnMoreDataConverter::WaitTillDataReady() { |
395 base::AutoLock auto_lock(source_lock_); | 397 base::AutoLock auto_lock(source_lock_); |
396 if (source_callback_) | 398 if (source_callback_) |
397 source_callback_->WaitTillDataReady(); | 399 source_callback_->WaitTillDataReady(); |
398 } | 400 } |
399 | 401 |
400 } // namespace media | 402 } // namespace media |
OLD | NEW |