OLD | NEW |
---|---|
1 // Copyright (c) 2011 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_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> |
11 #include <setupapi.h> | 11 #include <setupapi.h> |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 // Factory for the implementations of AudioInputStream. | 159 // Factory for the implementations of AudioInputStream. |
160 AudioInputStream* AudioManagerWin::MakeAudioInputStream( | 160 AudioInputStream* AudioManagerWin::MakeAudioInputStream( |
161 const AudioParameters& params, const std::string& device_id) { | 161 const AudioParameters& params, const std::string& device_id) { |
162 if (!params.IsValid() || (params.channels > kWinMaxInputChannels) || | 162 if (!params.IsValid() || (params.channels > kWinMaxInputChannels) || |
163 device_id.empty()) | 163 device_id.empty()) |
164 return NULL; | 164 return NULL; |
165 | 165 |
166 if (params.format == AudioParameters::AUDIO_MOCK) { | 166 if (params.format == AudioParameters::AUDIO_MOCK) { |
167 return FakeAudioInputStream::MakeFakeStream(params); | 167 return FakeAudioInputStream::MakeFakeStream(params); |
168 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { | 168 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { |
169 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 169 return CreatePCMWaveInAudioInputStream(params, device_id); |
170 AudioManagerBase::kDefaultDeviceId); | |
171 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { | 170 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { |
172 if (!media::IsWASAPISupported()) { | 171 if (!media::IsWASAPISupported()) { |
173 // Fall back to Windows Wave implementation on Windows XP or lower. | 172 // Fall back to Windows Wave implementation on Windows XP or lower. |
174 DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista."; | 173 DLOG(INFO) << "Using WaveIn since WASAPI requires at least Vista."; |
175 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 174 return CreatePCMWaveInAudioInputStream(params, device_id); |
176 device_id); | |
177 } else { | 175 } else { |
178 return new WASAPIAudioInputStream(this, params, device_id); | 176 return new WASAPIAudioInputStream(this, params, device_id); |
179 } | 177 } |
180 } | 178 } |
181 return NULL; | 179 return NULL; |
182 } | 180 } |
183 | 181 |
184 void AudioManagerWin::ReleaseOutputStream(AudioOutputStream* stream) { | 182 void AudioManagerWin::ReleaseOutputStream(AudioOutputStream* stream) { |
185 DCHECK(stream); | 183 DCHECK(stream); |
186 num_output_streams_--; | 184 num_output_streams_--; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 | 296 |
299 // Always add default device parameters as first element. | 297 // Always add default device parameters as first element. |
300 if (!device_names->empty()) { | 298 if (!device_names->empty()) { |
301 media::AudioDeviceName name; | 299 media::AudioDeviceName name; |
302 name.device_name = AudioManagerBase::kDefaultDeviceName; | 300 name.device_name = AudioManagerBase::kDefaultDeviceName; |
303 name.unique_id = AudioManagerBase::kDefaultDeviceId; | 301 name.unique_id = AudioManagerBase::kDefaultDeviceId; |
304 device_names->push_front(name); | 302 device_names->push_front(name); |
305 } | 303 } |
306 } | 304 } |
307 | 305 |
306 AudioInputStream* AudioManagerWin::CreatePCMWaveInAudioInputStream( | |
307 const AudioParameters& params, | |
308 const std::string& device_id) { | |
309 if (device_id != AudioManagerBase::kDefaultDeviceId && | |
310 enumeration_type_ == kMMDeviceEnumeration) { | |
311 std::string xp_device_id = ConvertToWinXPDeviceId(device_id); | |
312 if (!xp_device_id.empty()) { | |
313 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | |
314 xp_device_id); | |
315 } else { | |
316 return NULL; | |
no longer working on chromium
2012/03/05 09:58:39
It looks like an unexpected error to me, adding a
yzshen1
2012/03/13 21:09:23
Done.
| |
317 } | |
318 } | |
319 | |
320 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | |
321 device_id); | |
no longer working on chromium
2012/03/05 09:58:39
Just a personal preference, feel free to ignore if
yzshen1
2012/03/13 21:09:23
Done.
| |
322 } | |
323 | |
308 /// static | 324 /// static |
309 AudioManager* CreateAudioManager() { | 325 AudioManager* CreateAudioManager() { |
310 return new AudioManagerWin(); | 326 return new AudioManagerWin(); |
311 } | 327 } |
OLD | NEW |