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

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

Issue 1103383003: Don't allow CoreAudioUtil::IsSupported() to reinitialize COM. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 53530dfc998382d46ef6cbaf26031d1493ee0a79..bf1c56bbbfb139ff57995b96f740bbc3afa4861a 100644
--- a/media/audio/win/core_audio_util_win.cc
+++ b/media/audio/win/core_audio_util_win.cc
@@ -168,11 +168,12 @@ static HRESULT GetDeviceFriendlyNameInternal(IMMDevice* device,
return hr;
}
-static ScopedComPtr<IMMDeviceEnumerator> CreateDeviceEnumeratorInternal() {
+static ScopedComPtr<IMMDeviceEnumerator> CreateDeviceEnumeratorInternal(
+ bool allow_reinitialize) {
ScopedComPtr<IMMDeviceEnumerator> device_enumerator;
HRESULT hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator),
NULL, CLSCTX_INPROC_SERVER);
- if (hr == CO_E_NOTINITIALIZED) {
+ if (hr == CO_E_NOTINITIALIZED && allow_reinitialize) {
LOG(ERROR) << "CoCreateInstance fails with CO_E_NOTINITIALIZED";
// We have seen crashes which indicates that this method can in fact
// fail with CO_E_NOTINITIALIZED in combination with certain 3rd party
@@ -215,7 +216,7 @@ static bool IsSupportedInternal() {
// that it is possible to a create the IMMDeviceEnumerator interface. If this
// works as well we should be home free.
ScopedComPtr<IMMDeviceEnumerator> device_enumerator =
- CreateDeviceEnumeratorInternal();
+ CreateDeviceEnumeratorInternal(false);
if (!device_enumerator) {
LOG(ERROR)
<< "Failed to create Core Audio device enumerator on thread with ID "
@@ -274,7 +275,7 @@ int CoreAudioUtil::NumberOfActiveDevices(EDataFlow data_flow) {
ScopedComPtr<IMMDeviceEnumerator> CoreAudioUtil::CreateDeviceEnumerator() {
DCHECK(IsSupported());
ScopedComPtr<IMMDeviceEnumerator> device_enumerator =
- CreateDeviceEnumeratorInternal();
+ CreateDeviceEnumeratorInternal(true);
CHECK(device_enumerator);
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