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

65 lines
2 KiB
C++
Raw Permalink Normal View History

2025-03-09 10:16:40 +01:00
#include "splitter.h"
2026-02-26 10:41:20 +01:00
#include <cstdint>
2025-03-09 10:16:40 +01:00
namespace satdump
{
namespace ndsp
{
template <typename T>
SplitterBlock<T>::SplitterBlock()
2026-01-29 23:10:31 +01:00
: Block(std::is_same_v<T, complex_t> ? "splitter_cc" : "splitter_ff", {{"in", getTypeSampleType<T>()}},
2025-06-06 08:12:02 +02:00
{/*{"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()
{
2025-08-29 15:04:58 +02:00
DSPBuffer iblk = inputs[0].fifo->wait_dequeue();
2025-03-09 10:16:40 +01:00
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)
2025-08-29 15:04:58 +02:00
o.fifo->wait_enqueue(o.fifo->newBufferTerminator());
2025-06-07 15:50:30 +02:00
}
vfos_mtx.unlock();
}
2025-08-29 15:04:58 +02:00
inputs[0].fifo->free(iblk);
2025-03-09 10:16:40 +01:00
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-09-25 17:25:13 +01:00
DSPBuffer oblk = o.fifo->newBufferSamples(iblk.max_size, sizeof(T));
2025-03-09 10:16:40 +01:00
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
2025-08-29 15:04:58 +02:00
inputs[0].fifo->free(iblk);
2025-03-09 10:16:40 +01:00
return false;
}
template class SplitterBlock<complex_t>;
template class SplitterBlock<float>;
2026-02-26 10:41:20 +01:00
template class SplitterBlock<int16_t>;
template class SplitterBlock<int8_t>;
template class SplitterBlock<uint8_t>;
2025-06-06 08:12:02 +02:00
} // namespace ndsp
} // namespace satdump