21 #include <SoapySDR/Formats.hpp> 22 #include <SoapySDR/Errors.hpp> 34 m_nbChannels(nbRxChannels),
35 m_decimatorType(DecimatorFloat)
37 qDebug(
"SoapySDRInputThread::SoapySDRInputThread");
43 qDebug(
"SoapySDRInputThread::~SoapySDRInputThread");
89 std::iota(channels.begin(), channels.end(), 0);
92 for (
const auto &it : channels) {
97 double fullScale(0.0);
98 std::string format =
m_dev->getNativeStreamFormat(SOAPY_SDR_RX, channels.front(), fullScale);
100 qDebug(
"SoapySDRInputThread::run: format: %s fullScale: %f", format.c_str(), fullScale);
102 if ((format ==
"CS8") && (fullScale == 128.0)) {
104 }
else if ((format ==
"CS16") && (fullScale == 2048.0)) {
106 }
else if ((format ==
"CS16") && (fullScale == 32768.0)) {
113 unsigned int elemSize = SoapySDR::formatToSize(format);
114 SoapySDR::Stream *stream =
m_dev->setupStream(SOAPY_SDR_RX, format, channels);
117 const unsigned int numElems =
m_dev->getStreamMTU(stream);
118 std::vector<std::vector<char>> buffMem(
m_nbChannels, std::vector<char>(elemSize*numElems));
122 buffs[
i] = buffMem[
i].data();
129 m_dev->activateStream(stream);
133 long initialTtimeoutUs = 10000000 * blockTime;
134 long timeoutUs = initialTtimeoutUs < 250000 ? 250000 : initialTtimeoutUs;
136 qDebug(
"SoapySDRInputThread::run: numElems: %u elemSize: %u initialTtimeoutUs: %ld timeoutUs: %ld",
137 numElems, elemSize, initialTtimeoutUs, timeoutUs);
138 qDebug(
"SoapySDRInputThread::run: start running loop");
142 int ret =
m_dev->readStream(stream, buffs.data(), numElems, flags, timeNs, timeoutUs);
144 if (ret == SOAPY_SDR_TIMEOUT)
146 qWarning(
"SoapySDRInputThread::run: timeout: flags: %d timeNs: %lld timeoutUs: %ld", flags, timeNs, timeoutUs);
148 else if (ret == SOAPY_SDR_OVERFLOW)
150 qWarning(
"SoapySDRInputThread::run: overflow: flags: %d timeNs: %lld timeoutUs: %ld", flags, timeNs, timeoutUs);
154 qCritical(
"SoapySDRInputThread::run: Unexpected read stream error: %s", SoapySDR::errToStr(ret));
158 if (m_nbChannels > 1)
182 qDebug(
"SoapySDRInputThread::run: stop running loop");
183 m_dev->deactivateStream(stream);
184 m_dev->closeStream(stream);
188 qWarning(
"SoapySDRInputThread::run: no channels or FIFO allocated. Aborting");
196 unsigned int fifoCount = 0;
258 for(
unsigned int ichan = 0; ichan <
m_nbChannels; ichan++)
263 callbackSI8((
const qint8*) buffs[ichan], samplesPerChannel, ichan);
266 callbackSI12((
const qint16*) buffs[ichan], samplesPerChannel, ichan);
269 callbackSI16((
const qint16*) buffs[ichan], samplesPerChannel, ichan);
273 callbackSIF((
const float*) buffs[ichan], samplesPerChannel, ichan);
void decimate32_inf(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate8_inf(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate8_sup(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate2_inf(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate4_inf(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate64_sup(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate32_cen(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate32_sup(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate64_cen(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate2_sup(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate2_cen(SampleVector::iterator *it, const T *buf, qint32 len)
uint write(const quint8 *data, uint count)
void decimate8_sup(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate4_sup(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate64_inf(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate64_sup(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate32_inf(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate32_sup(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate4_sup(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate8_cen(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate16_cen(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate8_inf(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate16_sup(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate2_inf(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate2_cen(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate4_cen(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate4_cen(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate4_inf(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate2_sup(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate8_cen(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate16_sup(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate16_inf(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate64_cen(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate64_inf(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate16_cen(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate32_cen(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate1(SampleVector::iterator *it, const T *buf, qint32 len)
void decimate1(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate16_inf(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)