OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef REMOTING_HOST_WIN_DEFAULT_AUDIO_DEVICE_CHANGE_DETECTOR_H_ | |
6 #define REMOTING_HOST_WIN_DEFAULT_AUDIO_DEVICE_CHANGE_DETECTOR_H_ | |
7 | |
8 #include <mmdeviceapi.h> | |
9 | |
10 #include "base/synchronization/lock.h" | |
11 #include "base/win/scoped_comptr.h" | |
12 | |
13 namespace remoting { | |
14 | |
15 // An IMMNotificationClient implementation to detect the change of the default | |
16 // audio output device on the system. It registers itself into the input | |
17 // IMMDeviceEnumerator in constructor, and unregisters in destructor. | |
joedow
2017/04/24 17:29:41
nit: remove comma
Hzj_jie
2017/04/24 22:45:02
Done.
| |
18 // This class does not use the default referring memory management method | |
joedow
2017/04/24 17:29:41
s/referring/ref-counting
Hzj_jie
2017/04/24 22:45:02
Done.
| |
19 // provided by IUnknown: calling DefaultAudioDeviceChangeDetector::Release() | |
20 // won't delete the object. | |
21 class DefaultAudioDeviceChangeDetector final : public IMMNotificationClient { | |
22 public: | |
23 DefaultAudioDeviceChangeDetector( | |
24 const base::win::ScopedComPtr<IMMDeviceEnumerator>& enumerator); | |
joedow
2017/04/24 17:29:41
single param c'tors should be marked explicit
Hzj_jie
2017/04/24 22:45:02
Done.
| |
25 ~DefaultAudioDeviceChangeDetector(); | |
joedow
2017/04/24 17:29:41
override?
Hzj_jie
2017/04/24 22:45:02
e:\b\c\b\win\src\remoting\host\win\default_audio_d
| |
26 | |
27 bool GetAndReset(); | |
28 | |
29 private: | |
30 HRESULT __stdcall OnDefaultDeviceChanged(EDataFlow flow, | |
31 ERole role, | |
32 LPCWSTR pwstrDefaultDevice) override; | |
33 | |
34 HRESULT __stdcall QueryInterface(REFIID iid, void** object) override; | |
35 | |
36 // No-ops overrides. | |
joedow
2017/04/24 17:29:41
I wouldn't call out the no-op bit here, just docum
Hzj_jie
2017/04/24 22:45:02
I think both comments should be useful here. No-op
| |
37 HRESULT __stdcall OnDeviceAdded(LPCWSTR pwstrDeviceId) override; | |
38 HRESULT __stdcall OnDeviceRemoved(LPCWSTR pwstrDeviceId) override; | |
39 HRESULT __stdcall OnDeviceStateChanged(LPCWSTR pwstrDeviceId, | |
40 DWORD dwNewState) override; | |
41 HRESULT __stdcall OnPropertyValueChanged(LPCWSTR pwstrDeviceId, | |
42 const PROPERTYKEY key) override; | |
43 ULONG __stdcall AddRef() override; | |
44 ULONG __stdcall Release() override; | |
45 | |
46 const base::win::ScopedComPtr<IMMDeviceEnumerator> enumerator_; | |
47 bool changed_ = false; | |
48 base::Lock lock_; | |
49 }; | |
50 | |
51 } // namespace remoting | |
52 | |
53 #endif // REMOTING_HOST_WIN_DEFAULT_AUDIO_DEVICE_CHANGE_DETECTOR_H_ | |
OLD | NEW |