usb 2.12.1 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +11 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/usb/bindings.d.ts +0 -1
- package/dist/usb/bindings.js +1 -1
- package/dist/usb/bindings.js.map +1 -1
- package/dist/usb/capability.d.ts +0 -1
- package/dist/usb/capability.js.map +1 -1
- package/dist/usb/descriptors.d.ts +0 -1
- package/dist/usb/device.d.ts +0 -1
- package/dist/usb/device.js.map +1 -1
- package/dist/usb/endpoint.d.ts +0 -1
- package/dist/usb/endpoint.js +2 -2
- package/dist/usb/endpoint.js.map +1 -1
- package/dist/usb/index.js.map +1 -1
- package/dist/usb/interface.js +2 -2
- package/dist/usb/interface.js.map +1 -1
- package/dist/webusb/index.d.ts +1 -3
- package/dist/webusb/index.js.map +1 -1
- package/dist/webusb/webusb-device.d.ts +0 -1
- package/dist/webusb/webusb-device.js +10 -10
- package/dist/webusb/webusb-device.js.map +1 -1
- package/libusb/.codespellrc +3 -0
- package/libusb/.private/appveyor_build.sh +5 -1
- package/libusb/.private/ci-build.sh +26 -1
- package/libusb/.private/ci-container-build.sh +2 -5
- package/libusb/.private/wbs.txt +5 -8
- package/libusb/AUTHORS +22 -0
- package/libusb/ChangeLog +19 -2
- package/libusb/HACKING +25 -0
- package/libusb/INSTALL_WIN.txt +11 -10
- package/libusb/NEWS +2 -2
- package/libusb/README +3 -2
- package/libusb/README.git +1 -1
- package/libusb/Xcode/common.xcconfig +8 -1
- package/libusb/Xcode/config.h +0 -6
- package/libusb/Xcode/debug.xcconfig +4 -1
- package/libusb/Xcode/libusb.xcconfig +1 -1
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +60 -30
- package/libusb/Xcode/libusb_debug.xcconfig +1 -1
- package/libusb/Xcode/libusb_release.xcconfig +1 -1
- package/libusb/Xcode/release.xcconfig +1 -1
- package/libusb/appveyor.yml +33 -9
- package/libusb/configure.ac +68 -37
- package/libusb/examples/dpfp.c +2 -2
- package/libusb/examples/fxload.c +2 -2
- package/libusb/examples/hotplugtest.c +28 -13
- package/libusb/examples/listdevs.c +1 -1
- package/libusb/examples/sam3u_benchmark.c +1 -1
- package/libusb/examples/testlibusb.c +1 -1
- package/libusb/examples/xusb.c +74 -19
- package/libusb/libusb/Makefile.am +11 -1
- package/libusb/libusb/core.c +364 -186
- package/libusb/libusb/descriptor.c +276 -16
- package/libusb/libusb/hotplug.c +5 -4
- package/libusb/libusb/io.c +72 -61
- package/libusb/libusb/libusb-1.0.def +14 -1
- package/libusb/libusb/libusb.h +245 -76
- package/libusb/libusb/libusbi.h +35 -13
- package/libusb/libusb/os/darwin_usb.c +542 -279
- package/libusb/libusb/os/darwin_usb.h +44 -115
- package/libusb/libusb/os/emscripten_webusb.cpp +870 -0
- package/libusb/libusb/os/events_posix.c +40 -0
- package/libusb/libusb/os/events_posix.h +3 -0
- package/libusb/libusb/os/linux_usbfs.c +27 -16
- package/libusb/libusb/os/netbsd_usb.c +36 -36
- package/libusb/libusb/os/openbsd_usb.c +34 -34
- package/libusb/libusb/os/sunos_usb.c +25 -15
- package/libusb/libusb/os/threads_posix.c +1 -5
- package/libusb/libusb/os/windows_common.c +13 -5
- package/libusb/libusb/os/windows_common.h +8 -0
- package/libusb/libusb/os/windows_winusb.c +366 -174
- package/libusb/libusb/os/windows_winusb.h +13 -9
- package/libusb/libusb/strerror.c +5 -5
- package/libusb/libusb/sync.c +24 -19
- package/libusb/libusb/version.h +1 -1
- package/libusb/libusb/version_nano.h +1 -1
- package/libusb/msvc/Base.props +60 -0
- package/libusb/msvc/Configuration.Application.props +7 -0
- package/libusb/msvc/Configuration.Base.props +47 -0
- package/libusb/msvc/Configuration.DynamicLibrary.props +21 -0
- package/libusb/msvc/Configuration.StaticLibrary.props +7 -0
- package/libusb/msvc/ProjectConfigurations.Base.props +69 -0
- package/libusb/msvc/build_all.ps1 +17 -0
- package/libusb/msvc/config.h +2 -2
- package/libusb/msvc/dpfp.vcxproj +33 -0
- package/libusb/msvc/dpfp_threaded.vcxproj +38 -0
- package/libusb/msvc/fxload.vcxproj +46 -0
- package/libusb/msvc/getopt.vcxproj +33 -0
- package/libusb/msvc/hotplugtest.vcxproj +32 -0
- package/libusb/msvc/init_context.vcxproj +35 -0
- package/libusb/msvc/libusb.sln +542 -0
- package/libusb/msvc/libusb_dll.vcxproj +61 -0
- package/libusb/msvc/libusb_static.vcxproj +49 -0
- package/libusb/msvc/listdevs.vcxproj +32 -0
- package/libusb/msvc/sam3u_benchmark.vcxproj +33 -0
- package/libusb/msvc/set_option.vcxproj +35 -0
- package/libusb/msvc/stress.vcxproj +35 -0
- package/libusb/msvc/stress_mt.vcxproj +33 -0
- package/libusb/msvc/testlibusb.vcxproj +32 -0
- package/libusb/msvc/xusb.vcxproj +38 -0
- package/libusb/tests/Makefile.am +25 -3
- package/libusb/tests/init_context.c +153 -0
- package/libusb/tests/macos.c +130 -0
- package/libusb/tests/set_option.c +253 -0
- package/libusb/tests/stress.c +17 -14
- package/libusb/tests/stress_mt.c +265 -0
- package/libusb/tests/testlib.c +1 -1
- package/libusb/tests/umockdev.c +9 -9
- package/libusb/tests/webusb-test-shim/index.js +12 -0
- package/libusb/tests/webusb-test-shim/package-lock.json +50 -0
- package/libusb/tests/webusb-test-shim/package.json +10 -0
- package/package.json +8 -8
- package/prebuilds/android-arm/node.napi.armv7.node +0 -0
- package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
- package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/linux-ia32/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/node.napi.musl.node +0 -0
- package/prebuilds/win32-arm64/node.napi.node +0 -0
- package/prebuilds/win32-ia32/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/device.cc +16 -6
- package/src/transfer.cc +1 -1
- package/libusb/msvc/dpfp_2013.vcxproj +0 -87
- package/libusb/msvc/dpfp_2013.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_2015.vcxproj +0 -87
- package/libusb/msvc/dpfp_2015.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_2017.vcxproj +0 -106
- package/libusb/msvc/dpfp_2017.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_2019.vcxproj +0 -106
- package/libusb/msvc/dpfp_2019.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_threaded_2013.vcxproj +0 -87
- package/libusb/msvc/dpfp_threaded_2013.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_threaded_2015.vcxproj +0 -87
- package/libusb/msvc/dpfp_threaded_2015.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_threaded_2017.vcxproj +0 -106
- package/libusb/msvc/dpfp_threaded_2017.vcxproj.filters +0 -26
- package/libusb/msvc/dpfp_threaded_2019.vcxproj +0 -106
- package/libusb/msvc/dpfp_threaded_2019.vcxproj.filters +0 -26
- package/libusb/msvc/fxload_2013.vcxproj +0 -94
- package/libusb/msvc/fxload_2013.vcxproj.filters +0 -35
- package/libusb/msvc/fxload_2015.vcxproj +0 -94
- package/libusb/msvc/fxload_2015.vcxproj.filters +0 -35
- package/libusb/msvc/fxload_2017.vcxproj +0 -113
- package/libusb/msvc/fxload_2017.vcxproj.filters +0 -35
- package/libusb/msvc/fxload_2019.vcxproj +0 -113
- package/libusb/msvc/fxload_2019.vcxproj.filters +0 -35
- package/libusb/msvc/getopt_2013.vcxproj +0 -72
- package/libusb/msvc/getopt_2013.vcxproj.filters +0 -26
- package/libusb/msvc/getopt_2015.vcxproj +0 -73
- package/libusb/msvc/getopt_2015.vcxproj.filters +0 -26
- package/libusb/msvc/getopt_2017.vcxproj +0 -92
- package/libusb/msvc/getopt_2017.vcxproj.filters +0 -26
- package/libusb/msvc/getopt_2019.vcxproj +0 -92
- package/libusb/msvc/getopt_2019.vcxproj.filters +0 -26
- package/libusb/msvc/hotplugtest_2013.vcxproj +0 -86
- package/libusb/msvc/hotplugtest_2013.vcxproj.filters +0 -23
- package/libusb/msvc/hotplugtest_2015.vcxproj +0 -86
- package/libusb/msvc/hotplugtest_2015.vcxproj.filters +0 -23
- package/libusb/msvc/hotplugtest_2017.vcxproj +0 -105
- package/libusb/msvc/hotplugtest_2017.vcxproj.filters +0 -23
- package/libusb/msvc/hotplugtest_2019.vcxproj +0 -105
- package/libusb/msvc/hotplugtest_2019.vcxproj.filters +0 -23
- package/libusb/msvc/libusb_2013.sln +0 -137
- package/libusb/msvc/libusb_2015.sln +0 -137
- package/libusb/msvc/libusb_2017.sln +0 -240
- package/libusb/msvc/libusb_2019.sln +0 -240
- package/libusb/msvc/libusb_dll_2013.vcxproj +0 -104
- package/libusb/msvc/libusb_dll_2013.vcxproj.filters +0 -94
- package/libusb/msvc/libusb_dll_2015.vcxproj +0 -105
- package/libusb/msvc/libusb_dll_2015.vcxproj.filters +0 -94
- package/libusb/msvc/libusb_dll_2017.vcxproj +0 -124
- package/libusb/msvc/libusb_dll_2017.vcxproj.filters +0 -94
- package/libusb/msvc/libusb_dll_2019.vcxproj +0 -124
- package/libusb/msvc/libusb_dll_2019.vcxproj.filters +0 -94
- package/libusb/msvc/libusb_static_2013.vcxproj +0 -94
- package/libusb/msvc/libusb_static_2013.vcxproj.filters +0 -80
- package/libusb/msvc/libusb_static_2015.vcxproj +0 -95
- package/libusb/msvc/libusb_static_2015.vcxproj.filters +0 -80
- package/libusb/msvc/libusb_static_2017.vcxproj +0 -114
- package/libusb/msvc/libusb_static_2017.vcxproj.filters +0 -80
- package/libusb/msvc/libusb_static_2019.vcxproj +0 -114
- package/libusb/msvc/libusb_static_2019.vcxproj.filters +0 -80
- package/libusb/msvc/listdevs_2013.vcxproj +0 -86
- package/libusb/msvc/listdevs_2013.vcxproj.filters +0 -23
- package/libusb/msvc/listdevs_2015.vcxproj +0 -86
- package/libusb/msvc/listdevs_2015.vcxproj.filters +0 -23
- package/libusb/msvc/listdevs_2017.vcxproj +0 -105
- package/libusb/msvc/listdevs_2017.vcxproj.filters +0 -23
- package/libusb/msvc/listdevs_2019.vcxproj +0 -105
- package/libusb/msvc/listdevs_2019.vcxproj.filters +0 -23
- package/libusb/msvc/sam3u_benchmark_2013.vcxproj +0 -87
- package/libusb/msvc/sam3u_benchmark_2013.vcxproj.filters +0 -26
- package/libusb/msvc/sam3u_benchmark_2015.vcxproj +0 -87
- package/libusb/msvc/sam3u_benchmark_2015.vcxproj.filters +0 -26
- package/libusb/msvc/sam3u_benchmark_2017.vcxproj +0 -106
- package/libusb/msvc/sam3u_benchmark_2017.vcxproj.filters +0 -26
- package/libusb/msvc/sam3u_benchmark_2019.vcxproj +0 -106
- package/libusb/msvc/sam3u_benchmark_2019.vcxproj.filters +0 -26
- package/libusb/msvc/stress_2013.vcxproj +0 -89
- package/libusb/msvc/stress_2013.vcxproj.filters +0 -32
- package/libusb/msvc/stress_2015.vcxproj +0 -89
- package/libusb/msvc/stress_2015.vcxproj.filters +0 -32
- package/libusb/msvc/stress_2017.vcxproj +0 -108
- package/libusb/msvc/stress_2017.vcxproj.filters +0 -32
- package/libusb/msvc/stress_2019.vcxproj +0 -108
- package/libusb/msvc/stress_2019.vcxproj.filters +0 -32
- package/libusb/msvc/testlibusb_2013.vcxproj +0 -86
- package/libusb/msvc/testlibusb_2013.vcxproj.filters +0 -23
- package/libusb/msvc/testlibusb_2015.vcxproj +0 -86
- package/libusb/msvc/testlibusb_2015.vcxproj.filters +0 -23
- package/libusb/msvc/testlibusb_2017.vcxproj +0 -105
- package/libusb/msvc/testlibusb_2017.vcxproj.filters +0 -23
- package/libusb/msvc/testlibusb_2019.vcxproj +0 -105
- package/libusb/msvc/testlibusb_2019.vcxproj.filters +0 -23
- package/libusb/msvc/xusb_2013.vcxproj +0 -86
- package/libusb/msvc/xusb_2013.vcxproj.filters +0 -23
- package/libusb/msvc/xusb_2015.vcxproj +0 -86
- package/libusb/msvc/xusb_2015.vcxproj.filters +0 -23
- package/libusb/msvc/xusb_2017.vcxproj +0 -105
- package/libusb/msvc/xusb_2017.vcxproj.filters +0 -23
- package/libusb/msvc/xusb_2019.vcxproj +0 -105
- package/libusb/msvc/xusb_2019.vcxproj.filters +0 -23
package/libusb/libusb/io.c
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* I/O functions for libusb
|
|
4
4
|
* Copyright © 2007-2009 Daniel Drake <dsd@gentoo.org>
|
|
5
5
|
* Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
|
|
6
|
-
* Copyright © 2019 Nathan Hjelm <hjelmn@cs.
|
|
7
|
-
* Copyright © 2019 Google LLC. All rights reserved.
|
|
6
|
+
* Copyright © 2019-2022 Nathan Hjelm <hjelmn@cs.unm.edu>
|
|
7
|
+
* Copyright © 2019-2022 Google LLC. All rights reserved.
|
|
8
8
|
*
|
|
9
9
|
* This library is free software; you can redistribute it and/or
|
|
10
10
|
* modify it under the terms of the GNU Lesser General Public
|
|
@@ -313,6 +313,10 @@ if (r == 0 && actual_length == sizeof(data)) {
|
|
|
313
313
|
* be invoked, and the callback function should check the transfer status to
|
|
314
314
|
* determine that it was cancelled.
|
|
315
315
|
*
|
|
316
|
+
* On macOS and iOS it is not possible to cancel a single transfer. In this
|
|
317
|
+
* case cancelling one transfer on an endpoint will cause all transfers on
|
|
318
|
+
* that endpoint to be cancelled.
|
|
319
|
+
*
|
|
316
320
|
* Freeing the transfer after it has been cancelled but before cancellation
|
|
317
321
|
* has completed will result in undefined behaviour.
|
|
318
322
|
*
|
|
@@ -1240,8 +1244,8 @@ void usbi_io_exit(struct libusb_context *ctx)
|
|
|
1240
1244
|
|
|
1241
1245
|
static void calculate_timeout(struct usbi_transfer *itransfer)
|
|
1242
1246
|
{
|
|
1243
|
-
|
|
1244
|
-
|
|
1247
|
+
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
1248
|
+
unsigned int timeout = transfer->timeout;
|
|
1245
1249
|
|
|
1246
1250
|
if (!timeout) {
|
|
1247
1251
|
TIMESPEC_CLEAR(&itransfer->timeout);
|
|
@@ -1285,30 +1289,25 @@ DEFAULT_VISIBILITY
|
|
|
1285
1289
|
struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(
|
|
1286
1290
|
int iso_packets)
|
|
1287
1291
|
{
|
|
1288
|
-
size_t priv_size;
|
|
1289
|
-
size_t alloc_size;
|
|
1290
|
-
unsigned char *ptr;
|
|
1291
|
-
struct usbi_transfer *itransfer;
|
|
1292
|
-
struct libusb_transfer *transfer;
|
|
1293
|
-
|
|
1294
1292
|
assert(iso_packets >= 0);
|
|
1295
1293
|
if (iso_packets < 0)
|
|
1296
1294
|
return NULL;
|
|
1297
1295
|
|
|
1298
|
-
priv_size = PTR_ALIGN(usbi_backend.transfer_priv_size);
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
ptr = calloc(1, alloc_size);
|
|
1296
|
+
size_t priv_size = PTR_ALIGN(usbi_backend.transfer_priv_size);
|
|
1297
|
+
size_t usbi_transfer_size = PTR_ALIGN(sizeof(struct usbi_transfer));
|
|
1298
|
+
size_t libusb_transfer_size = PTR_ALIGN(sizeof(struct libusb_transfer));
|
|
1299
|
+
size_t iso_packets_size = sizeof(struct libusb_iso_packet_descriptor) * (size_t)iso_packets;
|
|
1300
|
+
size_t alloc_size = priv_size + usbi_transfer_size + libusb_transfer_size + iso_packets_size;
|
|
1301
|
+
unsigned char *ptr = calloc(1, alloc_size);
|
|
1304
1302
|
if (!ptr)
|
|
1305
1303
|
return NULL;
|
|
1306
1304
|
|
|
1307
|
-
itransfer = (struct usbi_transfer *)(ptr + priv_size);
|
|
1305
|
+
struct usbi_transfer *itransfer = (struct usbi_transfer *)(ptr + priv_size);
|
|
1308
1306
|
itransfer->num_iso_packets = iso_packets;
|
|
1309
1307
|
itransfer->priv = ptr;
|
|
1310
1308
|
usbi_mutex_init(&itransfer->lock);
|
|
1311
|
-
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
1309
|
+
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
1310
|
+
|
|
1312
1311
|
return transfer;
|
|
1313
1312
|
}
|
|
1314
1313
|
|
|
@@ -1331,31 +1330,26 @@ struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(
|
|
|
1331
1330
|
*/
|
|
1332
1331
|
void API_EXPORTED libusb_free_transfer(struct libusb_transfer *transfer)
|
|
1333
1332
|
{
|
|
1334
|
-
struct usbi_transfer *itransfer;
|
|
1335
|
-
size_t priv_size;
|
|
1336
|
-
unsigned char *ptr;
|
|
1337
|
-
|
|
1338
1333
|
if (!transfer)
|
|
1339
1334
|
return;
|
|
1340
1335
|
|
|
1341
|
-
usbi_dbg(TRANSFER_CTX(transfer), "transfer %p", transfer);
|
|
1336
|
+
usbi_dbg(TRANSFER_CTX(transfer), "transfer %p", (void *) transfer);
|
|
1342
1337
|
if (transfer->flags & LIBUSB_TRANSFER_FREE_BUFFER)
|
|
1343
1338
|
free(transfer->buffer);
|
|
1344
1339
|
|
|
1345
|
-
itransfer = LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer);
|
|
1340
|
+
struct usbi_transfer *itransfer = LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer);
|
|
1346
1341
|
usbi_mutex_destroy(&itransfer->lock);
|
|
1347
1342
|
if (itransfer->dev)
|
|
1348
1343
|
libusb_unref_device(itransfer->dev);
|
|
1349
1344
|
|
|
1350
|
-
|
|
1351
|
-
ptr = (unsigned char *)itransfer - priv_size;
|
|
1345
|
+
unsigned char *ptr = USBI_TRANSFER_TO_TRANSFER_PRIV(itransfer);
|
|
1352
1346
|
assert(ptr == itransfer->priv);
|
|
1353
1347
|
free(ptr);
|
|
1354
1348
|
}
|
|
1355
1349
|
|
|
1356
1350
|
/* iterates through the flying transfers, and rearms the timer based on the
|
|
1357
1351
|
* next upcoming timeout.
|
|
1358
|
-
* must be
|
|
1352
|
+
* NB: flying_transfers_lock must be held when calling this.
|
|
1359
1353
|
* returns 0 on success or a LIBUSB_ERROR code on failure.
|
|
1360
1354
|
*/
|
|
1361
1355
|
#ifdef HAVE_OS_TIMER
|
|
@@ -1376,7 +1370,8 @@ static int arm_timer_for_next_timeout(struct libusb_context *ctx)
|
|
|
1376
1370
|
|
|
1377
1371
|
/* act on first transfer that has not already been handled */
|
|
1378
1372
|
if (!(itransfer->timeout_flags & (USBI_TRANSFER_TIMEOUT_HANDLED | USBI_TRANSFER_OS_HANDLES_TIMEOUT))) {
|
|
1379
|
-
|
|
1373
|
+
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
1374
|
+
usbi_dbg(ctx, "next timeout originally %ums", transfer->timeout);
|
|
1380
1375
|
return usbi_arm_timer(&ctx->timer, cur_ts);
|
|
1381
1376
|
}
|
|
1382
1377
|
}
|
|
@@ -1394,7 +1389,8 @@ static inline int arm_timer_for_next_timeout(struct libusb_context *ctx)
|
|
|
1394
1389
|
|
|
1395
1390
|
/* add a transfer to the (timeout-sorted) active transfers list.
|
|
1396
1391
|
* This function will return non 0 if fails to update the timer,
|
|
1397
|
-
* in which case the transfer is *not* on the flying_transfers list.
|
|
1392
|
+
* in which case the transfer is *not* on the flying_transfers list.
|
|
1393
|
+
* NB: flying_transfers_lock MUST be held when calling this. */
|
|
1398
1394
|
static int add_to_flying_list(struct usbi_transfer *itransfer)
|
|
1399
1395
|
{
|
|
1400
1396
|
struct usbi_transfer *cur;
|
|
@@ -1438,8 +1434,9 @@ out:
|
|
|
1438
1434
|
if (first && usbi_using_timer(ctx) && TIMESPEC_IS_SET(timeout)) {
|
|
1439
1435
|
/* if this transfer has the lowest timeout of all active transfers,
|
|
1440
1436
|
* rearm the timer with this transfer's timeout */
|
|
1437
|
+
struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
1441
1438
|
usbi_dbg(ctx, "arm timer for timeout in %ums (first in line)",
|
|
1442
|
-
|
|
1439
|
+
transfer->timeout);
|
|
1443
1440
|
r = usbi_arm_timer(&ctx->timer, timeout);
|
|
1444
1441
|
}
|
|
1445
1442
|
#else
|
|
@@ -1455,20 +1452,19 @@ out:
|
|
|
1455
1452
|
/* remove a transfer from the active transfers list.
|
|
1456
1453
|
* This function will *always* remove the transfer from the
|
|
1457
1454
|
* flying_transfers list. It will return a LIBUSB_ERROR code
|
|
1458
|
-
* if it fails to update the timer for the next timeout.
|
|
1455
|
+
* if it fails to update the timer for the next timeout.
|
|
1456
|
+
* NB: flying_transfers_lock MUST be held when calling this. */
|
|
1459
1457
|
static int remove_from_flying_list(struct usbi_transfer *itransfer)
|
|
1460
1458
|
{
|
|
1461
1459
|
struct libusb_context *ctx = ITRANSFER_CTX(itransfer);
|
|
1462
1460
|
int rearm_timer;
|
|
1463
1461
|
int r = 0;
|
|
1464
1462
|
|
|
1465
|
-
usbi_mutex_lock(&ctx->flying_transfers_lock);
|
|
1466
1463
|
rearm_timer = (TIMESPEC_IS_SET(&itransfer->timeout) &&
|
|
1467
1464
|
list_first_entry(&ctx->flying_transfers, struct usbi_transfer, list) == itransfer);
|
|
1468
1465
|
list_del(&itransfer->list);
|
|
1469
1466
|
if (rearm_timer)
|
|
1470
1467
|
r = arm_timer_for_next_timeout(ctx);
|
|
1471
|
-
usbi_mutex_unlock(&ctx->flying_transfers_lock);
|
|
1472
1468
|
|
|
1473
1469
|
return r;
|
|
1474
1470
|
}
|
|
@@ -1479,11 +1475,11 @@ static int remove_from_flying_list(struct usbi_transfer *itransfer)
|
|
|
1479
1475
|
*
|
|
1480
1476
|
* \param transfer the transfer to submit
|
|
1481
1477
|
* \returns 0 on success
|
|
1482
|
-
* \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
|
|
1483
|
-
* \returns LIBUSB_ERROR_BUSY if the transfer has already been submitted.
|
|
1484
|
-
* \returns LIBUSB_ERROR_NOT_SUPPORTED if the transfer flags are not supported
|
|
1478
|
+
* \returns \ref LIBUSB_ERROR_NO_DEVICE if the device has been disconnected
|
|
1479
|
+
* \returns \ref LIBUSB_ERROR_BUSY if the transfer has already been submitted.
|
|
1480
|
+
* \returns \ref LIBUSB_ERROR_NOT_SUPPORTED if the transfer flags are not supported
|
|
1485
1481
|
* by the operating system.
|
|
1486
|
-
* \returns LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than
|
|
1482
|
+
* \returns \ref LIBUSB_ERROR_INVALID_PARAM if the transfer size is larger than
|
|
1487
1483
|
* the operating system and/or hardware can support (see \ref asynclimits)
|
|
1488
1484
|
* \returns another LIBUSB_ERROR code on other failure
|
|
1489
1485
|
*/
|
|
@@ -1500,7 +1496,7 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer)
|
|
|
1500
1496
|
itransfer->dev = libusb_ref_device(transfer->dev_handle->dev);
|
|
1501
1497
|
|
|
1502
1498
|
ctx = HANDLE_CTX(transfer->dev_handle);
|
|
1503
|
-
usbi_dbg(ctx, "transfer %p", transfer);
|
|
1499
|
+
usbi_dbg(ctx, "transfer %p", (void *) transfer);
|
|
1504
1500
|
|
|
1505
1501
|
/*
|
|
1506
1502
|
* Important note on locking, this function takes / releases locks
|
|
@@ -1562,8 +1558,11 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer)
|
|
|
1562
1558
|
}
|
|
1563
1559
|
usbi_mutex_unlock(&itransfer->lock);
|
|
1564
1560
|
|
|
1565
|
-
if (r != LIBUSB_SUCCESS)
|
|
1561
|
+
if (r != LIBUSB_SUCCESS) {
|
|
1562
|
+
usbi_mutex_lock(&ctx->flying_transfers_lock);
|
|
1566
1563
|
remove_from_flying_list(itransfer);
|
|
1564
|
+
usbi_mutex_unlock(&ctx->flying_transfers_lock);
|
|
1565
|
+
}
|
|
1567
1566
|
|
|
1568
1567
|
return r;
|
|
1569
1568
|
}
|
|
@@ -1584,21 +1583,23 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer)
|
|
|
1584
1583
|
* \ref libusb_transfer_status::LIBUSB_TRANSFER_CANCELLED
|
|
1585
1584
|
* "LIBUSB_TRANSFER_CANCELLED" for each transfer that was cancelled.
|
|
1586
1585
|
|
|
1587
|
-
* -
|
|
1588
|
-
* for the transfer's endpoint.
|
|
1589
|
-
*
|
|
1590
|
-
*
|
|
1591
|
-
*
|
|
1592
|
-
*
|
|
1593
|
-
*
|
|
1594
|
-
*
|
|
1595
|
-
*
|
|
1596
|
-
*
|
|
1586
|
+
* - When built for macOS versions prior to 10.5, this function sends a
|
|
1587
|
+
* \c ClearFeature(ENDPOINT_HALT) request for the transfer's endpoint.
|
|
1588
|
+
* (Prior to libusb 1.0.27, this request was sent on all Darwin systems.)
|
|
1589
|
+
* If the device does not handle this request correctly, the data toggle
|
|
1590
|
+
* bits for the endpoint can be left out of sync between host and device,
|
|
1591
|
+
* which can have unpredictable results when the next data is sent on
|
|
1592
|
+
* the endpoint, including data being silently lost. A call to
|
|
1593
|
+
* \ref libusb_clear_halt will not resolve this situation, since that
|
|
1594
|
+
* function uses the same request. Therefore, if your program runs on
|
|
1595
|
+
* macOS < 10.5 (or libusb < 1.0.27), and uses a device that does not
|
|
1596
|
+
* correctly implement \c ClearFeature(ENDPOINT_HALT) requests, it may
|
|
1597
|
+
* only be safe to cancel transfers when followed by a device reset using
|
|
1597
1598
|
* \ref libusb_reset_device.
|
|
1598
1599
|
*
|
|
1599
1600
|
* \param transfer the transfer to cancel
|
|
1600
1601
|
* \returns 0 on success
|
|
1601
|
-
* \returns LIBUSB_ERROR_NOT_FOUND if the transfer is not in progress,
|
|
1602
|
+
* \returns \ref LIBUSB_ERROR_NOT_FOUND if the transfer is not in progress,
|
|
1602
1603
|
* already complete, or already cancelled.
|
|
1603
1604
|
* \returns a LIBUSB_ERROR code on failure
|
|
1604
1605
|
*/
|
|
@@ -1609,7 +1610,7 @@ int API_EXPORTED libusb_cancel_transfer(struct libusb_transfer *transfer)
|
|
|
1609
1610
|
struct libusb_context *ctx = ITRANSFER_CTX(itransfer);
|
|
1610
1611
|
int r;
|
|
1611
1612
|
|
|
1612
|
-
usbi_dbg(ctx, "transfer %p", transfer );
|
|
1613
|
+
usbi_dbg(ctx, "transfer %p", (void *) transfer );
|
|
1613
1614
|
usbi_mutex_lock(&itransfer->lock);
|
|
1614
1615
|
if (!(itransfer->state_flags & USBI_TRANSFER_IN_FLIGHT)
|
|
1615
1616
|
|| (itransfer->state_flags & USBI_TRANSFER_CANCELLING)) {
|
|
@@ -1689,7 +1690,9 @@ int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
|
|
|
1689
1690
|
uint8_t flags;
|
|
1690
1691
|
int r;
|
|
1691
1692
|
|
|
1693
|
+
usbi_mutex_lock(&ctx->flying_transfers_lock);
|
|
1692
1694
|
r = remove_from_flying_list(itransfer);
|
|
1695
|
+
usbi_mutex_unlock(&ctx->flying_transfers_lock);
|
|
1693
1696
|
if (r < 0)
|
|
1694
1697
|
usbi_err(ctx, "failed to set timer for next timeout");
|
|
1695
1698
|
|
|
@@ -1711,9 +1714,13 @@ int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
|
|
|
1711
1714
|
flags = transfer->flags;
|
|
1712
1715
|
transfer->status = status;
|
|
1713
1716
|
transfer->actual_length = itransfer->transferred;
|
|
1714
|
-
usbi_dbg(ctx, "transfer %p has callback %p",
|
|
1715
|
-
|
|
1717
|
+
usbi_dbg(ctx, "transfer %p has callback %p",
|
|
1718
|
+
(void *) transfer, transfer->callback);
|
|
1719
|
+
if (transfer->callback) {
|
|
1720
|
+
libusb_lock_event_waiters (ctx);
|
|
1716
1721
|
transfer->callback(transfer);
|
|
1722
|
+
libusb_unlock_event_waiters(ctx);
|
|
1723
|
+
}
|
|
1717
1724
|
/* transfer might have been freed by the above call, do not use from
|
|
1718
1725
|
* this point. */
|
|
1719
1726
|
if (flags & LIBUSB_TRANSFER_FREE_TRANSFER)
|
|
@@ -2013,7 +2020,7 @@ void API_EXPORTED libusb_unlock_event_waiters(libusb_context *ctx)
|
|
|
2013
2020
|
* indicates unlimited timeout.
|
|
2014
2021
|
* \returns 0 after a transfer completes or another thread stops event handling
|
|
2015
2022
|
* \returns 1 if the timeout expired
|
|
2016
|
-
* \returns LIBUSB_ERROR_INVALID_PARAM if timeval is invalid
|
|
2023
|
+
* \returns \ref LIBUSB_ERROR_INVALID_PARAM if timeval is invalid
|
|
2017
2024
|
* \ref libusb_mtasync
|
|
2018
2025
|
*/
|
|
2019
2026
|
int API_EXPORTED libusb_wait_for_event(libusb_context *ctx, struct timeval *tv)
|
|
@@ -2037,6 +2044,7 @@ int API_EXPORTED libusb_wait_for_event(libusb_context *ctx, struct timeval *tv)
|
|
|
2037
2044
|
return 0;
|
|
2038
2045
|
}
|
|
2039
2046
|
|
|
2047
|
+
// NB: flying_transfers_lock must be held when calling this
|
|
2040
2048
|
static void handle_timeout(struct usbi_transfer *itransfer)
|
|
2041
2049
|
{
|
|
2042
2050
|
struct libusb_transfer *transfer =
|
|
@@ -2052,6 +2060,7 @@ static void handle_timeout(struct usbi_transfer *itransfer)
|
|
|
2052
2060
|
"async cancel failed %d", r);
|
|
2053
2061
|
}
|
|
2054
2062
|
|
|
2063
|
+
// NB: flying_transfers_lock must be held when calling this
|
|
2055
2064
|
static void handle_timeouts_locked(struct libusb_context *ctx)
|
|
2056
2065
|
{
|
|
2057
2066
|
struct timespec systime;
|
|
@@ -2332,7 +2341,7 @@ static int get_next_timeout(libusb_context *ctx, struct timeval *tv,
|
|
|
2332
2341
|
* timeval struct for non-blocking mode
|
|
2333
2342
|
* \param completed pointer to completion integer to check, or NULL
|
|
2334
2343
|
* \returns 0 on success
|
|
2335
|
-
* \returns LIBUSB_ERROR_INVALID_PARAM if timeval is invalid
|
|
2344
|
+
* \returns \ref LIBUSB_ERROR_INVALID_PARAM if timeval is invalid
|
|
2336
2345
|
* \returns another LIBUSB_ERROR code on other failure
|
|
2337
2346
|
* \ref libusb_mtasync
|
|
2338
2347
|
*/
|
|
@@ -2474,7 +2483,7 @@ int API_EXPORTED libusb_handle_events_completed(libusb_context *ctx,
|
|
|
2474
2483
|
* \param tv the maximum time to block waiting for events, or zero for
|
|
2475
2484
|
* non-blocking mode
|
|
2476
2485
|
* \returns 0 on success
|
|
2477
|
-
* \returns LIBUSB_ERROR_INVALID_PARAM if timeval is invalid
|
|
2486
|
+
* \returns \ref LIBUSB_ERROR_INVALID_PARAM if timeval is invalid
|
|
2478
2487
|
* \returns another LIBUSB_ERROR code on other failure
|
|
2479
2488
|
* \ref libusb_mtasync
|
|
2480
2489
|
*/
|
|
@@ -2558,7 +2567,7 @@ int API_EXPORTED libusb_pollfds_handle_timeouts(libusb_context *ctx)
|
|
|
2558
2567
|
* \param tv output location for a relative time against the current
|
|
2559
2568
|
* clock in which libusb must be called into in order to process timeout events
|
|
2560
2569
|
* \returns 0 if there are no pending timeouts, 1 if a timeout was returned,
|
|
2561
|
-
* or LIBUSB_ERROR_OTHER on failure
|
|
2570
|
+
* or \ref LIBUSB_ERROR_OTHER on failure
|
|
2562
2571
|
*/
|
|
2563
2572
|
int API_EXPORTED libusb_get_next_timeout(libusb_context *ctx,
|
|
2564
2573
|
struct timeval *tv)
|
|
@@ -2619,11 +2628,11 @@ int API_EXPORTED libusb_get_next_timeout(libusb_context *ctx,
|
|
|
2619
2628
|
* To remove notifiers, pass NULL values for the function pointers.
|
|
2620
2629
|
*
|
|
2621
2630
|
* Note that file descriptors may have been added even before you register
|
|
2622
|
-
* these notifiers (e.g. at
|
|
2631
|
+
* these notifiers (e.g. at libusb_init_context() time).
|
|
2623
2632
|
*
|
|
2624
2633
|
* Additionally, note that the removal notifier may be called during
|
|
2625
2634
|
* libusb_exit() (e.g. when it is closing file descriptors that were opened
|
|
2626
|
-
* and added to the poll set at
|
|
2635
|
+
* and added to the poll set at libusb_init_context() time). If you don't want this,
|
|
2627
2636
|
* remove the notifiers immediately before calling libusb_exit().
|
|
2628
2637
|
*
|
|
2629
2638
|
* \param ctx the context to operate on, or NULL for the default context
|
|
@@ -2827,7 +2836,8 @@ void usbi_handle_disconnect(struct libusb_device_handle *dev_handle)
|
|
|
2827
2836
|
to_cancel = NULL;
|
|
2828
2837
|
usbi_mutex_lock(&ctx->flying_transfers_lock);
|
|
2829
2838
|
for_each_transfer(ctx, cur) {
|
|
2830
|
-
|
|
2839
|
+
struct libusb_transfer *cur_transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(cur);
|
|
2840
|
+
if (cur_transfer->dev_handle == dev_handle) {
|
|
2831
2841
|
usbi_mutex_lock(&cur->lock);
|
|
2832
2842
|
if (cur->state_flags & USBI_TRANSFER_IN_FLIGHT)
|
|
2833
2843
|
to_cancel = cur;
|
|
@@ -2842,8 +2852,9 @@ void usbi_handle_disconnect(struct libusb_device_handle *dev_handle)
|
|
|
2842
2852
|
if (!to_cancel)
|
|
2843
2853
|
break;
|
|
2844
2854
|
|
|
2855
|
+
struct libusb_transfer *transfer_to_cancel = USBI_TRANSFER_TO_LIBUSB_TRANSFER(to_cancel);
|
|
2845
2856
|
usbi_dbg(ctx, "cancelling transfer %p from disconnect",
|
|
2846
|
-
|
|
2857
|
+
(void *) transfer_to_cancel);
|
|
2847
2858
|
|
|
2848
2859
|
usbi_mutex_lock(&to_cancel->lock);
|
|
2849
2860
|
usbi_backend.clear_transfer_priv(to_cancel);
|
|
@@ -40,6 +40,10 @@ EXPORTS
|
|
|
40
40
|
libusb_free_container_id_descriptor@4 = libusb_free_container_id_descriptor
|
|
41
41
|
libusb_free_device_list
|
|
42
42
|
libusb_free_device_list@8 = libusb_free_device_list
|
|
43
|
+
libusb_free_interface_association_descriptors
|
|
44
|
+
libusb_free_interface_association_descriptors@4 = libusb_free_interface_association_descriptors
|
|
45
|
+
libusb_free_platform_descriptor
|
|
46
|
+
libusb_free_platform_descriptor@4 = libusb_free_platform_descriptor
|
|
43
47
|
libusb_free_pollfds
|
|
44
48
|
libusb_free_pollfds@4 = libusb_free_pollfds
|
|
45
49
|
libusb_free_ss_endpoint_companion_descriptor
|
|
@@ -54,6 +58,8 @@ EXPORTS
|
|
|
54
58
|
libusb_free_usb_2_0_extension_descriptor@4 = libusb_free_usb_2_0_extension_descriptor
|
|
55
59
|
libusb_get_active_config_descriptor
|
|
56
60
|
libusb_get_active_config_descriptor@8 = libusb_get_active_config_descriptor
|
|
61
|
+
libusb_get_active_interface_association_descriptors
|
|
62
|
+
libusb_get_active_interface_association_descriptors@8 = libusb_get_active_interface_association_descriptors
|
|
57
63
|
libusb_get_bos_descriptor
|
|
58
64
|
libusb_get_bos_descriptor@8 = libusb_get_bos_descriptor
|
|
59
65
|
libusb_get_bus_number
|
|
@@ -76,6 +82,10 @@ EXPORTS
|
|
|
76
82
|
libusb_get_device_list@8 = libusb_get_device_list
|
|
77
83
|
libusb_get_device_speed
|
|
78
84
|
libusb_get_device_speed@4 = libusb_get_device_speed
|
|
85
|
+
libusb_get_interface_association_descriptors
|
|
86
|
+
libusb_get_interface_association_descriptors@12 = libusb_get_interface_association_descriptors
|
|
87
|
+
libusb_get_max_alt_packet_size
|
|
88
|
+
libusb_get_max_alt_packet_size@16 = libusb_get_max_alt_packet_size
|
|
79
89
|
libusb_get_max_iso_packet_size
|
|
80
90
|
libusb_get_max_iso_packet_size@8 = libusb_get_max_iso_packet_size
|
|
81
91
|
libusb_get_max_packet_size
|
|
@@ -84,6 +94,8 @@ EXPORTS
|
|
|
84
94
|
libusb_get_next_timeout@8 = libusb_get_next_timeout
|
|
85
95
|
libusb_get_parent
|
|
86
96
|
libusb_get_parent@4 = libusb_get_parent
|
|
97
|
+
libusb_get_platform_descriptor
|
|
98
|
+
libusb_get_platform_descriptor@12 = libusb_get_platform_descriptor
|
|
87
99
|
libusb_get_pollfds
|
|
88
100
|
libusb_get_pollfds@4 = libusb_get_pollfds
|
|
89
101
|
libusb_get_port_number
|
|
@@ -122,6 +134,8 @@ EXPORTS
|
|
|
122
134
|
libusb_hotplug_register_callback@36 = libusb_hotplug_register_callback
|
|
123
135
|
libusb_init
|
|
124
136
|
libusb_init@4 = libusb_init
|
|
137
|
+
libusb_init_context
|
|
138
|
+
libusb_init_context@12 = libusb_init_context
|
|
125
139
|
libusb_interrupt_event_handler
|
|
126
140
|
libusb_interrupt_event_handler@4 = libusb_interrupt_event_handler
|
|
127
141
|
libusb_interrupt_transfer
|
|
@@ -155,7 +169,6 @@ EXPORTS
|
|
|
155
169
|
libusb_set_log_cb
|
|
156
170
|
libusb_set_log_cb@12 = libusb_set_log_cb
|
|
157
171
|
libusb_set_option
|
|
158
|
-
libusb_set_option@8 = libusb_set_option
|
|
159
172
|
libusb_set_pollfd_notifiers
|
|
160
173
|
libusb_set_pollfd_notifiers@16 = libusb_set_pollfd_notifiers
|
|
161
174
|
libusb_setlocale
|