attemt at a CI build with new DSP

This commit is contained in:
AlexandreRouma
2022-06-17 17:34:23 +02:00
parent d1318d3a0f
commit 36adc102ee
38 changed files with 259 additions and 92 deletions

View 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;
};
}