Chromium Code Reviews| Index: media/audio/win/device_enumeration_win.cc |
| diff --git a/media/audio/win/device_enumeration_win.cc b/media/audio/win/device_enumeration_win.cc |
| index 0087a89e3f4e35fecbb7a0dd61d8d0b049faec74..87e4e9230ded3910768c38a65b85a65ac4b3e8b9 100644 |
| --- a/media/audio/win/device_enumeration_win.cc |
| +++ b/media/audio/win/device_enumeration_win.cc |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| @@ -17,6 +17,15 @@ using media::AudioDeviceNames; |
| using base::win::ScopedComPtr; |
| using base::win::ScopedCoMem; |
| +namespace { |
|
henrika (OOO until Aug 14)
2012/03/05 08:50:45
Guess you can remove the namespace part here. Shou
yzshen1
2012/03/13 21:09:23
Done.
|
| + |
| +// Taken from Mmddk.h. |
| +#define DRV_RESERVED 0x0800 |
| +#define DRV_QUERYFUNCTIONINSTANCEID (DRV_RESERVED + 17) |
| +#define DRV_QUERYFUNCTIONINSTANCEIDSIZE (DRV_RESERVED + 18) |
| + |
| +} // namespace |
| + |
|
no longer working on chromium
2012/03/05 09:58:39
Since we have been here.
Preferably we should put
yzshen1
2012/03/13 21:09:23
Sure. :)
On 2012/03/05 09:58:39, xians1 wrote:
|
| bool GetInputDeviceNamesWin(AudioDeviceNames* device_names) { |
| // It is assumed that this method is called from a COM thread, i.e., |
| // CoInitializeEx() is not called here again to avoid STA/MTA conflicts. |
| @@ -123,3 +132,43 @@ bool GetInputDeviceNamesWinXP(AudioDeviceNames* device_names) { |
| return true; |
| } |
| + |
| +std::string ConvertToWinXPDeviceId(const std::string& device_id) { |
| + UINT number_of_active_devices = waveInGetNumDevs(); |
| + MMRESULT result = MMSYSERR_NOERROR; |
| + |
| + UINT i = 0; |
| + for (; i < number_of_active_devices; ++i) { |
| + size_t size = 0; |
| + result = waveInMessage(reinterpret_cast<HWAVEIN>(i), |
|
henrika (OOO until Aug 14)
2012/03/05 08:50:45
I would add a comment (like in the MSDN example) h
yzshen1
2012/03/13 21:09:23
Done.
|
| + DRV_QUERYFUNCTIONINSTANCEIDSIZE, |
| + reinterpret_cast<DWORD_PTR>(&size), NULL); |
| + if (result != MMSYSERR_NOERROR) |
| + continue; |
| + |
| + ScopedCoMem<WCHAR> id; |
| + id.Reset(static_cast<WCHAR*>(CoTaskMemAlloc(size))); |
| + if (!id) |
| + continue; |
| + |
| + result = waveInMessage( |
|
henrika (OOO until Aug 14)
2012/03/05 08:50:45
Please comment to make the code more readable. Tha
yzshen1
2012/03/13 21:09:23
Done.
|
| + reinterpret_cast<HWAVEIN>(i), DRV_QUERYFUNCTIONINSTANCEID, |
| + reinterpret_cast<DWORD_PTR>(static_cast<WCHAR*>(id)), size); |
| + if (result != MMSYSERR_NOERROR) |
| + continue; |
| + |
| + std::string utf8_id = WideToUTF8(static_cast<WCHAR*>(id)); |
|
henrika (OOO until Aug 14)
2012/03/05 08:50:45
// Check whether the endpoint ID string of this wa
yzshen1
2012/03/13 21:09:23
Done.
|
| + if (device_id == utf8_id) |
| + break; |
| + } |
| + |
| + if (i < number_of_active_devices) { |
| + WAVEINCAPS capabilities; |
| + |
| + result = waveInGetDevCaps(i, &capabilities, sizeof(capabilities)); |
|
henrika (OOO until Aug 14)
2012/03/05 08:50:45
Comment that we convert the unique endpoint ID str
yzshen1
2012/03/13 21:09:23
Done.
|
| + if (result == MMSYSERR_NOERROR) |
| + return WideToUTF8(capabilities.szPname); |
| + } |
| + |
| + return std::string(); |
| +} |