only call 'libusb_set_interface_alt_setting' when value is changed
This commit is contained in:
parent
431570ffb2
commit
03128d5154
@ -465,7 +465,7 @@ static LIBUSB_DEVICE_DESCRIPTOR* udev_new_descript(URBDRC_PLUGIN* urbdrc, LIBUSB
|
||||
|
||||
static int libusb_udev_select_interface(IUDEVICE* idev, BYTE InterfaceNumber, BYTE AlternateSetting)
|
||||
{
|
||||
int error = 0, diff = 1;
|
||||
int error = 0, diff = 0;
|
||||
UDEVICE* pdev = (UDEVICE*)idev;
|
||||
URBDRC_PLUGIN* urbdrc;
|
||||
MSUSB_CONFIG_DESCRIPTOR* MsConfig;
|
||||
@ -480,21 +480,30 @@ static int libusb_udev_select_interface(IUDEVICE* idev, BYTE InterfaceNumber, BY
|
||||
if (MsConfig)
|
||||
{
|
||||
MsInterfaces = MsConfig->MsInterfaces;
|
||||
|
||||
if ((MsInterfaces) && (MsInterfaces[InterfaceNumber]->AlternateSetting == AlternateSetting))
|
||||
if (MsInterfaces)
|
||||
{
|
||||
diff = 0;
|
||||
WLog_Print(urbdrc->log, WLOG_INFO,
|
||||
"select Interface(%" PRIu8 ") curr AlternateSetting(%" PRIu8
|
||||
") new AlternateSetting(" PRIu8 ")",
|
||||
InterfaceNumber, MsInterfaces[InterfaceNumber]->AlternateSetting,
|
||||
AlternateSetting);
|
||||
|
||||
if (MsInterfaces[InterfaceNumber]->AlternateSetting != AlternateSetting)
|
||||
{
|
||||
diff = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (diff)
|
||||
{
|
||||
error = libusb_set_interface_alt_setting(pdev->libusb_handle, InterfaceNumber,
|
||||
AlternateSetting);
|
||||
|
||||
if (error < 0)
|
||||
if (diff)
|
||||
{
|
||||
WLog_Print(urbdrc->log, WLOG_ERROR, "Set interface altsetting get error num %d", error);
|
||||
error = libusb_set_interface_alt_setting(pdev->libusb_handle, InterfaceNumber,
|
||||
AlternateSetting);
|
||||
|
||||
if (error < 0)
|
||||
{
|
||||
WLog_Print(urbdrc->log, WLOG_ERROR, "Set interface altsetting get error num %d",
|
||||
error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user