DSP performance upgrades + bugfix

This commit is contained in:
Ryzerth
2021-03-29 21:53:43 +02:00
parent b72246d769
commit 27394a091f
29 changed files with 942 additions and 355 deletions

View File

@@ -10,8 +10,6 @@ namespace dsp {
HandlerSink(stream<T>* in, void (*handler)(T* data, int count, void* ctx), void* ctx) { init(in, handler, ctx); }
~HandlerSink() { generic_block<HandlerSink<T>>::stop(); }
void init(stream<T>* in, void (*handler)(T* data, int count, void* ctx), void* ctx) {
_in = in;
_handler = handler;
@@ -37,7 +35,7 @@ namespace dsp {
}
int run() {
count = _in->read();
int count = _in->read();
if (count < 0) { return -1; }
_handler(_in->readBuf, count, _ctx);
_in->flush();
@@ -45,7 +43,6 @@ namespace dsp {
}
private:
int count;
stream<T>* _in;
void (*_handler)(T* data, int count, void* ctx);
void* _ctx;
@@ -59,8 +56,6 @@ namespace dsp {
RingBufferSink(stream<T>* in) { init(in); }
~RingBufferSink() { generic_block<RingBufferSink<T>>::stop(); }
void init(stream<T>* in) {
_in = in;
data.init(480); // TODO: Use an argument
@@ -77,7 +72,7 @@ namespace dsp {
}
int run() {
count = _in->read();
int count = _in->read();
if (count < 0) { return -1; }
if (data.write(_in->readBuf, count) < 0) { return -1; }
_in->flush();
@@ -97,7 +92,6 @@ namespace dsp {
data.clearWriteStop();
}
int count;
stream<T>* _in;
};
@@ -126,14 +120,13 @@ namespace dsp {
}
int run() {
count = _in->read();
int count = _in->read();
if (count < 0) { return -1; }
_in->flush();
return count;
}
private:
int count;
stream<T>* _in;
};