satdump/src-core/dsp/io/iq_source.cpp

39 lines
1.2 KiB
C++
Raw Permalink Normal View History

2026-01-16 18:16:43 +01:00
#include "iq_source.h"
2025-03-09 10:16:40 +01:00
namespace satdump
{
namespace ndsp
{
2026-01-16 18:16:43 +01:00
IQSourceBlock::IQSourceBlock() : Block("iq_source_cc", {}, {{"out", DSP_SAMPLE_TYPE_CF32}}) {}
2025-03-09 10:16:40 +01:00
2026-01-16 18:16:43 +01:00
IQSourceBlock::~IQSourceBlock() {}
2025-03-09 10:16:40 +01:00
2026-01-16 18:16:43 +01:00
bool IQSourceBlock::work()
2025-03-09 10:16:40 +01:00
{
2026-03-13 07:54:12 +01:00
if (!d_eof && !baseband_reader.is_eof() && !work_should_exit)
2025-03-09 10:16:40 +01:00
{
2025-09-25 17:25:13 +01:00
auto oblk = outputs[0].fifo->newBufferSamples(d_buffer_size, sizeof(complex_t));
2025-03-09 10:16:40 +01:00
complex_t *obuf = oblk.getSamples<complex_t>();
int read = baseband_reader.read_samples(obuf, d_buffer_size);
if (d_iq_swap)
for (int i = 0; i < read; i++)
obuf[i] = complex_t(obuf[i].imag, obuf[i].real);
oblk.size = read;
outputs[0].fifo->wait_enqueue(oblk);
d_progress = baseband_reader.progress;
}
else
{
d_eof = true;
2025-08-29 15:04:58 +02:00
outputs[0].fifo->wait_enqueue(outputs[0].fifo->newBufferTerminator());
2025-03-09 10:16:40 +01:00
return true;
}
return false;
}
2025-08-29 15:04:58 +02:00
} // namespace ndsp
} // namespace satdump