OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/system_message_window_win.h" | 5 #include "content/browser/system_message_window_win.h" |
6 | 6 |
7 #include <dbt.h> | 7 #include <dbt.h> |
8 #include <ks.h> | |
9 #include <ksmedia.h> | |
10 | 8 |
11 #include "base/logging.h" | 9 #include "base/logging.h" |
12 #include "base/system_monitor/system_monitor.h" | 10 #include "base/system_monitor/system_monitor.h" |
13 #include "base/win/wrapped_window_proc.h" | 11 #include "base/win/wrapped_window_proc.h" |
| 12 #include "media/audio/win/core_audio_util_win.h" |
14 | 13 |
15 namespace content { | 14 namespace content { |
16 | 15 |
17 namespace { | 16 namespace { |
18 const wchar_t kWindowClassName[] = L"Chrome_SystemMessageWindow"; | 17 const wchar_t kWindowClassName[] = L"Chrome_SystemMessageWindow"; |
19 | 18 |
20 // A static map from a device category guid to base::SystemMonitor::DeviceType. | 19 // A static map from a device category guid to base::SystemMonitor::DeviceType. |
21 struct { | 20 struct { |
22 const GUID device_category; | 21 const GUID device_category; |
23 const base::SystemMonitor::DeviceType device_type; | 22 const base::SystemMonitor::DeviceType device_type; |
(...skipping 14 matching lines...) Expand all Loading... |
38 Unregister(); | 37 Unregister(); |
39 } | 38 } |
40 | 39 |
41 void Register(HWND hwnd) { | 40 void Register(HWND hwnd) { |
42 // Request to receive device notifications. All applications receive basic | 41 // Request to receive device notifications. All applications receive basic |
43 // notifications via WM_DEVICECHANGE but in order to receive detailed device | 42 // notifications via WM_DEVICECHANGE but in order to receive detailed device |
44 // arrival and removal messages, we need to register. | 43 // arrival and removal messages, we need to register. |
45 DEV_BROADCAST_DEVICEINTERFACE filter = {0}; | 44 DEV_BROADCAST_DEVICEINTERFACE filter = {0}; |
46 filter.dbcc_size = sizeof(filter); | 45 filter.dbcc_size = sizeof(filter); |
47 filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; | 46 filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; |
| 47 bool core_audio_support = media::CoreAudioUtil::IsSupported(); |
48 for (int i = 0; i < arraysize(kDeviceCategoryMap); ++i) { | 48 for (int i = 0; i < arraysize(kDeviceCategoryMap); ++i) { |
| 49 // If CoreAudio is supported, AudioDeviceListenerWin will |
| 50 // take care of monitoring audio devices. |
| 51 if (core_audio_support && |
| 52 KSCATEGORY_AUDIO == kDeviceCategoryMap[i].device_category) { |
| 53 continue; |
| 54 } |
| 55 |
49 filter.dbcc_classguid = kDeviceCategoryMap[i].device_category; | 56 filter.dbcc_classguid = kDeviceCategoryMap[i].device_category; |
50 DCHECK_EQ(notifications_[i], static_cast<HDEVNOTIFY>(NULL)); | 57 DCHECK_EQ(notifications_[i], static_cast<HDEVNOTIFY>(NULL)); |
51 notifications_[i] = RegisterDeviceNotification( | 58 notifications_[i] = RegisterDeviceNotification( |
52 hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE); | 59 hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE); |
53 DPLOG_IF(ERROR, !notifications_[i]) | 60 DPLOG_IF(ERROR, !notifications_[i]) |
54 << "RegisterDeviceNotification failed"; | 61 << "RegisterDeviceNotification failed"; |
55 } | 62 } |
56 } | 63 } |
57 | 64 |
58 void Unregister() { | 65 void Unregister() { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 case WM_DEVICECHANGE: | 153 case WM_DEVICECHANGE: |
147 return OnDeviceChange(static_cast<UINT>(wparam), lparam); | 154 return OnDeviceChange(static_cast<UINT>(wparam), lparam); |
148 default: | 155 default: |
149 break; | 156 break; |
150 } | 157 } |
151 | 158 |
152 return ::DefWindowProc(hwnd, message, wparam, lparam); | 159 return ::DefWindowProc(hwnd, message, wparam, lparam); |
153 } | 160 } |
154 | 161 |
155 } // namespace content | 162 } // namespace content |
OLD | NEW |