From 6c05c11a62b42bda0909865028317e3951bc7d3a Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Mon, 26 Jul 2021 21:30:49 +0200 Subject: [PATCH] potential fix for stall --- core/src/dsp/decimation.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/dsp/decimation.h b/core/src/dsp/decimation.h index 5cdf4abe..3811b906 100644 --- a/core/src/dsp/decimation.h +++ b/core/src/dsp/decimation.h @@ -47,6 +47,7 @@ namespace dsp { void updateWindow(dsp::filter_window::generic_window* window) { assert(generic_block>::_block_init); std::lock_guard lck(generic_block>::ctrlMtx); + std::lock_guard lck2(bufMtx); _window = window; volk_free(taps); tapCount = window->getTapCount(); @@ -59,7 +60,7 @@ namespace dsp { int count = _in->read(); if (count < 0) { return -1; } - generic_block>::ctrlMtx.lock(); + bufMtx.lock(); memcpy(bufStart, _in->readBuf, count * sizeof(T)); _in->flush(); @@ -82,11 +83,13 @@ namespace dsp { } _inIndex = inIndex - count; - if (!out.swap(outIndex)) { return -1; } + if (!out.swap(outIndex)) { + bufMtx.unlock(); + return -1; + } memmove(buffer, &buffer[count], tapCount * sizeof(T)); - - generic_block>::ctrlMtx.unlock(); + return count; } @@ -97,6 +100,7 @@ namespace dsp { stream* _in; dsp::filter_window::generic_window* _window; + std::mutex bufMtx; T* bufStart; T* buffer;