Index: remoting/host/win/default_audio_device_change_detector.h |
diff --git a/remoting/host/win/default_audio_device_change_detector.h b/remoting/host/win/default_audio_device_change_detector.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ac26b3e8494e9b8f7c420880015b34508ef32c8f |
--- /dev/null |
+++ b/remoting/host/win/default_audio_device_change_detector.h |
@@ -0,0 +1,62 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef REMOTING_HOST_WIN_DEFAULT_AUDIO_DEVICE_CHANGE_DETECTOR_H_ |
+#define REMOTING_HOST_WIN_DEFAULT_AUDIO_DEVICE_CHANGE_DETECTOR_H_ |
+ |
+#include <mmdeviceapi.h> |
+ |
+#include "base/synchronization/lock.h" |
+ |
+namespace remoting { |
+ |
+// An IMMNotificationClient implementation to detect the change of the default |
+// audio output device on the system. |
+// This class does not use the default referring memory management method |
Sergey Ulanov
2017/04/13 01:30:12
s/default referring memory management method/refer
Hzj_jie
2017/04/13 17:26:16
I have not noticed the mm_device_enumerator_ is fo
|
+// provided by IUnknown: the |
+// IMMDeviceEnumerator::RegisterEndpointNotificationCallback() will be called in |
+// the constructor, and |
+// IMMDeviceEnumerator::UnregisterEndpointNotificationCallback() will be called |
Sergey Ulanov
2017/04/13 01:30:12
s/will be/is/ in the two places above.
Hzj_jie
2017/04/13 17:26:16
Done.
|
+// in the destructor. Consumers should ensure the input IMMDeviceEnumerator |
+// outlives this instance. |
+class DefaultAudioDeviceChangeDetector final : public IMMNotificationClient { |
+ public: |
+ DefaultAudioDeviceChangeDetector(IMMDeviceEnumerator* enumerator); |
+ ~DefaultAudioDeviceChangeDetector(); |
+ |
+ HRESULT __stdcall OnDefaultDeviceChanged(EDataFlow flow, |
Sergey Ulanov
2017/04/13 01:30:12
Move IMMNotificationClient implementation to the p
Hzj_jie
2017/04/13 17:26:16
Done.
|
+ ERole role, |
+ LPCWSTR pwstrDefaultDevice) override; |
+ |
+ HRESULT __stdcall QueryInterface(REFIID iid, void** object) override; |
+ |
+ bool GetAndReset(); |
+ |
+ // No-ops overrides. |
+ HRESULT __stdcall OnDeviceAdded(LPCWSTR pwstrDeviceId) override { |
Sergey Ulanov
2017/04/13 01:30:12
Normally all virtual method overrides should be in
Hzj_jie
2017/04/13 17:26:16
Done.
|
+ return S_OK; |
+ } |
+ HRESULT __stdcall OnDeviceRemoved(LPCWSTR pwstrDeviceId) override { |
+ return S_OK; |
+ } |
+ HRESULT __stdcall OnDeviceStateChanged(LPCWSTR pwstrDeviceId, |
+ DWORD dwNewState) override { |
+ return S_OK; |
+ } |
+ HRESULT __stdcall OnPropertyValueChanged(LPCWSTR pwstrDeviceId, |
+ const PROPERTYKEY key) override { |
+ return S_OK; |
+ } |
+ ULONG __stdcall AddRef() override { return 1; } |
+ ULONG __stdcall Release() override { return 1; } |
+ |
+ private: |
+ IMMDeviceEnumerator* const enumerator_; |
+ bool changed_ = false; |
+ base::Lock lock_; |
+}; |
+ |
+} // namespace remoting |
+ |
+#endif // REMOTING_HOST_WIN_DEFAULT_AUDIO_DEVICE_CHANGE_DETECTOR_H_ |