Chromium Code Reviews| Index: media/audio/win/audio_manager_win.cc |
| =================================================================== |
| --- media/audio/win/audio_manager_win.cc (revision 110683) |
| +++ media/audio/win/audio_manager_win.cc (working copy) |
| @@ -24,6 +24,7 @@ |
| #include "media/audio/win/audio_low_latency_input_win.h" |
| #include "media/audio/win/audio_low_latency_output_win.h" |
| #include "media/audio/win/audio_manager_win.h" |
| +#include "media/audio/win/device_enumeration_win.h" |
| #include "media/audio/win/wavein_input_win.h" |
| #include "media/audio/win/waveout_output_win.h" |
| #include "media/base/limits.h" |
| @@ -55,6 +56,10 @@ |
| // play. |
| static const int kNumInputBuffers = 3; |
| +// TODO(henrika): add comment |
| +AudioManagerWin::EnumerationType AudioManagerWin::enumeration_type_ = |
|
tommi (sloooow) - chröme
2011/11/22 12:52:37
see comment elsewhere about this global variable.
henrika (OOO until Aug 14)
2011/11/23 09:19:19
Will use private member instead.
|
| + AudioManagerWin::kUninitializedEnumeration; |
| + |
| static int GetVersionPartAsInt(DWORDLONG num) { |
| return static_cast<int>(num & 0xffff); |
| } |
| @@ -99,6 +104,13 @@ |
| AudioManagerWin::AudioManagerWin() |
| : num_output_streams_(0) { |
| + if (base::win::GetVersion() <= base::win::VERSION_XP) { |
| + // Use the Wave API for device enumeration if XP or lower. |
| + enumeration_type_ = kWaveEnumeration; |
| + } else { |
| + // Use the MMDevice API for device enumeration if Vista or higher. |
| + enumeration_type_ = kMMDeviceEnumeration; |
| + } |
| } |
| AudioManagerWin::~AudioManagerWin() { |
| @@ -275,15 +287,24 @@ |
| void AudioManagerWin::GetAudioInputDeviceNames( |
| media::AudioDeviceNames* device_names) { |
| - // TODO(xians): query a full list of valid devices. |
| - if (HasAudioInputDevices()) { |
| - // Add the default device to the list. |
| - // We use index 0 to make up the unique_id to identify the |
| - // default devices. |
| + DCHECK(enumeration_type() != kUninitializedEnumeration); |
| + // Enumerate all active audio-endpoint capture devices. |
| + if (enumeration_type() == kWaveEnumeration) { |
| + // Utilize the Wave API for Windows XP. |
| + GetInputDeviceNamesWinXP(device_names); |
| + } else { |
| + // Utilize the MMDevice API (part of Core Audio) for Vista and higher. |
| + GetInputDeviceNamesWin(device_names); |
| + } |
| + |
| + // Always add default device parameters as first element. |
| + if (!device_names->empty()) { |
| media::AudioDeviceName name; |
| name.device_name = AudioManagerBase::kDefaultDeviceName; |
| + // TODO(henrika): modify to AudioManagerBase::kXXX when pending patch has |
| + // landed. |
| name.unique_id = "0"; |
| - device_names->push_back(name); |
| + device_names->push_front(name); |
| } |
| } |