OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_io.h" | 5 #include "media/audio/audio_io.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <objbase.h> // This has to be before initguid.h | 8 #include <objbase.h> // This has to be before initguid.h |
9 #include <initguid.h> | 9 #include <initguid.h> |
10 #include <mmsystem.h> | 10 #include <mmsystem.h> |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 AudioInputStream* AudioManagerWin::MakeAudioInputStream( | 158 AudioInputStream* AudioManagerWin::MakeAudioInputStream( |
159 const AudioParameters& params, const std::string& device_id) { | 159 const AudioParameters& params, const std::string& device_id) { |
160 if (!params.IsValid() || (params.channels > kWinMaxInputChannels) || | 160 if (!params.IsValid() || (params.channels > kWinMaxInputChannels) || |
161 device_id.empty()) | 161 device_id.empty()) |
162 return NULL; | 162 return NULL; |
163 | 163 |
164 if (params.format == AudioParameters::AUDIO_MOCK) { | 164 if (params.format == AudioParameters::AUDIO_MOCK) { |
165 return FakeAudioInputStream::MakeFakeStream(params); | 165 return FakeAudioInputStream::MakeFakeStream(params); |
166 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { | 166 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { |
167 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 167 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
168 WAVE_MAPPER); | 168 AudioManagerBase::kDefaultDeviceId); |
169 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { | 169 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { |
170 if (!media::IsWASAPISupported()) { | 170 if (!media::IsWASAPISupported()) { |
171 // Fall back to Windows Wave implementation on Windows XP or lower. | 171 // Fall back to Windows Wave implementation on Windows XP or lower. |
172 DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista."; | 172 DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista."; |
173 // TODO(xians): Handle the non-default device. | 173 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
174 if (device_id == AudioManagerBase::kDefaultDeviceId) | 174 device_id); |
175 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | |
176 WAVE_MAPPER); | |
177 } else { | 175 } else { |
178 // TODO(henrika): improve possibility to specify audio endpoint. | 176 return new WASAPIAudioInputStream(this, params, device_id); |
179 // Use the default device (same as for Wave) for now to be compatible. | |
180 // TODO(xians): Handle the non-default device. | |
181 if (device_id == AudioManagerBase::kDefaultDeviceId) | |
182 return new WASAPIAudioInputStream(this, params, eConsole); | |
183 } | 177 } |
184 } | 178 } |
185 return NULL; | 179 return NULL; |
186 } | 180 } |
187 | 181 |
188 void AudioManagerWin::ReleaseOutputStream(AudioOutputStream* stream) { | 182 void AudioManagerWin::ReleaseOutputStream(AudioOutputStream* stream) { |
189 DCHECK(stream); | 183 DCHECK(stream); |
190 num_output_streams_--; | 184 num_output_streams_--; |
191 delete stream; | 185 delete stream; |
192 } | 186 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 name.device_name = AudioManagerBase::kDefaultDeviceName; | 300 name.device_name = AudioManagerBase::kDefaultDeviceName; |
307 name.unique_id = AudioManagerBase::kDefaultDeviceId; | 301 name.unique_id = AudioManagerBase::kDefaultDeviceId; |
308 device_names->push_front(name); | 302 device_names->push_front(name); |
309 } | 303 } |
310 } | 304 } |
311 | 305 |
312 /// static | 306 /// static |
313 AudioManager* AudioManager::CreateAudioManager() { | 307 AudioManager* AudioManager::CreateAudioManager() { |
314 return new AudioManagerWin(); | 308 return new AudioManagerWin(); |
315 } | 309 } |
OLD | NEW |