Chromium Code Reviews| 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..03df03980d580b7d281ace992f132b923af5ae41 |
| --- /dev/null |
| +++ b/media/audio/win/audio_device_listener_win.h |
| @@ -0,0 +1,57 @@ |
| +// 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 <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/callback.h" |
| +#include "base/win/scoped_comptr.h" |
| +#include "media/base/media_export.h" |
| + |
| +#include <MMDeviceAPI.h> |
| + |
| +using base::win::ScopedComPtr; |
| + |
| +namespace media { |
| + |
| +// IMMNotificationClient implementation for listening for default device changes |
| +// and forwarding to AudioManagerWin so it can notify downstream clients. Only |
| +// output (eRender) device changes are supported currently. WASAPI support is |
| +// required to construct this object. |
| +// TODO(henrika): Refactor based on upcoming CoreAudioUtil class for windows. |
| +// TODO(dalecurtis, henrika): Support input device changes. |
| +class MEDIA_EXPORT AudioDeviceListenerWin : public IMMNotificationClient { |
| + public: |
| + // The listener callback will be called from a system level multimedia thread, |
| + // thus the callee must be thread safe. |
|
scherkus (not reviewing)
2012/10/24 21:00:59
mention this is a permanent callback
DaleCurtis
2012/10/25 20:27:37
Done.
|
| + explicit AudioDeviceListenerWin(const base::Closure& listener); |
| + virtual ~AudioDeviceListenerWin(); |
| + |
| + private: |
| + friend class AudioDeviceListenerWinTest; |
| + |
| + // IMMNotificationClient implementation. |
| + STDMETHOD_(ULONG, AddRef)(); |
| + STDMETHOD_(ULONG, Release)(); |
| + STDMETHOD(QueryInterface)(REFIID iid, void** object); |
| + STDMETHOD(OnPropertyValueChanged)(LPCWSTR device_id, const PROPERTYKEY key); |
| + STDMETHOD(OnDeviceAdded)(LPCWSTR device_id); |
| + STDMETHOD(OnDeviceRemoved)(LPCWSTR device_id); |
| + STDMETHOD(OnDeviceStateChanged)(LPCWSTR device_id, DWORD new_state); |
| + STDMETHOD(OnDefaultDeviceChanged)(EDataFlow flow, ERole role, |
| + LPCWSTR new_default_device_id); |
| + |
| + base::Closure listener_; |
|
scherkus (not reviewing)
2012/10/24 21:00:59
nit: listener_cb_
DaleCurtis
2012/10/25 20:27:37
Done.
|
| + ScopedComPtr<IMMDeviceEnumerator> device_enumerator_; |
| + std::string default_render_device_id_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AudioDeviceListenerWin); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_AUDIO_WIN_AUDIO_DEVICE_LISTENER_WIN_H_ |