diff options
author | Memphiz <memphis@machzwo.de> | 2016-01-28 17:10:09 +0100 |
---|---|---|
committer | Memphiz <memphis@machzwo.de> | 2016-01-28 17:10:09 +0100 |
commit | ad93e7ebaa25bee87d9aabeacef6bff7ac8704f3 (patch) | |
tree | 58f360294a6c0345fed49a0c56925741652a00d7 | |
parent | 8c5794d91f16e82587c731b7b04e2310727e6076 (diff) | |
parent | 56ffd7b451b5a81f937aa2b57dc73ba02e155c63 (diff) |
Merge pull request #8957 from Memphiz/fix_usb_crash_bp
[osx] - Fix crash when unplugging usb devices
-rw-r--r-- | xbmc/peripherals/bus/osx/PeripheralBusUSB.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/xbmc/peripherals/bus/osx/PeripheralBusUSB.cpp b/xbmc/peripherals/bus/osx/PeripheralBusUSB.cpp index 0d83865c84..0ab954807a 100644 --- a/xbmc/peripherals/bus/osx/PeripheralBusUSB.cpp +++ b/xbmc/peripherals/bus/osx/PeripheralBusUSB.cpp @@ -121,7 +121,7 @@ void CPeripheralBusUSB::DeviceDetachCallback(void *refCon, io_service_t service, { if (messageType == kIOMessageServiceIsTerminated) { - std::unique_ptr<USBDevicePrivateData> privateDataRef((USBDevicePrivateData*)refCon); + USBDevicePrivateData *privateDataRef = (USBDevicePrivateData*)refCon; std::vector<PeripheralScanResult>::iterator it = privateDataRef->refCon->m_scan_results.m_results.begin(); while(it != privateDataRef->refCon->m_scan_results.m_results.end()) @@ -136,6 +136,7 @@ void CPeripheralBusUSB::DeviceDetachCallback(void *refCon, io_service_t service, CLog::Log(LOGDEBUG, "USB Device Detach:%s, %s\n", privateDataRef->deviceName.c_str(), privateDataRef->result.m_strLocation.c_str()); IOObjectRelease(privateDataRef->notification); + delete privateDataRef; //release the service IOObjectRelease(service); } @@ -174,9 +175,6 @@ void CPeripheralBusUSB::DeviceAttachCallback(CPeripheralBusUSB* refCon, io_itera continue; } - // do not need the intermediate plug-in after device interface is created - (*devicePlugin)->Release(devicePlugin); - // get vendor/product ids UInt16 vendorId; UInt16 productId; @@ -218,9 +216,6 @@ void CPeripheralBusUSB::DeviceAttachCallback(CPeripheralBusUSB* refCon, io_itera continue; } - // do not need the intermediate plug-in after query - (*interfaceInterface)->Release(interfaceInterface); - // finally we can get to the bInterfaceClass // we should also check for kHIDKeyboardInterfaceProtocol but // some IR remotes that emulate an HID keyboard do not report this. @@ -230,7 +225,8 @@ void CPeripheralBusUSB::DeviceAttachCallback(CPeripheralBusUSB* refCon, io_itera { std::string ttlDeviceFilePath; CFStringRef deviceFilePathAsCFString; - std::unique_ptr<USBDevicePrivateData> privateDataRef(new USBDevicePrivateData); + USBDevicePrivateData *privateDataRef; + privateDataRef = new USBDevicePrivateData; // save the device info to our private data. privateDataRef->refCon = refCon; privateDataRef->deviceName = deviceName; @@ -277,7 +273,7 @@ void CPeripheralBusUSB::DeviceAttachCallback(CPeripheralBusUSB* refCon, io_itera usbDevice, // service kIOGeneralInterest, // interestType (IOServiceInterestCallback)DeviceDetachCallback, // callback - &privateDataRef, // refCon + privateDataRef, // refCon &privateDataRef->notification); // notification if (result == kIOReturnSuccess) @@ -286,6 +282,14 @@ void CPeripheralBusUSB::DeviceAttachCallback(CPeripheralBusUSB* refCon, io_itera CLog::Log(LOGDEBUG, "USB Device Attach:%s, %s\n", deviceName, privateDataRef->result.m_strLocation.c_str()); } + else + { + delete privateDataRef; + } + } + else + { + delete privateDataRef; } // done with this device, only need one notification per device. IODestroyPlugInInterface(interfacePlugin); |