even more stuff

This commit is contained in:
AlexandreRouma
2022-06-15 16:08:54 +02:00
parent 343ec6ca1c
commit d1318d3a0f
156 changed files with 24826 additions and 0 deletions

View File

@ -0,0 +1,34 @@
#pragma once
#include "../sink.h"
namespace dsp::sink {
template <class T>
class Handler : public Sink<T> {
using base_type = Sink<T>;
public:
Handler() {}
Handler(stream<T>* in, void (*handler)(T* data, int count, void* ctx), void* ctx) { init(in, handler, ctx); }
void init(stream<T>* in, void (*handler)(T* data, int count, void* ctx), void* ctx) {
_handler = handler;
_ctx = ctx;
base_type::init(in);
}
int run() {
int count = base_type::_in->read();
if (count < 0) { return -1; }
_handler(_in->readBuf, count, _ctx);
base_type::_in->flush();
return count;
}
protected:
void (*_handler)(T* data, int count, void* ctx);
void* _ctx;
};
}

View File

@ -0,0 +1,20 @@
#pragma once
#include "../sink.h"
namespace dsp::sink {
template <class T>
class Null : public Sink<T> {
using base_type = Sink<T>;
public:
Null() {}
Null(stream<T>* in, void (*handler)(T* data, int count, void* ctx), void* ctx) { base_type::init(in); }
int run() {
int count = base_type::_in->read();
if (count < 0) { return -1; }
base_type::_in->flush();
return count;
}
};
}