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. |
| 18 // This class does not use the default ref-counting memory management method |
| 19 // provided by IUnknown: calling DefaultAudioDeviceChangeDetector::Release() |
| 20 // won't delete the object. |
| 21 class DefaultAudioDeviceChangeDetector final : public IMMNotificationClient { |
| 22 public: |
| 23 explicit DefaultAudioDeviceChangeDetector( |
| 24 const base::win::ScopedComPtr<IMMDeviceEnumerator>& enumerator); |
| 25 ~DefaultAudioDeviceChangeDetector(); |
| 26 |
| 27 bool GetAndReset(); |
| 28 |
| 29 private: |
| 30 // IMMNotificationClient implementation. |
| 31 HRESULT __stdcall OnDefaultDeviceChanged(EDataFlow flow, |
| 32 ERole role, |
| 33 LPCWSTR pwstrDefaultDevice) override; |
| 34 |
| 35 HRESULT __stdcall QueryInterface(REFIID iid, void** object) override; |
| 36 |
| 37 // No-ops overrides. |
| 38 HRESULT __stdcall OnDeviceAdded(LPCWSTR pwstrDeviceId) override; |
| 39 HRESULT __stdcall OnDeviceRemoved(LPCWSTR pwstrDeviceId) override; |
| 40 HRESULT __stdcall OnDeviceStateChanged(LPCWSTR pwstrDeviceId, |
| 41 DWORD dwNewState) override; |
| 42 HRESULT __stdcall OnPropertyValueChanged(LPCWSTR pwstrDeviceId, |
| 43 const PROPERTYKEY key) override; |
| 44 ULONG __stdcall AddRef() override; |
| 45 ULONG __stdcall Release() override; |
| 46 |
| 47 const base::win::ScopedComPtr<IMMDeviceEnumerator> enumerator_; |
| 48 bool changed_ = false; |
| 49 base::Lock lock_; |
| 50 }; |
| 51 |
| 52 } // namespace remoting |
| 53 |
| 54 #endif // REMOTING_HOST_WIN_DEFAULT_AUDIO_DEVICE_CHANGE_DETECTOR_H_ |
OLD | NEW |