satdump/src-core/dsp/path/splitter.cpp

62 lines
1.9 KiB
C++
Raw Permalink Normal View History

2025-03-09 10:16:40 +01:00
#include "splitter.h"
namespace satdump
{
namespace ndsp
{
template <typename T>
SplitterBlock<T>::SplitterBlock()
2025-06-06 08:12:02 +02:00
: Block(std::is_same_v<T, complex_t> ? "splitter_cc" : "splitter_ff", {{"in", std::is_same_v<T, complex_t> ? DSP_SAMPLE_TYPE_CF32 : DSP_SAMPLE_TYPE_F32}},
{/*{"out", std::is_same_v<T, complex_t> ? DSP_SAMPLE_TYPE_CF32 : DSP_SAMPLE_TYPE_F32}*/})
2025-03-09 10:16:40 +01:00
{
}
template <typename T>
SplitterBlock<T>::~SplitterBlock()
{
}
template <typename T>
bool SplitterBlock<T>::work()
{
DSPBuffer iblk;
inputs[0].fifo->wait_dequeue(iblk);
if (iblk.isTerminator())
{
if (iblk.terminatorShouldPropagate())
2025-06-07 15:50:30 +02:00
{
vfos_mtx.lock();
2025-03-09 10:16:40 +01:00
for (auto &o : outputs)
2025-06-07 15:50:30 +02:00
{
IOInfo *i = ((IOInfo *)o.blkdata.get());
if (i->forward_terminator)
o.fifo->wait_enqueue(DSPBuffer::newBufferTerminator());
}
vfos_mtx.unlock();
}
2025-03-09 10:16:40 +01:00
iblk.free();
return true;
}
2025-06-06 08:12:02 +02:00
vfos_mtx.lock();
2025-03-09 10:16:40 +01:00
for (auto &o : outputs)
{
2025-06-07 15:50:30 +02:00
IOInfo *i = ((IOInfo *)o.blkdata.get());
2025-03-09 10:16:40 +01:00
DSPBuffer oblk = DSPBuffer::newBufferSamples<T>(iblk.max_size);
memcpy(oblk.getSamples<T>(), iblk.getSamples<T>(), iblk.size * sizeof(T));
oblk.size = iblk.size;
o.fifo->wait_enqueue(oblk);
}
2025-06-06 08:12:02 +02:00
vfos_mtx.unlock();
2025-03-09 10:16:40 +01:00
iblk.free();
return false;
}
template class SplitterBlock<complex_t>;
template class SplitterBlock<float>;
2025-06-06 08:12:02 +02:00
} // namespace ndsp
} // namespace satdump