Skip to content

Commit

Permalink
Merge pull request #55 from naali/macos12
Browse files Browse the repository at this point in the history
Don't open & close control channel on macOS Monterey
  • Loading branch information
vonnieda authored Mar 17, 2022
2 parents f9328d4 + dbaa7e7 commit 0aa77fb
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions mac/uvcctrl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,19 @@ of this software and associated documentation files (the "Software"), to deal
return false;
}

kern_return_t kr = (*m_controller)->USBInterfaceOpen(m_controller);
if (kr != kIOReturnSuccess)
kern_return_t kr;
if (@available(macOS 12.0, *))
{
LOG(LOG_ERR, "sendControlRequest USBInterfaceOpen failed!\n");
return false;
// macOS 12 doesn't like if we're trying to open USB interface here...
}
else
{
kr = (*m_controller)->USBInterfaceOpen(m_controller);
if (kr != kIOReturnSuccess)
{
LOG(LOG_ERR, "sendControlRequest USBInterfaceOpen failed!\n");
return false;
}
}

kr = (*m_controller)->ControlRequest(m_controller, 0, &req);
Expand Down Expand Up @@ -403,11 +411,34 @@ of this software and associated documentation files (the "Software"), to deal
break;
}

kr = (*m_controller)->USBInterfaceClose(m_controller);
if (@available(macOS 12.0, *))
{
// macOS 12 doesn't like if we're trying to close USB interface here...
}
else
{
kr = (*m_controller)->USBInterfaceClose(m_controller);
if (kr != kIOReturnSuccess) {
LOG(LOG_ERR, "sendControlRequest USBInterfaceClose failed!\n");
}
}

return false;
}

kr = (*m_controller)->USBInterfaceClose(m_controller);
if (@available(macOS 12.0, *))
{
// macOS 12 doesn't like if we're trying to close USB interface here either...
}
else
{
kr = (*m_controller)->USBInterfaceClose(m_controller);
if (kr != kIOReturnSuccess)
{
LOG(LOG_ERR, "sendControlRequest USBInterfaceClose failed!\n");
}
}

return true;
}

Expand Down

0 comments on commit 0aa77fb

Please sign in to comment.