summaryrefslogtreecommitdiffstats
path: root/media/audio
diff options
context:
space:
mode:
authorhenrika@chromium.org <henrika@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-05 13:08:35 +0000
committerhenrika@chromium.org <henrika@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-05 13:08:35 +0000
commitb9079d4b60ce88c45a8e9f8b79199f6fff4b2809 (patch)
tree3bca42acc7dcffb21693ab72d592f8749eec690a /media/audio
parent1fb496da072e049fba1baa04712abc54af009499 (diff)
downloadchromium_src-b9079d4b60ce88c45a8e9f8b79199f6fff4b2809.zip
chromium_src-b9079d4b60ce88c45a8e9f8b79199f6fff4b2809.tar.gz
chromium_src-b9079d4b60ce88c45a8e9f8b79199f6fff4b2809.tar.bz2
Improved CoreAudioUtil::IsSupported().
This patch adds one more test in CoreAudioUtil::IsSupported() and that is to be able to create an IMMDeviceEnumerator. We have seen some crashes where it does not seem to be sufficient to check that Audioses.dll can be loaded. I hope we are fine now. BUG=166397 TEST=media_unittests and different audio clients in Chrome. Review URL: https://chromiumcodereview.appspot.com/12378066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186166 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio')
-rw-r--r--media/audio/win/core_audio_util_win.cc33
1 files changed, 29 insertions, 4 deletions
diff --git a/media/audio/win/core_audio_util_win.cc b/media/audio/win/core_audio_util_win.cc
index 4bae7b9..addf8c7 100644
--- a/media/audio/win/core_audio_util_win.cc
+++ b/media/audio/win/core_audio_util_win.cc
@@ -76,6 +76,21 @@ 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());
+
+ // If we hit CO_E_NOTINITIALIZED, CoInitialize has not been called and it
+ // must be called at least once for each thread that uses the COM library.
+ CHECK_NE(hr, CO_E_NOTINITIALIZED);
+
+ return SUCCEEDED(hr);
+}
+
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 +105,18 @@ 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)
+ 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();
+ LOG_IF(ERROR, !g_can_create_device_enumerator)
+ << "Failed to create Core Audio device enumerator on thread with ID "
+ << GetCurrentThreadId();
+ return g_can_create_device_enumerator;
}
base::TimeDelta CoreAudioUtil::RefererenceTimeToTimeDelta(REFERENCE_TIME time) {
@@ -141,9 +167,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;
}