diff --git a/host/hackrf-tools/src/hackrf_transfer.c b/host/hackrf-tools/src/hackrf_transfer.c index c3680263..ec74b95b 100644 --- a/host/hackrf-tools/src/hackrf_transfer.c +++ b/host/hackrf-tools/src/hackrf_transfer.c @@ -594,9 +594,11 @@ static void tx_complete_callback(hackrf_transfer* transfer, int success) stream_power += sum; } -static void flush_callback(void* flush_ctx) +static void flush_callback(void* flush_ctx, int success) { - flush_complete = true; + if (success) { + flush_complete = true; + } stop_main_loop(); } diff --git a/host/libhackrf/src/hackrf.c b/host/libhackrf/src/hackrf.c index 9dbb338c..0c44b75c 100644 --- a/host/libhackrf/src/hackrf.c +++ b/host/libhackrf/src/hackrf.c @@ -1770,15 +1770,18 @@ static void* transfer_threadproc(void* arg) static void LIBUSB_CALL hackrf_libusb_flush_callback(struct libusb_transfer* usb_transfer) { - // TX buffer is now flushed, so proceed with signalling completion. + bool success = usb_transfer->status == LIBUSB_TRANSFER_COMPLETED; + + // All transfers have now ended, so proceed with signalling completion. hackrf_device* device = (hackrf_device*) usb_transfer->user_data; pthread_mutex_lock(&device->all_finished_lock); device->flush = false; device->active_transfers = 0; pthread_cond_broadcast(&device->all_finished_cv); pthread_mutex_unlock(&device->all_finished_lock); + if (device->flush_callback) - device->flush_callback(device->flush_ctx); + device->flush_callback(device->flush_ctx, success); } static void LIBUSB_CALL diff --git a/host/libhackrf/src/hackrf.h b/host/libhackrf/src/hackrf.h index 73d3bcff..79f140f7 100644 --- a/host/libhackrf/src/hackrf.h +++ b/host/libhackrf/src/hackrf.h @@ -229,7 +229,7 @@ typedef struct hackrf_device_list hackrf_device_list_t; typedef int (*hackrf_sample_block_cb_fn)(hackrf_transfer* transfer); typedef void (*hackrf_tx_block_complete_cb_fn)(hackrf_transfer* transfer, int); -typedef void (*hackrf_flush_cb_fn)(void* flush_ctx); +typedef void (*hackrf_flush_cb_fn)(void* flush_ctx, int); #ifdef __cplusplus extern "C" {