Indicate success or failure to flush callback.

This commit is contained in:
Martin Ling
2022-09-22 12:54:23 +01:00
committed by Michael Ossmann
parent 4810d1f992
commit 0becbc6b4a
3 changed files with 10 additions and 5 deletions

View File

@ -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)
{
if (success) {
flush_complete = true;
}
stop_main_loop();
}

View File

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

View File

@ -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" {