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

Unified Diff: remoting/host/win/default_audio_device_change_detector.h

Issue 2809293006: [Chromoting] Move DefaultAudioDeviceChangeDetector out of AudioCapturerWin (Closed)
Patch Set: Remove override of destructor Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/win/BUILD.gn ('k') | remoting/host/win/default_audio_device_change_detector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c38df3f82c1ceccea21a43141b9713293255712f
--- /dev/null
+++ b/remoting/host/win/default_audio_device_change_detector.h
@@ -0,0 +1,54 @@
+// 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.
+// This class does not use the default ref-counting memory management method
+// provided by IUnknown: calling DefaultAudioDeviceChangeDetector::Release()
+// won't delete the object.
+class DefaultAudioDeviceChangeDetector final : public IMMNotificationClient {
+ public:
+ explicit DefaultAudioDeviceChangeDetector(
+ const base::win::ScopedComPtr<IMMDeviceEnumerator>& enumerator);
+ ~DefaultAudioDeviceChangeDetector();
+
+ bool GetAndReset();
+
+ private:
+ // IMMNotificationClient implementation.
+ HRESULT __stdcall OnDefaultDeviceChanged(EDataFlow flow,
+ ERole role,
+ LPCWSTR pwstrDefaultDevice) override;
+
+ HRESULT __stdcall QueryInterface(REFIID iid, void** object) override;
+
+ // No-ops overrides.
+ 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_
« no previous file with comments | « remoting/host/win/BUILD.gn ('k') | remoting/host/win/default_audio_device_change_detector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698