Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: media/audio/win/audio_manager_win.cc

Issue 9566002: On windows, create PCMWaveInAudioInputStream instance with correct device ID. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/audio/win/audio_manager_win.h ('k') | media/audio/win/device_enumeration_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 command_line.AppendArg(argument); 210 command_line.AppendArg(argument);
211 base::LaunchProcess(command_line, base::LaunchOptions(), NULL); 211 base::LaunchProcess(command_line, base::LaunchOptions(), NULL);
212 } 212 }
213 213
214 void AudioManagerWin::GetAudioInputDeviceNames( 214 void AudioManagerWin::GetAudioInputDeviceNames(
215 media::AudioDeviceNames* device_names) { 215 media::AudioDeviceNames* device_names) {
216 DCHECK(enumeration_type() != kUninitializedEnumeration); 216 DCHECK(enumeration_type() != kUninitializedEnumeration);
217 // Enumerate all active audio-endpoint capture devices. 217 // Enumerate all active audio-endpoint capture devices.
218 if (enumeration_type() == kWaveEnumeration) { 218 if (enumeration_type() == kWaveEnumeration) {
219 // Utilize the Wave API for Windows XP. 219 // Utilize the Wave API for Windows XP.
220 GetInputDeviceNamesWinXP(device_names); 220 media::GetInputDeviceNamesWinXP(device_names);
221 } else { 221 } else {
222 // Utilize the MMDevice API (part of Core Audio) for Vista and higher. 222 // Utilize the MMDevice API (part of Core Audio) for Vista and higher.
223 GetInputDeviceNamesWin(device_names); 223 media::GetInputDeviceNamesWin(device_names);
224 } 224 }
225 225
226 // Always add default device parameters as first element. 226 // Always add default device parameters as first element.
227 if (!device_names->empty()) { 227 if (!device_names->empty()) {
228 media::AudioDeviceName name; 228 media::AudioDeviceName name;
229 name.device_name = AudioManagerBase::kDefaultDeviceName; 229 name.device_name = AudioManagerBase::kDefaultDeviceName;
230 name.unique_id = AudioManagerBase::kDefaultDeviceId; 230 name.unique_id = AudioManagerBase::kDefaultDeviceId;
231 device_names->push_front(name); 231 device_names->push_front(name);
232 } 232 }
233 } 233 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 267 }
268 268
269 return stream; 269 return stream;
270 } 270 }
271 271
272 // Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR 272 // Factory for the implementations of AudioInputStream for AUDIO_PCM_LINEAR
273 // mode. 273 // mode.
274 AudioInputStream* AudioManagerWin::MakeLinearInputStream( 274 AudioInputStream* AudioManagerWin::MakeLinearInputStream(
275 const AudioParameters& params, const std::string& device_id) { 275 const AudioParameters& params, const std::string& device_id) {
276 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format); 276 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format);
277 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, 277 return CreatePCMWaveInAudioInputStream(params, device_id);
278 AudioManagerBase::kDefaultDeviceId);
279 } 278 }
280 279
281 // Factory for the implementations of AudioInputStream for 280 // Factory for the implementations of AudioInputStream for
282 // AUDIO_PCM_LOW_LATENCY mode. 281 // AUDIO_PCM_LOW_LATENCY mode.
283 AudioInputStream* AudioManagerWin::MakeLowLatencyInputStream( 282 AudioInputStream* AudioManagerWin::MakeLowLatencyInputStream(
284 const AudioParameters& params, const std::string& device_id) { 283 const AudioParameters& params, const std::string& device_id) {
285 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format); 284 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format);
286 AudioInputStream* stream = NULL; 285 AudioInputStream* stream = NULL;
287 if (!media::IsWASAPISupported()) { 286 if (!media::IsWASAPISupported()) {
288 // Fall back to Windows Wave implementation on Windows XP or lower. 287 // Fall back to Windows Wave implementation on Windows XP or lower.
289 DVLOG(1) << "Using WaveIn since WASAPI requires at least Vista."; 288 DVLOG(1) << "Using WaveIn since WASAPI requires at least Vista.";
290 stream = new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, 289 stream = CreatePCMWaveInAudioInputStream(params, device_id);
291 device_id);
292 } else { 290 } else {
293 stream = new WASAPIAudioInputStream(this, params, device_id); 291 stream = new WASAPIAudioInputStream(this, params, device_id);
294 } 292 }
295 293
296 return stream; 294 return stream;
297 } 295 }
298 296
297 AudioInputStream* AudioManagerWin::CreatePCMWaveInAudioInputStream(
298 const AudioParameters& params,
299 const std::string& device_id) {
300 std::string xp_device_id = device_id;
301 if (device_id != AudioManagerBase::kDefaultDeviceId &&
302 enumeration_type_ == kMMDeviceEnumeration) {
303 xp_device_id = media::ConvertToWinXPDeviceId(device_id);
304 if (xp_device_id.empty()) {
305 DLOG(ERROR) << "Cannot find a waveIn device which matches the device ID "
306 << device_id;
307 return NULL;
308 }
309 }
310
311 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers,
312 xp_device_id);
313 }
314
299 /// static 315 /// static
300 AudioManager* CreateAudioManager() { 316 AudioManager* CreateAudioManager() {
301 return new AudioManagerWin(); 317 return new AudioManagerWin();
302 } 318 }
OLDNEW
« no previous file with comments | « media/audio/win/audio_manager_win.h ('k') | media/audio/win/device_enumeration_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698