diff options
author | Nathan Hjelm <hjelmn@me.com> | 2010-10-05 19:48:39 -0600 |
---|---|---|
committer | Peter Stuge <peter@stuge.se> | 2010-11-26 20:47:23 +0100 |
commit | 67d9ef7b6877e17f2deec81cd41dc0948f6bed4b (patch) | |
tree | 97ef297d68c354ec95344f8248465d6621f3f224 /libusb/io.c | |
parent | 370922dfbe0964c0b8a0c1974bb1d7b85ac10607 (diff) | |
download | android_external_libusbx-67d9ef7b6877e17f2deec81cd41dc0948f6bed4b.tar.gz android_external_libusbx-67d9ef7b6877e17f2deec81cd41dc0948f6bed4b.tar.bz2 android_external_libusbx-67d9ef7b6877e17f2deec81cd41dc0948f6bed4b.zip |
Remove USBI_OS_HANDLES_TIMEOUT and fix int/isoc timeouts on Darwin
Backends set USBI_TRANSFER_OS_HANDLES_TIMEOUT for transfers instead.
Darwin only handles timeouts for bulk and control transfers, so the
backend now sets that flag accordingly, making libusb core handle
timeouts for interrupt and isochronous transfers. Fixes #31.
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
[stuge: rework libusb_get_next_timeout() and enum usbi_transfer_flags]
[stuge: fix typo; set USBI_TRANSFER_TIMED_OUT flag correctly]
Diffstat (limited to 'libusb/io.c')
-rw-r--r-- | libusb/io.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/libusb/io.c b/libusb/io.c index ab37e8d..c6b42fe 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -1710,16 +1710,6 @@ static void handle_timeout(struct usbi_transfer *itransfer) "async cancel failed %d errno=%d", r, errno); } -#ifdef USBI_OS_HANDLES_TIMEOUT -static int handle_timeouts_locked(struct libusb_context *ctx) -{ - return 0; -} -static int handle_timeouts(struct libusb_context *ctx) -{ - return 0; -} -#else static int handle_timeouts_locked(struct libusb_context *ctx) { int r; @@ -1747,7 +1737,7 @@ static int handle_timeouts_locked(struct libusb_context *ctx) return 0; /* ignore timeouts we've already handled */ - if (transfer->flags & USBI_TRANSFER_TIMED_OUT) + if (transfer->flags & (USBI_TRANSFER_TIMED_OUT | USBI_TRANSFER_OS_HANDLES_TIMEOUT)) continue; /* if transfer has non-expired timeout, nothing more to do */ @@ -1771,7 +1761,6 @@ static int handle_timeouts(struct libusb_context *ctx) usbi_mutex_unlock(&ctx->flying_transfers_lock); return r; } -#endif #ifdef USBI_TIMERFD_AVAILABLE static int handle_timerfd_trigger(struct libusb_context *ctx) @@ -2073,9 +2062,7 @@ int API_EXPORTED libusb_handle_events_locked(libusb_context *ctx, */ int API_EXPORTED libusb_pollfds_handle_timeouts(libusb_context *ctx) { -#if defined(USBI_OS_HANDLES_TIMEOUT) - return 1; -#elif defined(USBI_TIMERFD_AVAILABLE) +#if defined(USBI_TIMERFD_AVAILABLE) USBI_GET_CONTEXT(ctx); return usbi_using_timerfd(ctx); #else @@ -2114,7 +2101,6 @@ int API_EXPORTED libusb_pollfds_handle_timeouts(libusb_context *ctx) int API_EXPORTED libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv) { -#ifndef USBI_OS_HANDLES_TIMEOUT struct usbi_transfer *transfer; struct timespec cur_ts; struct timeval cur_tv; @@ -2135,10 +2121,11 @@ int API_EXPORTED libusb_get_next_timeout(libusb_context *ctx, /* find next transfer which hasn't already been processed as timed out */ list_for_each_entry(transfer, &ctx->flying_transfers, list, struct usbi_transfer) { - if (!(transfer->flags & USBI_TRANSFER_TIMED_OUT)) { - found = 1; - break; - } + if (transfer->flags & (USBI_TRANSFER_TIMED_OUT | USBI_TRANSFER_OS_HANDLES_TIMEOUT)) + continue; + + found = 1; + break; } usbi_mutex_unlock(&ctx->flying_transfers_lock); @@ -2171,9 +2158,6 @@ int API_EXPORTED libusb_get_next_timeout(libusb_context *ctx, } return 1; -#else - return 0; -#endif } /** \ingroup poll |