Open device counting: increment when opening a device

Previously it incremented when the library was initialised, this worked
for GNU Radio flowgraphs, but broke elsewhere
This commit is contained in:
Dominic Spill
2018-02-27 16:07:04 -07:00
parent fc8fcd8616
commit 65c7b5aa24

View File

@ -348,7 +348,6 @@ extern "C"
int ADDCALL hackrf_init(void) int ADDCALL hackrf_init(void)
{ {
int libusb_error; int libusb_error;
open_devices++;
if (g_libusb_context != NULL) { if (g_libusb_context != NULL) {
return HACKRF_SUCCESS; return HACKRF_SUCCESS;
} }
@ -357,7 +356,6 @@ int ADDCALL hackrf_init(void)
if( libusb_error != 0 ) if( libusb_error != 0 )
{ {
last_libusb_error = libusb_error; last_libusb_error = libusb_error;
open_devices--;
return HACKRF_ERROR_LIBUSB; return HACKRF_ERROR_LIBUSB;
} else { } else {
return HACKRF_SUCCESS; return HACKRF_SUCCESS;
@ -582,6 +580,7 @@ static int hackrf_open_setup(libusb_device_handle* usb_device, hackrf_device** d
} }
*device = lib_device; *device = lib_device;
open_devices++;
return HACKRF_SUCCESS; return HACKRF_SUCCESS;
} }