mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-07-15 05:23:30 +02:00
even more stuff
This commit is contained in:
34
core/src/dsp/sink/handler_sink.h
Normal file
34
core/src/dsp/sink/handler_sink.h
Normal 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;
|
||||
|
||||
};
|
||||
}
|
20
core/src/dsp/sink/null_sink.h
Normal file
20
core/src/dsp/sink/null_sink.h
Normal 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;
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user