Chromium Code Reviews| Index: media/audio/win/audio_device_listener_win.cc |
| diff --git a/media/audio/win/audio_device_listener_win.cc b/media/audio/win/audio_device_listener_win.cc |
| index 9312af62cc78b7d3239a10d306c79a6468a74284..78e84302896fc2c15649f06b769308fc2c2c8d35 100644 |
| --- a/media/audio/win/audio_device_listener_win.cc |
| +++ b/media/audio/win/audio_device_listener_win.cc |
| @@ -7,6 +7,7 @@ |
| #include <Audioclient.h> |
| #include "base/logging.h" |
| +#include "base/system_monitor/system_monitor.h" |
| #include "base/utf_string_conversions.h" |
| #include "base/win/scoped_co_mem.h" |
| #include "base/win/windows_version.h" |
| @@ -18,7 +19,8 @@ using base::win::ScopedCoMem; |
| namespace media { |
| AudioDeviceListenerWin::AudioDeviceListenerWin(const base::Closure& listener_cb) |
| - : listener_cb_(listener_cb) { |
| + : listener_cb_(listener_cb), |
| + pending_capture_device_changed_(false) { |
| CHECK(CoreAudioUtil::IsSupported()); |
| ScopedComPtr<IMMDeviceEnumerator> device_enumerator( |
| @@ -101,12 +103,24 @@ STDMETHODIMP AudioDeviceListenerWin::OnDeviceRemoved(LPCWSTR device_id) { |
| STDMETHODIMP AudioDeviceListenerWin::OnDeviceStateChanged(LPCWSTR device_id, |
| DWORD new_state) { |
| + if (!pending_capture_device_changed_) |
|
tommi (sloooow) - chröme
2012/12/13 13:16:58
This doesn't seem right. With this change we igno
no longer working on chromium
2012/12/13 14:54:58
This flag is to prevent sending ProcessDevicesChan
|
| + return S_OK; |
| + |
| + base::SystemMonitor* monitor = base::SystemMonitor::Get(); |
| + if (monitor) |
| + monitor->ProcessDevicesChanged(base::SystemMonitor::DEVTYPE_AUDIO_CAPTURE); |
| + |
| + pending_capture_device_changed_ = false; |
| return S_OK; |
| } |
| STDMETHODIMP AudioDeviceListenerWin::OnDefaultDeviceChanged( |
| EDataFlow flow, ERole role, LPCWSTR new_default_device_id) { |
| - // Only listen for output device changes right now... |
|
tommi (sloooow) - chröme
2012/12/13 13:16:58
why remove this comment?
no longer working on chromium
2012/12/13 14:54:58
because we are also listening to capture device ch
|
| + if (role == eCapture) { |
| + pending_capture_device_changed_ = true; |
|
tommi (sloooow) - chröme
2012/12/13 13:16:58
Imho this variable should be called |default_captu
no longer working on chromium
2012/12/13 14:54:58
I changed the name to capture_device_changed_, sin
|
| + return S_OK; |
| + } |
| + |
| if (flow != eConsole && role != eRender) |
| return S_OK; |