| 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 |
| 237 ScopedComPtr<IMMDevice> CoreAudioUtil::CreateDefaultDevice(EDataFlow data_flow, | 249 ScopedComPtr<IMMDevice> CoreAudioUtil::CreateDefaultDevice(EDataFlow data_flow, |
| 238 ERole role) { | 250 ERole role) { |
| 239 DCHECK(IsSupported()); | 251 DCHECK(IsSupported()); |
| 240 ScopedComPtr<IMMDevice> endpoint_device; | 252 ScopedComPtr<IMMDevice> endpoint_device; |
| 241 | 253 |
| 242 // Create the IMMDeviceEnumerator interface. | 254 // Create the IMMDeviceEnumerator interface. |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 return false; | 842 return false; |
| 831 | 843 |
| 832 // Using the AUDCLNT_BUFFERFLAGS_SILENT flag eliminates the need to | 844 // Using the AUDCLNT_BUFFERFLAGS_SILENT flag eliminates the need to |
| 833 // explicitly write silence data to the rendering buffer. | 845 // explicitly write silence data to the rendering buffer. |
| 834 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; | 846 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; |
| 835 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, | 847 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, |
| 836 AUDCLNT_BUFFERFLAGS_SILENT)); | 848 AUDCLNT_BUFFERFLAGS_SILENT)); |
| 837 } | 849 } |
| 838 | 850 |
| 839 } // namespace media | 851 } // namespace media |
| OLD | NEW |