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

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

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/default_audio_device_change_detector.h ('k') | no next file » | 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.cc
diff --git a/remoting/host/win/default_audio_device_change_detector.cc b/remoting/host/win/default_audio_device_change_detector.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4a8f2e619689c4fd345e107f507cd7a07eed54e5
--- /dev/null
+++ b/remoting/host/win/default_audio_device_change_detector.cc
@@ -0,0 +1,87 @@
+// 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.
+
+#include "remoting/host/win/default_audio_device_change_detector.h"
+
+#include <unknwn.h>
+
+#include "base/logging.h"
+
+namespace remoting {
+
+DefaultAudioDeviceChangeDetector::DefaultAudioDeviceChangeDetector(
+ const base::win::ScopedComPtr<IMMDeviceEnumerator>& enumerator)
+ : enumerator_(enumerator) {
+ DCHECK(enumerator_);
+ HRESULT hr = enumerator_->RegisterEndpointNotificationCallback(this);
+ if (FAILED(hr)) {
+ // We cannot predict which kind of error the API may return, but this is not
+ // a fatal error.
+ LOG(WARNING) << "Failed to register IMMNotificationClient, we may not be "
+ "able to detect the new default audio device. Error "
+ << hr;
+ }
+}
+
+DefaultAudioDeviceChangeDetector::~DefaultAudioDeviceChangeDetector() {
+ enumerator_->UnregisterEndpointNotificationCallback(this);
+}
+
+bool DefaultAudioDeviceChangeDetector::GetAndReset() {
+ bool result = false;
+ {
+ base::AutoLock lock(lock_);
+ result = changed_;
+ changed_ = false;
+ }
+ return result;
+}
+
+HRESULT DefaultAudioDeviceChangeDetector::OnDefaultDeviceChanged(
+ EDataFlow flow,
+ ERole role,
+ LPCWSTR pwstrDefaultDevice) {
+ {
+ base::AutoLock lock(lock_);
+ changed_ = true;
+ }
+ return S_OK;
+}
+
+HRESULT DefaultAudioDeviceChangeDetector::QueryInterface(REFIID iid,
+ void** object) {
+ if (iid == IID_IUnknown || iid == __uuidof(IMMNotificationClient)) {
+ *object = static_cast<IMMNotificationClient*>(this);
+ return S_OK;
+ }
+ *object = nullptr;
+ return E_NOINTERFACE;
+}
+
+HRESULT DefaultAudioDeviceChangeDetector::OnDeviceAdded(LPCWSTR pwstrDeviceId) {
+ return S_OK;
+}
+
+HRESULT DefaultAudioDeviceChangeDetector::OnDeviceRemoved(
+ LPCWSTR pwstrDeviceId) {
+ return S_OK;
+}
+
+HRESULT DefaultAudioDeviceChangeDetector::OnDeviceStateChanged(
+ LPCWSTR pwstrDeviceId,
+ DWORD dwNewState) {
+ return S_OK;
+}
+
+HRESULT DefaultAudioDeviceChangeDetector::OnPropertyValueChanged(
+ LPCWSTR pwstrDeviceId,
+ const PROPERTYKEY key) {
+ return S_OK;
+}
+
+ULONG DefaultAudioDeviceChangeDetector::AddRef() { return 1; }
+
+ULONG DefaultAudioDeviceChangeDetector::Release() { return 1; }
+
+} // namespace remoting
« no previous file with comments | « remoting/host/win/default_audio_device_change_detector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698