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

Side by Side Diff: content/browser/system_message_window_win.cc

Issue 11529012: Use the device listener in Media on windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/audio/win/audio_device_listener_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 8 #include <ks.h>
9 #include <ksmedia.h> 9 #include <ksmedia.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/system_monitor/system_monitor.h" 12 #include "base/system_monitor/system_monitor.h"
13 #include "base/win/windows_version.h"
13 #include "base/win/wrapped_window_proc.h" 14 #include "base/win/wrapped_window_proc.h"
14 15
15 namespace content { 16 namespace content {
16 17
17 namespace { 18 namespace {
19
18 const wchar_t kWindowClassName[] = L"Chrome_SystemMessageWindow"; 20 const wchar_t kWindowClassName[] = L"Chrome_SystemMessageWindow";
19 21
20 // A static map from a device category guid to base::SystemMonitor::DeviceType. 22 // A static map from a device category guid to base::SystemMonitor::DeviceType.
21 struct { 23 struct {
22 const GUID device_category; 24 const GUID device_category;
23 const base::SystemMonitor::DeviceType device_type; 25 const base::SystemMonitor::DeviceType device_type;
24 } const kDeviceCategoryMap[] = { 26 } const kDeviceCategoryMap[] = {
25 { KSCATEGORY_AUDIO, base::SystemMonitor::DEVTYPE_AUDIO_CAPTURE }, 27 { KSCATEGORY_AUDIO, base::SystemMonitor::DEVTYPE_AUDIO_CAPTURE },
26 { KSCATEGORY_VIDEO, base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE }, 28 { KSCATEGORY_VIDEO, base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE },
27 }; 29 };
30
31 bool IsCoreAudioSupported() {
32 return (base::win::GetVersion() >= base::win::VERSION_VISTA);
33 }
34
28 } // namespace 35 } // namespace
29 36
30 // Manages the device notification handles for SystemMessageWindowWin. 37 // Manages the device notification handles for SystemMessageWindowWin.
31 class SystemMessageWindowWin::DeviceNotifications { 38 class SystemMessageWindowWin::DeviceNotifications {
32 public: 39 public:
33 explicit DeviceNotifications(HWND hwnd) : notifications_() { 40 explicit DeviceNotifications(HWND hwnd) : notifications_() {
34 Register(hwnd); 41 Register(hwnd);
35 } 42 }
36 43
37 ~DeviceNotifications() { 44 ~DeviceNotifications() {
38 Unregister(); 45 Unregister();
39 } 46 }
40 47
41 void Register(HWND hwnd) { 48 void Register(HWND hwnd) {
42 // Request to receive device notifications. All applications receive basic 49 // Request to receive device notifications. All applications receive basic
43 // notifications via WM_DEVICECHANGE but in order to receive detailed device 50 // notifications via WM_DEVICECHANGE but in order to receive detailed device
44 // arrival and removal messages, we need to register. 51 // arrival and removal messages, we need to register.
45 DEV_BROADCAST_DEVICEINTERFACE filter = {0}; 52 DEV_BROADCAST_DEVICEINTERFACE filter = {0};
46 filter.dbcc_size = sizeof(filter); 53 filter.dbcc_size = sizeof(filter);
47 filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; 54 filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
48 for (int i = 0; i < arraysize(kDeviceCategoryMap); ++i) { 55 for (int i = 0; i < arraysize(kDeviceCategoryMap); ++i) {
56 // From Vista, we use a device listener in AudioDeviceListenerWin.
57 if (IsCoreAudioSupported() &&
DaleCurtis 2012/12/11 19:27:59 This should use Henrik's CoreAudioUtil class.
no longer working on chromium 2012/12/11 20:15:49 I tried include the media/audio/win/core_audio_uti
no longer working on chromium 2012/12/12 10:17:16 including the CoreAudioUtil.h gives me this compil
tommi (sloooow) - chröme 2012/12/12 13:01:09 This doesn't look like related to CoreAudioUtil.h
58 KSCATEGORY_AUDIO == kDeviceCategoryMap[i].device_category)
59 continue;
60
49 filter.dbcc_classguid = kDeviceCategoryMap[i].device_category; 61 filter.dbcc_classguid = kDeviceCategoryMap[i].device_category;
50 DCHECK_EQ(notifications_[i], static_cast<HDEVNOTIFY>(NULL)); 62 DCHECK_EQ(notifications_[i], static_cast<HDEVNOTIFY>(NULL));
51 notifications_[i] = RegisterDeviceNotification( 63 notifications_[i] = RegisterDeviceNotification(
52 hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE); 64 hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE);
53 DPLOG_IF(ERROR, !notifications_[i]) 65 DPLOG_IF(ERROR, !notifications_[i])
54 << "RegisterDeviceNotification failed"; 66 << "RegisterDeviceNotification failed";
55 } 67 }
56 } 68 }
57 69
58 void Unregister() { 70 void Unregister() {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 case WM_DEVICECHANGE: 158 case WM_DEVICECHANGE:
147 return OnDeviceChange(static_cast<UINT>(wparam), lparam); 159 return OnDeviceChange(static_cast<UINT>(wparam), lparam);
148 default: 160 default:
149 break; 161 break;
150 } 162 }
151 163
152 return ::DefWindowProc(hwnd, message, wparam, lparam); 164 return ::DefWindowProc(hwnd, message, wparam, lparam);
153 } 165 }
154 166
155 } // namespace content 167 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | media/audio/win/audio_device_listener_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698