mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-25 12:07:49 +02:00
Fixed file source and cleaned up buffering code
This commit is contained in:
@ -224,14 +224,6 @@ namespace dsp {
|
||||
|
||||
SampleFrameBuffer(stream<T>* in) { init(in); }
|
||||
|
||||
~SampleFrameBuffer() {
|
||||
generic_block<SampleFrameBuffer<T>>::stop();
|
||||
out.stopWriter();
|
||||
stopWorker = true;
|
||||
cnd.notify_all();
|
||||
if (readWorkerThread.joinable()) { readWorkerThread.join(); }
|
||||
}
|
||||
|
||||
void init(stream<T>* in) {
|
||||
_in = in;
|
||||
|
||||
@ -241,8 +233,6 @@ namespace dsp {
|
||||
|
||||
generic_block<SampleFrameBuffer<T>>::registerInput(in);
|
||||
generic_block<SampleFrameBuffer<T>>::registerOutput(&out);
|
||||
|
||||
readWorkerThread = std::thread(&SampleFrameBuffer::worker, this);
|
||||
}
|
||||
|
||||
void setInput(stream<T>* in) {
|
||||
@ -275,9 +265,9 @@ namespace dsp {
|
||||
writeCur++;
|
||||
writeCur = ((writeCur) % TEST_BUFFER_SIZE);
|
||||
|
||||
if (((writeCur - readCur + TEST_BUFFER_SIZE) % TEST_BUFFER_SIZE) >= (TEST_BUFFER_SIZE-2)) {
|
||||
spdlog::warn("Overflow");
|
||||
}
|
||||
// if (((writeCur - readCur + TEST_BUFFER_SIZE) % TEST_BUFFER_SIZE) >= (TEST_BUFFER_SIZE-2)) {
|
||||
// spdlog::warn("Overflow");
|
||||
// }
|
||||
}
|
||||
cnd.notify_all();
|
||||
_in->flush();
|
||||
@ -311,6 +301,25 @@ namespace dsp {
|
||||
bool bypass = false;
|
||||
|
||||
private:
|
||||
void doStart() {
|
||||
generic_block<SampleFrameBuffer<T>>::workerThread = std::thread(&generic_block<SampleFrameBuffer<T>>::workerLoop, this);
|
||||
readWorkerThread = std::thread(&SampleFrameBuffer<T>::worker, this);
|
||||
}
|
||||
|
||||
void doStop() {
|
||||
_in->stopReader();
|
||||
out.stopWriter();
|
||||
stopWorker = true;
|
||||
cnd.notify_all();
|
||||
|
||||
if (generic_block<SampleFrameBuffer<T>>::workerThread.joinable()) { generic_block<SampleFrameBuffer<T>>::workerThread.join(); }
|
||||
if (readWorkerThread.joinable()) { readWorkerThread.join(); }
|
||||
|
||||
_in->clearReadStop();
|
||||
out.clearWriteStop();
|
||||
stopWorker = false;
|
||||
}
|
||||
|
||||
stream<T>* _in;
|
||||
|
||||
std::thread readWorkerThread;
|
||||
|
@ -461,7 +461,7 @@ void MainWindow::draw() {
|
||||
|
||||
ImGui::Checkbox("Bypass buffering", &sigpath::signalPath.inputBuffer.bypass);
|
||||
|
||||
ImGui::Text("Buffering: %d", (sigpath::signalPath.inputBuffer.writeCur - sigpath::signalPath.inputBuffer.readCur + 20) % 20);
|
||||
ImGui::Text("Buffering: %d", (sigpath::signalPath.inputBuffer.writeCur - sigpath::signalPath.inputBuffer.readCur + 32) % 32);
|
||||
|
||||
if (ImGui::Button("Test Bug")) {
|
||||
spdlog::error("Will this make the software crash?");
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <gui/menus/theme.h>
|
||||
#include <gui/gui.h>
|
||||
#include <options.h>
|
||||
#include <core.h>>
|
||||
#include <core.h>
|
||||
|
||||
namespace thememenu {
|
||||
int themeId;
|
||||
|
@ -116,4 +116,8 @@ void SignalPath::startFFT() {
|
||||
void SignalPath::stopFFT() {
|
||||
reshape.stop();
|
||||
fftHandlerSink.stop();
|
||||
}
|
||||
|
||||
void SignalPath::setBuffering(bool enabled) {
|
||||
inputBuffer.bypass = !enabled;
|
||||
}
|
@ -20,6 +20,7 @@ public:
|
||||
void setFFTSize(int size);
|
||||
void startFFT();
|
||||
void stopFFT();
|
||||
void setBuffering(bool enabled);
|
||||
|
||||
dsp::SampleFrameBuffer<dsp::complex_t> inputBuffer;
|
||||
|
||||
@ -43,4 +44,5 @@ private:
|
||||
double fftRate;
|
||||
int fftSize;
|
||||
int inputBlockSize;
|
||||
bool bufferingEnabled = false;
|
||||
};
|
Reference in New Issue
Block a user