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

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

2025-03-09 10:16:40 +01:00
#include "file_source.h"
namespace satdump
{
namespace ndsp
{
2025-08-29 15:04:58 +02:00
FileSourceBlock::FileSourceBlock() : Block("file_source_cc", {}, {{"out", DSP_SAMPLE_TYPE_CF32}}) {}
2025-03-09 10:16:40 +01:00
2025-08-29 15:04:58 +02:00
FileSourceBlock::~FileSourceBlock() {}
2025-03-09 10:16:40 +01:00
bool FileSourceBlock::work()
{
2025-03-10 20:05:31 +01:00
if (!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