From 2e73a4f2dbfcd1de07613124f7d2ea68fd8a7f97 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Fri, 23 Sep 2022 12:46:49 +0100 Subject: [PATCH] If TX callback sets valid_length to 0, treat as end of data. --- host/libhackrf/src/hackrf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/host/libhackrf/src/hackrf.c b/host/libhackrf/src/hackrf.c index 0c44b75c..46385ebf 100644 --- a/host/libhackrf/src/hackrf.c +++ b/host/libhackrf/src/hackrf.c @@ -367,7 +367,8 @@ static int prepare_transfers( .rx_ctx = device->rx_ctx, .tx_ctx = device->tx_ctx, }; - if (device->callback(&transfer) == 0) { + if ((device->callback(&transfer) == 0) && + (transfer.valid_length > 0)) { device->transfers[transfer_index]->length = transfer.valid_length; ready_transfers++; @@ -1810,7 +1811,8 @@ hackrf_libusb_transfer_callback(struct libusb_transfer* usb_transfer) // of stopping them. pthread_mutex_lock(&device->transfer_lock); if (success) { - if (device->streaming && device->callback(&transfer) == 0) { + if (device->streaming && (device->callback(&transfer) == 0) && + (transfer.valid_length > 0)) { if ((resubmit = device->transfers_setup)) { if (usb_transfer->endpoint == TX_ENDPOINT_ADDRESS) { usb_transfer->length = transfer.valid_length;