Don't return -1 from the TX callback that provides the last data.

This commit is contained in:
Martin Ling
2022-09-14 15:18:32 +01:00
parent 5ad08cfd96
commit e38534b99d

View File

@ -323,6 +323,7 @@ char* u64toa(uint64_t val, t_u64toa* str)
static volatile bool do_exit = false; static volatile bool do_exit = false;
static volatile bool interrupted = false; static volatile bool interrupted = false;
static volatile bool tx_complete = false;
#ifdef _WIN32 #ifdef _WIN32
static HANDLE interrupt_handle; static HANDLE interrupt_handle;
#endif #endif
@ -496,6 +497,11 @@ int tx_callback(hackrf_transfer* transfer)
byte_count += transfer->valid_length; byte_count += transfer->valid_length;
stream_power += sum; stream_power += sum;
if (tx_complete) {
stop_main_loop();
return -1;
}
bytes_to_read = transfer->buffer_length; bytes_to_read = transfer->buffer_length;
if (limit_num_samples) { if (limit_num_samples) {
if (bytes_to_read >= bytes_to_xfer) { if (bytes_to_read >= bytes_to_xfer) {
@ -515,8 +521,8 @@ int tx_callback(hackrf_transfer* transfer)
transfer->valid_length = bytes_read; transfer->valid_length = bytes_read;
if (limit_num_samples && (bytes_to_xfer == 0)) { if (limit_num_samples && (bytes_to_xfer == 0)) {
stop_main_loop(); tx_complete = true;
return -1; return 0;
} }
if (bytes_read == bytes_to_read) { if (bytes_read == bytes_to_read) {
@ -524,8 +530,8 @@ int tx_callback(hackrf_transfer* transfer)
} }
if (!repeat) { if (!repeat) {
stop_main_loop(); tx_complete = true;
return -1; /* not repeat mode, end of file */ return 0;
} }
while (bytes_read < bytes_to_read) { while (bytes_read < bytes_to_read) {