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

Side by Side Diff: media/audio/win/core_audio_util_win.cc

Issue 2887243002: Remove ScopedComPtr::CreateInstance() (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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 <devicetopology.h> 7 #include <devicetopology.h>
8 #include <dxdiag.h> 8 #include <dxdiag.h>
9 #include <functiondiscoverykeys_devpkey.h> 9 #include <functiondiscoverykeys_devpkey.h>
10 #include <objbase.h> 10 #include <objbase.h>
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 base::WideToUTF8(friendly_name_pv.get().pwszVal, 170 base::WideToUTF8(friendly_name_pv.get().pwszVal,
171 wcslen(friendly_name_pv.get().pwszVal), friendly_name); 171 wcslen(friendly_name_pv.get().pwszVal), friendly_name);
172 } 172 }
173 173
174 return hr; 174 return hr;
175 } 175 }
176 176
177 static ScopedComPtr<IMMDeviceEnumerator> CreateDeviceEnumeratorInternal( 177 static ScopedComPtr<IMMDeviceEnumerator> CreateDeviceEnumeratorInternal(
178 bool allow_reinitialize) { 178 bool allow_reinitialize) {
179 ScopedComPtr<IMMDeviceEnumerator> device_enumerator; 179 ScopedComPtr<IMMDeviceEnumerator> device_enumerator;
180 HRESULT hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), 180 HRESULT hr = ::CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL,
181 NULL, CLSCTX_INPROC_SERVER); 181 CLSCTX_INPROC_SERVER,
182 IID_PPV_ARGS(&device_enumerator));
182 if (hr == CO_E_NOTINITIALIZED && allow_reinitialize) { 183 if (hr == CO_E_NOTINITIALIZED && allow_reinitialize) {
183 LOG(ERROR) << "CoCreateInstance fails with CO_E_NOTINITIALIZED"; 184 LOG(ERROR) << "CoCreateInstance fails with CO_E_NOTINITIALIZED";
184 // We have seen crashes which indicates that this method can in fact 185 // We have seen crashes which indicates that this method can in fact
185 // fail with CO_E_NOTINITIALIZED in combination with certain 3rd party 186 // fail with CO_E_NOTINITIALIZED in combination with certain 3rd party
186 // modules. Calling CoInitializeEx is an attempt to resolve the reported 187 // modules. Calling CoInitializeEx is an attempt to resolve the reported
187 // issues. See http://crbug.com/378465 for details. 188 // issues. See http://crbug.com/378465 for details.
188 hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); 189 hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
189 if (SUCCEEDED(hr)) { 190 if (SUCCEEDED(hr)) {
190 hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), 191 hr = ::CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL,
191 NULL, CLSCTX_INPROC_SERVER); 192 CLSCTX_INPROC_SERVER,
193 IID_PPV_ARGS(&device_enumerator));
192 } 194 }
193 } 195 }
194 return device_enumerator; 196 return device_enumerator;
195 } 197 }
196 198
197 static bool IsSupportedInternal() { 199 static bool IsSupportedInternal() {
198 // It is possible to force usage of WaveXxx APIs by using a command line flag. 200 // It is possible to force usage of WaveXxx APIs by using a command line flag.
199 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 201 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
200 if (cmd_line->HasSwitch(switches::kForceWaveAudio)) { 202 if (cmd_line->HasSwitch(switches::kForceWaveAudio)) {
201 DVLOG(1) << "Forcing usage of Windows WaveXxx APIs"; 203 DVLOG(1) << "Forcing usage of Windows WaveXxx APIs";
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 // explicitly write silence data to the rendering buffer. 872 // explicitly write silence data to the rendering buffer.
871 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; 873 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence";
872 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, 874 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill,
873 AUDCLNT_BUFFERFLAGS_SILENT)); 875 AUDCLNT_BUFFERFLAGS_SILENT));
874 } 876 }
875 877
876 bool CoreAudioUtil::GetDxDiagDetails(std::string* driver_name, 878 bool CoreAudioUtil::GetDxDiagDetails(std::string* driver_name,
877 std::string* driver_version) { 879 std::string* driver_version) {
878 ScopedComPtr<IDxDiagProvider, &IID_IDxDiagProvider> provider; 880 ScopedComPtr<IDxDiagProvider, &IID_IDxDiagProvider> provider;
879 HRESULT hr = 881 HRESULT hr =
880 provider.CreateInstance(CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER); 882 ::CoCreateInstance(CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER,
883 IID_IDxDiagProvider, &provider);
881 if (FAILED(hr)) 884 if (FAILED(hr))
882 return false; 885 return false;
883 886
884 DXDIAG_INIT_PARAMS params = {sizeof(params)}; 887 DXDIAG_INIT_PARAMS params = {sizeof(params)};
885 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION; 888 params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
886 params.bAllowWHQLChecks = FALSE; 889 params.bAllowWHQLChecks = FALSE;
887 params.pReserved = NULL; 890 params.pReserved = NULL;
888 hr = provider->Initialize(&params); 891 hr = provider->Initialize(&params);
889 if (FAILED(hr)) 892 if (FAILED(hr))
890 return false; 893 return false;
(...skipping 28 matching lines...) Expand all
919 922
920 if (variant.type() == VT_BSTR && variant.ptr()->bstrVal) { 923 if (variant.type() == VT_BSTR && variant.ptr()->bstrVal) {
921 base::WideToUTF8(variant.ptr()->bstrVal, wcslen(variant.ptr()->bstrVal), 924 base::WideToUTF8(variant.ptr()->bstrVal, wcslen(variant.ptr()->bstrVal),
922 driver_version); 925 driver_version);
923 } 926 }
924 927
925 return true; 928 return true;
926 } 929 }
927 930
928 } // namespace media 931 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/win/audio_low_latency_input_win.cc ('k') | media/audio/win/device_enumeration_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698