Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(855)

Unified Diff: media/audio/win/core_audio_util_win.cc

Issue 12378066: Improved CoreAudioUtil::IsSupported() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/win/core_audio_util_win.cc
diff --git a/media/audio/win/core_audio_util_win.cc b/media/audio/win/core_audio_util_win.cc
index 4bae7b93f44caa3cb516935d4d69162d48e3dd4a..a28ce4bbe8a47247a5083320c0556128bf6e37c3 100644
--- a/media/audio/win/core_audio_util_win.cc
+++ b/media/audio/win/core_audio_util_win.cc
@@ -76,6 +76,16 @@ bool LoadAudiosesDll() {
return (LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) != NULL);
}
+bool CanCreateDeviceEnumerator() {
+ ScopedComPtr<IMMDeviceEnumerator> device_enumerator;
+ HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator),
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ __uuidof(IMMDeviceEnumerator),
+ device_enumerator.ReceiveVoid());
+ return SUCCEEDED(hr);
tommi (sloooow) - chröme 2013/03/05 09:32:10 add a check here: CHECK_NE(hr, CO_E_NOTINITIALIZED
henrika (OOO until Aug 14) 2013/03/05 09:49:35 Done.
+}
+
bool CoreAudioUtil::IsSupported() {
// Microsoft does not plan to make the Core Audio APIs available for use
// with earlier versions of Windows, including Microsoft Windows Server 2003,
@@ -90,7 +100,15 @@ bool CoreAudioUtil::IsSupported() {
// See http://crbug.com/166397 why this extra step is required to guarantee
// Core Audio support.
static bool g_audioses_dll_available = LoadAudiosesDll();
- return g_audioses_dll_available;
+ if (g_audioses_dll_available)
DaleCurtis 2013/03/04 17:18:26 !g_audioses_dll_available ?
henrika (OOO until Aug 14) 2013/03/05 09:09:11 My bad. Will fix. Thanks!
+ return false;
+
+ // Being able to load the Audioses.dll does not seem to be sufficient for
+ // all devices to guarantee Core Audio support. To be 100%, we also verify
+ // that it is possible to a create the IMMDeviceEnumerator interface. If this
+ // works as well we should be home free.
+ static bool g_can_create_device_enumerator = CanCreateDeviceEnumerator();
tommi (sloooow) - chröme 2013/03/04 17:29:01 If this function is called on a non-COM initialize
henrika (OOO until Aug 14) 2013/03/05 09:09:11 Tommi, great comments as usual, please see replies
tommi (sloooow) - chröme 2013/03/05 09:32:10 Yes, that sounds OK with me but ask that we add th
henrika (OOO until Aug 14) 2013/03/05 09:49:35 Got it, thanks. Part of my comments above were inv
+ return g_can_create_device_enumerator;
}
base::TimeDelta CoreAudioUtil::RefererenceTimeToTimeDelta(REFERENCE_TIME time) {
@@ -141,9 +159,8 @@ ScopedComPtr<IMMDeviceEnumerator> CoreAudioUtil::CreateDeviceEnumerator() {
CLSCTX_INPROC_SERVER,
__uuidof(IMMDeviceEnumerator),
device_enumerator.ReceiveVoid());
- // CO_E_NOTINITIALIZED is the most likely reason for failure and if that
- // happens we might as well die here.
- CHECK(SUCCEEDED(hr));
+ LOG_IF(ERROR, FAILED(hr)) << "IMMDeviceEnumerator::CreateDeviceEnumerator: "
+ << std::hex << hr;
return device_enumerator;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698