0
Files
src/content/browser/device_monitor_mac.h
xians@chromium.org 1d34b6cd3f IOKit sends out a device changed notification before the driver fully initializes the device. And Since chrome will enumerate the devices after getting the notification, this will crash on some specific USB devices if the device is being initialized while being enumerated.
This patch change IOKit notification to use AudioObjectAddPropertyListener on kAudioHardwarePropertyDevices. By doing so, we will get notification after the driver initializes the devices.


BUG=153411
TEST= manual test with Pepper flash device enumeration.

Review URL: https://chromiumcodereview.appspot.com/11106013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161594 0039d316-1c4b-4281-b951-d872f2087c98
2012-10-12 16:46:21 +00:00

50 lines
1.3 KiB
C++

// 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 CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_
#define CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_
#include <CoreAudio/AudioHardware.h>
#include <IOKit/IOKitLib.h>
#include <vector>
#include "base/basictypes.h"
#include "base/system_monitor/system_monitor.h"
namespace content {
class DeviceMonitorMac {
public:
DeviceMonitorMac();
~DeviceMonitorMac();
private:
void RegisterAudioServices();
void RegisterVideoServices();
static OSStatus AudioDeviceCallback(
AudioObjectID object, UInt32 size,
const AudioObjectPropertyAddress addresses[],
void* context);
static void VideoDeviceCallback(void* context, io_iterator_t iterator);
// Forward the notifications to system monitor.
void NotifyDeviceChanged(base::SystemMonitor::DeviceType type);
// Helper.
void RegisterServices(CFMutableDictionaryRef dictionary,
IOServiceMatchingCallback callback);
IONotificationPortRef notification_port_;
std::vector<io_iterator_t*> notification_iterators_;
DISALLOW_COPY_AND_ASSIGN(DeviceMonitorMac);
};
} // namespace content
#endif // CONTENT_BROWSER_DEVICE_MONITOR_MAC_H_