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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 static ScopedComPtr<IMMDeviceEnumerator> CreateDeviceEnumeratorInternal() { | 171 static ScopedComPtr<IMMDeviceEnumerator> CreateDeviceEnumeratorInternal() { |
172 ScopedComPtr<IMMDeviceEnumerator> device_enumerator; | 172 ScopedComPtr<IMMDeviceEnumerator> device_enumerator; |
173 HRESULT hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), | 173 HRESULT hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), |
174 NULL, CLSCTX_INPROC_SERVER); | 174 NULL, CLSCTX_INPROC_SERVER); |
175 if (hr == CO_E_NOTINITIALIZED) { | 175 if (hr == CO_E_NOTINITIALIZED) { |
176 LOG(ERROR) << "CoCreateInstance fails with CO_E_NOTINITIALIZED"; | 176 LOG(ERROR) << "CoCreateInstance fails with CO_E_NOTINITIALIZED"; |
177 // We have seen crashes which indicates that this method can in fact | 177 // We have seen crashes which indicates that this method can in fact |
178 // fail with CO_E_NOTINITIALIZED in combination with certain 3rd party | 178 // fail with CO_E_NOTINITIALIZED in combination with certain 3rd party |
179 // modules. Calling CoInitializeEx is an attempt to resolve the reported | 179 // modules. Calling CoInitializeEx is an attempt to resolve the reported |
180 // issues. See http://crbug.com/378465 for details. | 180 // issues. See http://crbug.com/378465 for details. |
181 hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); | 181 hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); |
182 if (SUCCEEDED(hr)) { | 182 if (SUCCEEDED(hr)) { |
183 hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), | 183 hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), NULL, |
184 NULL, CLSCTX_INPROC_SERVER); | 184 CLSCTX_INPROC_SERVER); |
| 185 } else { |
| 186 LOG(ERROR) << "CoCreateInstance still failed! " << std::hex << hr; |
185 } | 187 } |
186 } | 188 } |
187 return device_enumerator; | 189 return device_enumerator; |
188 } | 190 } |
189 | 191 |
190 static bool IsRemoteSession() { | 192 static bool IsRemoteSession() { |
191 return !!GetSystemMetrics(SM_REMOTESESSION); | 193 return !!GetSystemMetrics(SM_REMOTESESSION); |
192 } | 194 } |
193 | 195 |
194 static bool IsRemoteDeviceInternal(IMMDevice* device) { | 196 static bool IsRemoteDeviceInternal(IMMDevice* device) { |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 if (!IsRemoteSession()) | 913 if (!IsRemoteSession()) |
912 return false; | 914 return false; |
913 ScopedComPtr<IMMDevice> device(device_id.empty() | 915 ScopedComPtr<IMMDevice> device(device_id.empty() |
914 ? CreateDefaultDevice(eRender, eConsole) | 916 ? CreateDefaultDevice(eRender, eConsole) |
915 : CreateDevice(device_id)); | 917 : CreateDevice(device_id)); |
916 // Assume remote audio if we can't tell. | 918 // Assume remote audio if we can't tell. |
917 return device ? IsRemoteDeviceInternal(device.get()) : true; | 919 return device ? IsRemoteDeviceInternal(device.get()) : true; |
918 } | 920 } |
919 | 921 |
920 } // namespace media | 922 } // namespace media |
OLD | NEW |