Skip to content

Commit

Permalink
Merge pull request #2 from libusb/master
Browse files Browse the repository at this point in the history
macOS: Error reporting/hid_error implementation (libusb#314)
  • Loading branch information
fengjixuchui authored Oct 14, 2022
2 parents 4301149 + f2e2b5b commit 6f8a43b
Show file tree
Hide file tree
Showing 2 changed files with 224 additions and 74 deletions.
9 changes: 7 additions & 2 deletions libusb/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ static void read_callback(struct libusb_transfer *transfer)

static void *read_thread(void *param)
{
int res;
hid_device *dev = param;
uint8_t *buf;
const size_t length = dev->input_ep_max_packet_size;
Expand All @@ -985,14 +986,18 @@ static void *read_thread(void *param)

/* Make the first submission. Further submissions are made
from inside read_callback() */
libusb_submit_transfer(dev->transfer);
res = libusb_submit_transfer(dev->transfer);
if(res < 0) {
LOG("libusb_submit_transfer failed: %d %s. Stopping read_thread from running\n", res, libusb_error_name(res));
dev->shutdown_thread = 1;
dev->transfer_loop_finished = 1;
}

/* Notify the main thread that the read thread is up and running. */
pthread_barrier_wait(&dev->barrier);

/* Handle all the events. */
while (!dev->shutdown_thread) {
int res;
res = libusb_handle_events(usb_context);
if (res < 0) {
/* There was an error. */
Expand Down
Loading

0 comments on commit 6f8a43b

Please sign in to comment.