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> |
11 #include <setupapi.h> | 11 #include <setupapi.h> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/process_util.h" | 18 #include "base/process_util.h" |
19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
21 #include "base/win/windows_version.h" | 21 #include "base/win/windows_version.h" |
22 #include "media/audio/fake_audio_input_stream.h" | 22 #include "media/audio/fake_audio_input_stream.h" |
23 #include "media/audio/fake_audio_output_stream.h" | 23 #include "media/audio/fake_audio_output_stream.h" |
24 #include "media/audio/win/audio_low_latency_input_win.h" | 24 #include "media/audio/win/audio_low_latency_input_win.h" |
25 #include "media/audio/win/audio_low_latency_output_win.h" | 25 #include "media/audio/win/audio_low_latency_output_win.h" |
26 #include "media/audio/win/audio_manager_win.h" | 26 #include "media/audio/win/audio_manager_win.h" |
27 #include "media/audio/win/device_enumeration_win.h" | |
27 #include "media/audio/win/wavein_input_win.h" | 28 #include "media/audio/win/wavein_input_win.h" |
28 #include "media/audio/win/waveout_output_win.h" | 29 #include "media/audio/win/waveout_output_win.h" |
29 #include "media/base/limits.h" | 30 #include "media/base/limits.h" |
30 | 31 |
31 // Libraries required for the SetupAPI and Wbem APIs used here. | 32 // Libraries required for the SetupAPI and Wbem APIs used here. |
32 #pragma comment(lib, "setupapi.lib") | 33 #pragma comment(lib, "setupapi.lib") |
33 | 34 |
34 // The following are defined in various DDK headers, and we (re)define them | 35 // The following are defined in various DDK headers, and we (re)define them |
35 // here to avoid adding the DDK as a chrome dependency. | 36 // here to avoid adding the DDK as a chrome dependency. |
36 #define DRV_QUERYDEVICEINTERFACE 0x80c | 37 #define DRV_QUERYDEVICEINTERFACE 0x80c |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 } | 93 } |
93 | 94 |
94 SetupDiSetDeviceInstallParams(device_info, device_data, | 95 SetupDiSetDeviceInstallParams(device_info, device_data, |
95 &old_device_install_params); | 96 &old_device_install_params); |
96 | 97 |
97 return device_and_driver_info; | 98 return device_and_driver_info; |
98 } | 99 } |
99 | 100 |
100 AudioManagerWin::AudioManagerWin() | 101 AudioManagerWin::AudioManagerWin() |
101 : num_output_streams_(0) { | 102 : num_output_streams_(0) { |
103 if (base::win::GetVersion() <= base::win::VERSION_XP) { | |
104 // Use the Wave API for device enumeration if XP or lower. | |
105 enumeration_type_ = kWaveEnumeration; | |
106 } else { | |
107 // Use the MMDevice API for device enumeration if Vista or higher. | |
108 enumeration_type_ = kMMDeviceEnumeration; | |
109 } | |
102 } | 110 } |
103 | 111 |
104 AudioManagerWin::~AudioManagerWin() { | 112 AudioManagerWin::~AudioManagerWin() { |
105 } | 113 } |
106 | 114 |
107 bool AudioManagerWin::HasAudioOutputDevices() { | 115 bool AudioManagerWin::HasAudioOutputDevices() { |
108 return (::waveOutGetNumDevs() != 0); | 116 return (::waveOutGetNumDevs() != 0); |
109 } | 117 } |
110 | 118 |
111 bool AudioManagerWin::HasAudioInputDevices() { | 119 bool AudioManagerWin::HasAudioInputDevices() { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 FilePath path; | 281 FilePath path; |
274 PathService::Get(base::DIR_SYSTEM, &path); | 282 PathService::Get(base::DIR_SYSTEM, &path); |
275 path = path.Append(program); | 283 path = path.Append(program); |
276 CommandLine command_line(path); | 284 CommandLine command_line(path); |
277 command_line.AppendArg(argument); | 285 command_line.AppendArg(argument); |
278 base::LaunchProcess(command_line, base::LaunchOptions(), NULL); | 286 base::LaunchProcess(command_line, base::LaunchOptions(), NULL); |
279 } | 287 } |
280 | 288 |
281 void AudioManagerWin::GetAudioInputDeviceNames( | 289 void AudioManagerWin::GetAudioInputDeviceNames( |
282 media::AudioDeviceNames* device_names) { | 290 media::AudioDeviceNames* device_names) { |
283 // TODO(xians): query a full list of valid devices. | 291 DCHECK(enumeration_type() != kUninitializedEnumeration); |
284 if (HasAudioInputDevices()) { | 292 // Enumerate all active audio-endpoint capture devices. |
285 // Add the default device to the list. | 293 if (enumeration_type() == kWaveEnumeration) { |
286 // We use index 0 to make up the unique_id to identify the | 294 // Utilize the Wave API for Windows XP. |
287 // default devices. | 295 GetInputDeviceNamesWinXP(device_names); |
296 } else { | |
297 // Utilize the MMDevice API (part of Core Audio) for Vista and higher. | |
298 GetInputDeviceNamesWin(device_names); | |
299 } | |
300 | |
301 // Always add default device parameters as first element. | |
302 if (!device_names->empty()) { | |
288 media::AudioDeviceName name; | 303 media::AudioDeviceName name; |
289 name.device_name = AudioManagerBase::kDefaultDeviceName; | 304 name.device_name = AudioManagerBase::kDefaultDeviceName; |
290 name.unique_id = AudioManagerBase::kDefaultDeviceId; | 305 name.unique_id = AudioManagerBase::kDefaultDeviceId; |
291 device_names->push_back(name); | 306 device_names->push_front(name); |
292 } | 307 } |
293 } | 308 } |
294 | 309 |
295 // static | 310 /// static |
tommi (sloooow) - chröme
2011/11/23 09:47:13
//
| |
296 AudioManager* AudioManager::CreateAudioManager() { | 311 AudioManager* AudioManager::CreateAudioManager() { |
297 return new AudioManagerWin(); | 312 return new AudioManagerWin(); |
298 } | 313 } |
OLD | NEW |