OLD | NEW |
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 <MMDeviceAPI.h> | 5 #include <MMDeviceAPI.h> |
6 #include <mmsystem.h> | 6 #include <mmsystem.h> |
7 #include <Functiondiscoverykeys_devpkey.h> // MMDeviceAPI.h must come first | 7 #include <Functiondiscoverykeys_devpkey.h> // MMDeviceAPI.h must come first |
8 | 8 |
9 #include "media/audio/win/audio_manager_win.h" | 9 #include "media/audio/win/audio_manager_win.h" |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 bool GetInputDeviceNamesWin(AudioDeviceNames* device_names) { | 27 bool GetInputDeviceNamesWin(AudioDeviceNames* device_names) { |
28 // It is assumed that this method is called from a COM thread, i.e., | 28 // It is assumed that this method is called from a COM thread, i.e., |
29 // CoInitializeEx() is not called here again to avoid STA/MTA conflicts. | 29 // CoInitializeEx() is not called here again to avoid STA/MTA conflicts. |
30 ScopedComPtr<IMMDeviceEnumerator> enumerator; | 30 ScopedComPtr<IMMDeviceEnumerator> enumerator; |
31 HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), | 31 HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), |
32 NULL, | 32 NULL, |
33 CLSCTX_INPROC_SERVER, | 33 CLSCTX_INPROC_SERVER, |
34 __uuidof(IMMDeviceEnumerator), | 34 __uuidof(IMMDeviceEnumerator), |
35 enumerator.ReceiveVoid()); | 35 enumerator.ReceiveVoid()); |
| 36 DCHECK_NE(hr, CO_E_NOTINITIALIZED); |
36 if (FAILED(hr)) { | 37 if (FAILED(hr)) { |
37 LOG(WARNING) << "Failed to create IMMDeviceEnumerator: " << std::hex << hr; | 38 LOG(WARNING) << "Failed to create IMMDeviceEnumerator: " << std::hex << hr; |
38 return false; | 39 return false; |
39 } | 40 } |
40 | 41 |
41 // Generate a collection of active audio capture endpoint devices. | 42 // Generate a collection of active audio capture endpoint devices. |
42 // This method will succeed even if all devices are disabled. | 43 // This method will succeed even if all devices are disabled. |
43 ScopedComPtr<IMMDeviceCollection> collection; | 44 ScopedComPtr<IMMDeviceCollection> collection; |
44 hr = enumerator->EnumAudioEndpoints(eCapture, | 45 hr = enumerator->EnumAudioEndpoints(eCapture, |
45 DEVICE_STATE_ACTIVE, | 46 DEVICE_STATE_ACTIVE, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 171 |
171 result = waveInGetDevCaps(i, &capabilities, sizeof(capabilities)); | 172 result = waveInGetDevCaps(i, &capabilities, sizeof(capabilities)); |
172 if (result == MMSYSERR_NOERROR) | 173 if (result == MMSYSERR_NOERROR) |
173 return WideToUTF8(capabilities.szPname); | 174 return WideToUTF8(capabilities.szPname); |
174 } | 175 } |
175 | 176 |
176 return std::string(); | 177 return std::string(); |
177 } | 178 } |
178 | 179 |
179 } // namespace media | 180 } // namespace media |
OLD | NEW |