From df4991bc19dc9961b5edc4665151cdbced450d52 Mon Sep 17 00:00:00 2001 From: Dimitri Stolnikov Date: Fri, 6 Apr 2012 13:47:45 +0200 Subject: [PATCH] do not use NULL usb contexts to make libusb-pbatard work on windows --- src/rtl-sdr.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rtl-sdr.c b/src/rtl-sdr.c index 55ccc0b..1a65d00 100644 --- a/src/rtl-sdr.c +++ b/src/rtl-sdr.c @@ -559,14 +559,15 @@ rtlsdr_device_t *find_known_device(uint16_t vid, uint16_t pid) uint32_t rtlsdr_get_device_count(void) { int i; + libusb_context *ctx; libusb_device **list; uint32_t device_count = 0; struct libusb_device_descriptor dd; ssize_t cnt; - libusb_init(NULL); + libusb_init(&ctx); - cnt = libusb_get_device_list(NULL, &list); + cnt = libusb_get_device_list(ctx, &list); for (i = 0; i < cnt; i++) { libusb_get_device_descriptor(list[i], &dd); @@ -577,7 +578,7 @@ uint32_t rtlsdr_get_device_count(void) libusb_free_device_list(list, 0); - libusb_exit(NULL); + libusb_exit(ctx); return device_count; } @@ -585,15 +586,16 @@ uint32_t rtlsdr_get_device_count(void) const char *rtlsdr_get_device_name(uint32_t index) { int i; + libusb_context *ctx; libusb_device **list; struct libusb_device_descriptor dd; rtlsdr_device_t *device = NULL; uint32_t device_count = 0; ssize_t cnt; - libusb_init(NULL); + libusb_init(&ctx); - cnt = libusb_get_device_list(NULL, &list); + cnt = libusb_get_device_list(ctx, &list); for (i = 0; i < cnt; i++) { libusb_get_device_descriptor(list[i], &dd); @@ -610,7 +612,7 @@ const char *rtlsdr_get_device_name(uint32_t index) libusb_free_device_list(list, 0); - libusb_exit(NULL); + libusb_exit(ctx); if (device) return device->name;