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

Unified Diff: media/audio/win/audio_device_listener_win.h

Issue 11233023: Handle audio device changes on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments! Created 8 years, 2 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
Index: media/audio/win/audio_device_listener_win.h
diff --git a/media/audio/win/audio_device_listener_win.h b/media/audio/win/audio_device_listener_win.h
new file mode 100644
index 0000000000000000000000000000000000000000..5eca5fa894cc1039c2c910100c204ddc857dd4c3
--- /dev/null
+++ b/media/audio/win/audio_device_listener_win.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 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 MEDIA_AUDIO_WIN_AUDIO_DEVICE_LISTENER_WIN_H_
+#define MEDIA_AUDIO_WIN_AUDIO_DEVICE_LISTENER_WIN_H_
+
+#include <MMDeviceAPI.h>
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/win/scoped_comptr.h"
+#include "media/audio/audio_manager.h"
+#include "media/base/media_export.h"
+
+using base::win::ScopedComPtr;
+
+namespace media {
+
+// IMMNotificationClient implementation for listening for default device changes
+// and forwarding to AudioManagerBase so it can notify downstream clients.
scherkus (not reviewing) 2012/10/23 02:23:11 s/AudioManagerWin/?
DaleCurtis 2012/10/24 00:09:27 Done.
+// TODO(henrika): Refactor based on upcoming CoreAudioUtil class for windows.
+class MEDIA_EXPORT AudioDeviceListenerWin : public IMMNotificationClient {
+ public:
+ // AudioDeviceListener::OnDeviceChanged() will be called from an system level
+ // multimedia thread. As such the callee should be thread safe.
+ explicit AudioDeviceListenerWin(AudioManager::AudioDeviceListener* listener);
+ virtual ~AudioDeviceListenerWin();
+
+ private:
+ ULONG __stdcall AddRef();
scherkus (not reviewing) 2012/10/23 02:23:11 nit: add "IMMNotificationClient implementation." c
DaleCurtis 2012/10/23 03:28:20 I dunno, this compiles and runs fine though. Henri
henrika (OOO until Aug 14) 2012/10/23 08:21:43 I vote for COM style and use what's in there. Take
scherkus (not reviewing) 2012/10/23 17:48:19 Yeah it looks like the tide has turned in favour o
DaleCurtis 2012/10/23 20:09:08 Will change back in the next revision.
+ ULONG __stdcall Release();
+ HRESULT __stdcall QueryInterface(REFIID iid, void** object);
+ HRESULT __stdcall OnPropertyValueChanged(LPCWSTR device_id,
+ const PROPERTYKEY key);
+ HRESULT __stdcall OnDeviceAdded(LPCWSTR device_id);
+ HRESULT __stdcall OnDeviceRemoved(LPCWSTR device_id);
+ HRESULT __stdcall OnDeviceStateChanged(LPCWSTR device_id, DWORD new_state);
+ HRESULT __stdcall OnDefaultDeviceChanged(EDataFlow flow, ERole role,
+ LPCWSTR new_default_device_id);
+
+ AudioManager::AudioDeviceListener* listener_;
+ ScopedComPtr<IMMDeviceEnumerator> device_enumerator_;
+ std::string default_device_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioDeviceListenerWin);
+};
+
+} // namespace media
+
+#endif // MEDIA_AUDIO_WIN_AUDIO_DEVICE_LISTENER_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698