|
|
|
@ -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; |
|
|
|
|