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

Side by Side Diff: media/audio/win/device_enumeration_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 <MMDeviceAPI.h> 5 #include <MMDeviceAPI.h>
6 #include <mmsystem.h> 6 #include <mmsystem.h>
7 #include <objbase.h>
7 #include <Functiondiscoverykeys_devpkey.h> // MMDeviceAPI.h must come first 8 #include <Functiondiscoverykeys_devpkey.h> // MMDeviceAPI.h must come first
8 #include <stddef.h> 9 #include <stddef.h>
9 10
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "base/win/scoped_co_mem.h" 13 #include "base/win/scoped_co_mem.h"
13 #include "base/win/scoped_comptr.h" 14 #include "base/win/scoped_comptr.h"
14 #include "base/win/scoped_propvariant.h" 15 #include "base/win/scoped_propvariant.h"
15 #include "media/audio/win/audio_manager_win.h" 16 #include "media/audio/win/audio_manager_win.h"
16 17
17 using base::win::ScopedComPtr; 18 using base::win::ScopedComPtr;
18 using base::win::ScopedCoMem; 19 using base::win::ScopedCoMem;
19 20
20 // Taken from Mmddk.h. 21 // Taken from Mmddk.h.
21 #define DRV_RESERVED 0x0800 22 #define DRV_RESERVED 0x0800
22 #define DRV_QUERYFUNCTIONINSTANCEID (DRV_RESERVED + 17) 23 #define DRV_QUERYFUNCTIONINSTANCEID (DRV_RESERVED + 17)
23 #define DRV_QUERYFUNCTIONINSTANCEIDSIZE (DRV_RESERVED + 18) 24 #define DRV_QUERYFUNCTIONINSTANCEIDSIZE (DRV_RESERVED + 18)
24 25
25 namespace media { 26 namespace media {
26 27
27 static bool GetDeviceNamesWinImpl(EDataFlow data_flow, 28 static bool GetDeviceNamesWinImpl(EDataFlow data_flow,
28 AudioDeviceNames* device_names) { 29 AudioDeviceNames* device_names) {
29 // It is assumed that this method is called from a COM thread, i.e., 30 // It is assumed that this method is called from a COM thread, i.e.,
30 // CoInitializeEx() is not called here again to avoid STA/MTA conflicts. 31 // CoInitializeEx() is not called here again to avoid STA/MTA conflicts.
31 ScopedComPtr<IMMDeviceEnumerator> enumerator; 32 ScopedComPtr<IMMDeviceEnumerator> enumerator;
32 HRESULT hr = enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), NULL, 33 HRESULT hr =
33 CLSCTX_INPROC_SERVER); 34 ::CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL,
35 CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&enumerator));
34 DCHECK_NE(CO_E_NOTINITIALIZED, hr); 36 DCHECK_NE(CO_E_NOTINITIALIZED, hr);
35 if (FAILED(hr)) { 37 if (FAILED(hr)) {
36 LOG(WARNING) << "Failed to create IMMDeviceEnumerator: " << std::hex << hr; 38 LOG(WARNING) << "Failed to create IMMDeviceEnumerator: " << std::hex << hr;
37 return false; 39 return false;
38 } 40 }
39 41
40 // Generate a collection of active audio endpoint devices. 42 // Generate a collection of active audio endpoint devices.
41 // This method will succeed even if all devices are disabled. 43 // This method will succeed even if all devices are disabled.
42 ScopedComPtr<IMMDeviceCollection> collection; 44 ScopedComPtr<IMMDeviceCollection> collection;
43 hr = enumerator->EnumAudioEndpoints(data_flow, DEVICE_STATE_ACTIVE, 45 hr = enumerator->EnumAudioEndpoints(data_flow, DEVICE_STATE_ACTIVE,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return GetDeviceNamesWinXPImpl<waveInGetNumDevs, WAVEINCAPSW, 149 return GetDeviceNamesWinXPImpl<waveInGetNumDevs, WAVEINCAPSW,
148 waveInGetDevCapsW>(device_names); 150 waveInGetDevCapsW>(device_names);
149 } 151 }
150 152
151 bool GetOutputDeviceNamesWinXP(AudioDeviceNames* device_names) { 153 bool GetOutputDeviceNamesWinXP(AudioDeviceNames* device_names) {
152 return GetDeviceNamesWinXPImpl<waveOutGetNumDevs, WAVEOUTCAPSW, 154 return GetDeviceNamesWinXPImpl<waveOutGetNumDevs, WAVEOUTCAPSW,
153 waveOutGetDevCapsW>(device_names); 155 waveOutGetDevCapsW>(device_names);
154 } 156 }
155 157
156 } // namespace media 158 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/win/core_audio_util_win.cc ('k') | media/capture/video/win/video_capture_device_factory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698