Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addresses issue #408 for macOS. Under macOS, when libusb_cancel_transfer #924

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions host/libraries/libbladeRF/src/backend/usb/libusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,29 @@ static inline void cancel_all_transfers(struct bladerf_stream *stream)
int status;
struct lusb_stream_data *stream_data = stream->backend_data;

#ifdef __APPLE__
/* For macOS and iOS, canceling one transfer will cause all transfers
* on the same endpoint to be cancelled.
*/
bool have_cancelled = false;

for (i = 0; i < stream_data->num_transfers; i++) {
if (stream_data->transfer_status[i] == TRANSFER_IN_FLIGHT) {
if (!have_cancelled) {
status = libusb_cancel_transfer(stream_data->transfers[i]);
if (status < 0 && status != LIBUSB_ERROR_NOT_FOUND) {
log_error("Error canceling transfer (%d): %s\n",
status, libusb_error_name(status));
} else {
stream_data->transfer_status[i] = TRANSFER_CANCEL_PENDING;
}
have_cancelled = true;
} else {
stream_data->transfer_status[i] = TRANSFER_CANCEL_PENDING;
}
}
}
#else
for (i = 0; i < stream_data->num_transfers; i++) {
if (stream_data->transfer_status[i] == TRANSFER_IN_FLIGHT) {
status = libusb_cancel_transfer(stream_data->transfers[i]);
Expand All @@ -1014,6 +1037,7 @@ static inline void cancel_all_transfers(struct bladerf_stream *stream)
}
}
}
#endif
}

static inline size_t transfer_idx(struct lusb_stream_data *stream_data,
Expand Down