mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2026-04-19 23:02:43 +00:00
attemt at a CI build with new DSP
This commit is contained in:
44
core/src/dsp/routing/stream_link.h
Normal file
44
core/src/dsp/routing/stream_link.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
#include "../sink.h"
|
||||
|
||||
namespace dsp::routing {
|
||||
template <class T>
|
||||
class StreamLink : public Sink<T> {
|
||||
using base_type = Sink<T>;
|
||||
public:
|
||||
StreamLink() {}
|
||||
|
||||
StreamLink(stream<T>* in, stream<T>* out) { init(in, out); }
|
||||
|
||||
void init(stream<T>* in, stream<T>* out) {
|
||||
_out = out;
|
||||
base_type::registerOutput(_out);
|
||||
base_type::init(in);
|
||||
}
|
||||
|
||||
void setOutput(stream<T>* out) {
|
||||
assert(base_type::_block_init);
|
||||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx);
|
||||
base_type::tempStop();
|
||||
base_type::unregisterOutput(_out);
|
||||
_out = out;
|
||||
base_type::registerOutput(_out);
|
||||
base_type::tempStart();
|
||||
}
|
||||
|
||||
int run() {
|
||||
int count = _in->read();
|
||||
if (count < 0) { return -1; }
|
||||
|
||||
memcpy(_out->writeBuf, _in->readBuf, count * sizeof(T));
|
||||
|
||||
_in->flush();
|
||||
if (!_out->swap(count)) { return -1; }
|
||||
return count;
|
||||
}
|
||||
|
||||
protected:
|
||||
stream<T>* _out;
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user