Chromium Code Reviews| 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..099158fbe9266a32829491528bbd4a9b44dec253 |
| --- /dev/null |
| +++ b/remoting/host/win/default_audio_device_change_detector.h |
| @@ -0,0 +1,53 @@ |
| +// 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" |
| +#include "base/win/scoped_comptr.h" |
| + |
| +namespace remoting { |
| + |
| +// An IMMNotificationClient implementation to detect the change of the default |
| +// audio output device on the system. It registers itself into the input |
| +// 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.
|
| +// 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.
|
| +// provided by IUnknown: calling DefaultAudioDeviceChangeDetector::Release() |
| +// won't delete the object. |
| +class DefaultAudioDeviceChangeDetector final : public IMMNotificationClient { |
| + public: |
| + DefaultAudioDeviceChangeDetector( |
| + 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.
|
| + ~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
|
| + |
| + bool GetAndReset(); |
| + |
| + private: |
| + HRESULT __stdcall OnDefaultDeviceChanged(EDataFlow flow, |
| + ERole role, |
| + LPCWSTR pwstrDefaultDevice) override; |
| + |
| + HRESULT __stdcall QueryInterface(REFIID iid, void** object) override; |
| + |
| + // 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
|
| + HRESULT __stdcall OnDeviceAdded(LPCWSTR pwstrDeviceId) override; |
| + HRESULT __stdcall OnDeviceRemoved(LPCWSTR pwstrDeviceId) override; |
| + HRESULT __stdcall OnDeviceStateChanged(LPCWSTR pwstrDeviceId, |
| + DWORD dwNewState) override; |
| + HRESULT __stdcall OnPropertyValueChanged(LPCWSTR pwstrDeviceId, |
| + const PROPERTYKEY key) override; |
| + ULONG __stdcall AddRef() override; |
| + ULONG __stdcall Release() override; |
| + |
| + const base::win::ScopedComPtr<IMMDeviceEnumerator> enumerator_; |
| + bool changed_ = false; |
| + base::Lock lock_; |
| +}; |
| + |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_HOST_WIN_DEFAULT_AUDIO_DEVICE_CHANGE_DETECTOR_H_ |