Merge pull request #1070 from martinling/cleanup-stop
Remove unnecessary delays on stop, and duplicated stop commands on close.
This commit is contained in:
@ -1884,16 +1884,10 @@ int ADDCALL hackrf_start_rx(hackrf_device* device, hackrf_sample_block_cb_fn cal
|
||||
return result;
|
||||
}
|
||||
|
||||
static int hackrf_stop_rx_cmd(hackrf_device* device)
|
||||
static int hackrf_stop_cmd(hackrf_device* device)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = hackrf_set_transceiver_mode(device, HACKRF_TRANSCEIVER_MODE_OFF);
|
||||
#ifdef _WIN32
|
||||
Sleep(10);
|
||||
#else
|
||||
usleep(10 * 1000);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1915,7 +1909,7 @@ int ADDCALL hackrf_stop_rx(hackrf_device* device)
|
||||
return result;
|
||||
}
|
||||
|
||||
return hackrf_stop_rx_cmd(device);
|
||||
return hackrf_stop_cmd(device);
|
||||
}
|
||||
|
||||
int ADDCALL hackrf_start_tx(hackrf_device* device, hackrf_sample_block_cb_fn callback, void* tx_ctx)
|
||||
@ -1931,18 +1925,6 @@ int ADDCALL hackrf_start_tx(hackrf_device* device, hackrf_sample_block_cb_fn cal
|
||||
return result;
|
||||
}
|
||||
|
||||
static int hackrf_stop_tx_cmd(hackrf_device* device)
|
||||
{
|
||||
int result;
|
||||
result = hackrf_set_transceiver_mode(device, HACKRF_TRANSCEIVER_MODE_OFF);
|
||||
#ifdef _WIN32
|
||||
Sleep(10);
|
||||
#else
|
||||
usleep(10 * 1000);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop any pending transmit.
|
||||
*
|
||||
@ -1960,27 +1942,25 @@ int ADDCALL hackrf_stop_tx(hackrf_device* device)
|
||||
return result;
|
||||
}
|
||||
|
||||
return hackrf_stop_tx_cmd(device);
|
||||
return hackrf_stop_cmd(device);
|
||||
}
|
||||
|
||||
int ADDCALL hackrf_close(hackrf_device* device)
|
||||
{
|
||||
int result1, result2, result3;
|
||||
int result1, result2;
|
||||
|
||||
result1 = HACKRF_SUCCESS;
|
||||
result2 = HACKRF_SUCCESS;
|
||||
result3 = HACKRF_SUCCESS;
|
||||
|
||||
if( device != NULL )
|
||||
{
|
||||
result1 = hackrf_stop_rx_cmd(device);
|
||||
result2 = hackrf_stop_tx_cmd(device);
|
||||
result1 = hackrf_stop_cmd(device);
|
||||
|
||||
/*
|
||||
* Finally kill the transfer thread, which will
|
||||
* also cancel any pending transmit/receive transfers.
|
||||
*/
|
||||
result3 = kill_transfer_thread(device);
|
||||
result2 = kill_transfer_thread(device);
|
||||
if( device->usb_device != NULL )
|
||||
{
|
||||
libusb_release_interface(device->usb_device, 0);
|
||||
@ -1998,10 +1978,6 @@ int ADDCALL hackrf_close(hackrf_device* device)
|
||||
}
|
||||
open_devices--;
|
||||
|
||||
if (result3 != HACKRF_SUCCESS)
|
||||
{
|
||||
return result3;
|
||||
}
|
||||
if (result2 != HACKRF_SUCCESS)
|
||||
{
|
||||
return result2;
|
||||
|
Reference in New Issue
Block a user