diff --git a/host/libraries/libbladeRF/src/streaming/async.c b/host/libraries/libbladeRF/src/streaming/async.c index d26c2056..b712f06d 100644 --- a/host/libraries/libbladeRF/src/streaming/async.c +++ b/host/libraries/libbladeRF/src/streaming/async.c @@ -143,6 +143,26 @@ int async_init_stream(struct bladerf_stream **stream, return status; } +int async_set_transfer_timeout(struct bladerf_stream *stream, + unsigned int transfer_timeout_ms) +{ + MUTEX_LOCK(&stream->lock); + stream->transfer_timeout = transfer_timeout_ms; + MUTEX_UNLOCK(&stream->lock); + + return 0; +} + +int async_get_transfer_timeout(struct bladerf_stream *stream, + unsigned int *transfer_timeout_ms) +{ + MUTEX_LOCK(&stream->lock); + *transfer_timeout_ms = stream->transfer_timeout; + MUTEX_UNLOCK(&stream->lock); + + return 0; +} + int async_run_stream(struct bladerf_stream *stream, bladerf_channel_layout layout) { int status; diff --git a/host/libraries/libbladeRF/src/streaming/async.h b/host/libraries/libbladeRF/src/streaming/async.h index ace5573d..2f75189e 100644 --- a/host/libraries/libbladeRF/src/streaming/async.h +++ b/host/libraries/libbladeRF/src/streaming/async.h @@ -79,6 +79,14 @@ int async_init_stream(struct bladerf_stream **stream, size_t num_transfers, void *user_data); +/* Set the transfer timeout. This acquires stream->lock. */ +int async_set_transfer_timeout(struct bladerf_stream *stream, + unsigned int transfer_timeout_ms); + +/* Get the transfer timeout. This acquires stream->lock. */ +int async_get_transfer_timeout(struct bladerf_stream *stream, + unsigned int *transfer_timeout_ms); + /* Backend code is responsible for acquiring stream->lock in their callbacks */ int async_run_stream(struct bladerf_stream *stream, bladerf_channel_layout layout); diff --git a/host/libraries/libbladeRF/src/streaming/sync_worker.c b/host/libraries/libbladeRF/src/streaming/sync_worker.c index 045df82a..ddd286c1 100644 --- a/host/libraries/libbladeRF/src/streaming/sync_worker.c +++ b/host/libraries/libbladeRF/src/streaming/sync_worker.c @@ -30,12 +30,14 @@ #endif #include "rel_assert.h" #include "conversions.h" +#include "minmax.h" #include "async.h" #include "sync.h" #include "sync_worker.h" #include "board/board.h" +#include "backend/usb/usb.h" #define worker2str(s) (direction2str(s->stream_config.layout & BLADERF_DIRECTION_MASK)) @@ -213,6 +215,14 @@ int sync_worker_init(struct bladerf_sync *s) goto worker_init_out; } + status = async_set_transfer_timeout( + s->worker->stream, + uint_max(s->stream_config.timeout_ms, BULK_TIMEOUT_MS)); + if (status != 0) { + log_debug("%s worker: Failed to set transfer timeout: %s\n", + worker2str(s), bladerf_strerror(status)); + goto worker_init_out; + } MUTEX_INIT(&s->worker->state_lock); MUTEX_INIT(&s->worker->request_lock);