Chromium Code Reviews| 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 "media/audio/win/core_audio_util_win.h" | 5 #include "media/audio/win/core_audio_util_win.h" |
| 6 | 6 |
| 7 #include <audioclient.h> | 7 #include <audioclient.h> |
| 8 #include <devicetopology.h> | 8 #include <devicetopology.h> |
| 9 #include <functiondiscoverykeys_devpkey.h> | 9 #include <functiondiscoverykeys_devpkey.h> |
| 10 | 10 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 DVLOG(2) << ((data_flow == eCapture) ? "[in ] " : "[out] ") | 223 DVLOG(2) << ((data_flow == eCapture) ? "[in ] " : "[out] ") |
| 224 << "number of devices: " << number_of_active_devices; | 224 << "number of devices: " << number_of_active_devices; |
| 225 return static_cast<int>(number_of_active_devices); | 225 return static_cast<int>(number_of_active_devices); |
| 226 } | 226 } |
| 227 | 227 |
| 228 ScopedComPtr<IMMDeviceEnumerator> CoreAudioUtil::CreateDeviceEnumerator() { | 228 ScopedComPtr<IMMDeviceEnumerator> CoreAudioUtil::CreateDeviceEnumerator() { |
| 229 DCHECK(IsSupported()); | 229 DCHECK(IsSupported()); |
| 230 ScopedComPtr<IMMDeviceEnumerator> device_enumerator; | 230 ScopedComPtr<IMMDeviceEnumerator> device_enumerator; |
| 231 HRESULT hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), | 231 HRESULT hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), |
| 232 NULL, CLSCTX_INPROC_SERVER); | 232 NULL, CLSCTX_INPROC_SERVER); |
| 233 if (hr == CO_E_NOTINITIALIZED) { | |
| 234 LOG(ERROR) << "CoCreateInstance fails with CO_E_NOTINITIALIZED"; | |
| 235 // We have seen crashes which indicates that this method can in fact | |
| 236 // fail with CO_E_NOTINITIALIZED in combination with certain 3rd party | |
| 237 // modules. Calling CoInitializeEx is an attempt to resolve the reported | |
| 238 // issues. See http://crbug.com/378465 for details. | |
| 239 hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); | |
| 240 if (SUCCEEDED(hr)) { | |
| 241 hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), | |
| 242 NULL, CLSCTX_INPROC_SERVER); | |
| 243 } | |
| 244 } | |
| 233 CHECK(SUCCEEDED(hr)); | 245 CHECK(SUCCEEDED(hr)); |
| 234 return device_enumerator; | 246 return device_enumerator; |
| 235 } | 247 } |
| 236 | 248 |
| 249 | |
|
tommi (sloooow) - chröme
2014/06/12 10:56:20
one line should be enough :)
henrika (OOO until Aug 14)
2014/06/12 11:01:19
Ooops, sorry.
| |
| 237 ScopedComPtr<IMMDevice> CoreAudioUtil::CreateDefaultDevice(EDataFlow data_flow, | 250 ScopedComPtr<IMMDevice> CoreAudioUtil::CreateDefaultDevice(EDataFlow data_flow, |
| 238 ERole role) { | 251 ERole role) { |
| 239 DCHECK(IsSupported()); | 252 DCHECK(IsSupported()); |
| 240 ScopedComPtr<IMMDevice> endpoint_device; | 253 ScopedComPtr<IMMDevice> endpoint_device; |
| 241 | 254 |
| 242 // Create the IMMDeviceEnumerator interface. | 255 // Create the IMMDeviceEnumerator interface. |
| 243 ScopedComPtr<IMMDeviceEnumerator> device_enumerator = | 256 ScopedComPtr<IMMDeviceEnumerator> device_enumerator = |
| 244 CreateDeviceEnumerator(); | 257 CreateDeviceEnumerator(); |
| 245 if (!device_enumerator) | 258 if (!device_enumerator) |
| 246 return endpoint_device; | 259 return endpoint_device; |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 830 return false; | 843 return false; |
| 831 | 844 |
| 832 // Using the AUDCLNT_BUFFERFLAGS_SILENT flag eliminates the need to | 845 // Using the AUDCLNT_BUFFERFLAGS_SILENT flag eliminates the need to |
| 833 // explicitly write silence data to the rendering buffer. | 846 // explicitly write silence data to the rendering buffer. |
| 834 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; | 847 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; |
| 835 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, | 848 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, |
| 836 AUDCLNT_BUFFERFLAGS_SILENT)); | 849 AUDCLNT_BUFFERFLAGS_SILENT)); |
| 837 } | 850 } |
| 838 | 851 |
| 839 } // namespace media | 852 } // namespace media |
| OLD | NEW |