From c7bdd3190cf7f6328e459fd0befe6b658fdd49ee Mon Sep 17 00:00:00 2001 From: "xians@chromium.org" Date: Sun, 16 Dec 2012 00:45:51 +0000 Subject: This patch will use the device listener in media to monitor audio capture device changed. The reasons for doing this include: # when using the device notification from content/browser, the notification comes before the device is fully initialized, so the change won't show up in the following device enumeration. # I saw a serious crash by plugging in or unplugging an audio device, I believe it is because some racing between two notifications, if this is the case, this patch should fix it. BUG=160872,165147 TEST=manual test by plugging and unplugging device, look at the device selection menu in content setting media. Review URL: https://chromiumcodereview.appspot.com/11529012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173350 0039d316-1c4b-4281-b951-d872f2087c98 --- content/browser/system_message_window_win.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'content/browser/system_message_window_win.cc') diff --git a/content/browser/system_message_window_win.cc b/content/browser/system_message_window_win.cc index d2a7808..08f44cb 100644 --- a/content/browser/system_message_window_win.cc +++ b/content/browser/system_message_window_win.cc @@ -5,12 +5,11 @@ #include "content/browser/system_message_window_win.h" #include -#include -#include #include "base/logging.h" #include "base/system_monitor/system_monitor.h" #include "base/win/wrapped_window_proc.h" +#include "media/audio/win/core_audio_util_win.h" namespace content { @@ -45,7 +44,15 @@ class SystemMessageWindowWin::DeviceNotifications { DEV_BROADCAST_DEVICEINTERFACE filter = {0}; filter.dbcc_size = sizeof(filter); filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; + bool core_audio_support = media::CoreAudioUtil::IsSupported(); for (int i = 0; i < arraysize(kDeviceCategoryMap); ++i) { + // If CoreAudio is supported, AudioDeviceListenerWin will + // take care of monitoring audio devices. + if (core_audio_support && + KSCATEGORY_AUDIO == kDeviceCategoryMap[i].device_category) { + continue; + } + filter.dbcc_classguid = kDeviceCategoryMap[i].device_category; DCHECK_EQ(notifications_[i], static_cast(NULL)); notifications_[i] = RegisterDeviceNotification( -- cgit v1.1