| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2019-04-11 06:57:41 +02:00
										 |  |  | // Copyright (C) 2017, 2018 Edouard Griffiths, F4EXB                             //
 | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | // Copyright (C) 2017 Sergey Kostanbaev, Fairwaves Inc.                          //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is free software; you can redistribute it and/or modify          //
 | 
					
						
							|  |  |  | // it under the terms of the GNU General Public License as published by          //
 | 
					
						
							|  |  |  | // the Free Software Foundation as version 3 of the License, or                  //
 | 
					
						
							| 
									
										
										
										
											2019-04-11 06:57:41 +02:00
										 |  |  | // (at your option) any later version.                                           //
 | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful,               //
 | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | 
					
						
							|  |  |  | // GNU General Public License V3 for more details.                               //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU General Public License             //
 | 
					
						
							|  |  |  | // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <errno.h>
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  | #include <chrono>
 | 
					
						
							|  |  |  | #include <thread>
 | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  | #include "xtrx/devicextrx.h"
 | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | #include "xtrxinputsettings.h"
 | 
					
						
							|  |  |  | #include "xtrxinputthread.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  | XTRXInputThread::XTRXInputThread(struct xtrx_dev *dev, unsigned int nbChannels, unsigned int uniqueChannelIndex, QObject* parent) : | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  |     QThread(parent), | 
					
						
							|  |  |  |     m_running(false), | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |     m_dev(dev), | 
					
						
							|  |  |  |     m_nbChannels(nbChannels), | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  |     m_uniqueChannelIndex(uniqueChannelIndex), | 
					
						
							|  |  |  |     m_iqOrder(true) | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-12-31 10:43:11 +01:00
										 |  |  |     qDebug("XTRXInputThread::XTRXInputThread: nbChannels: %u uniqueChannelIndex: %u", nbChannels, uniqueChannelIndex); | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |     m_channels = new Channel[2]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (unsigned int i = 0; i < 2; i++) { | 
					
						
							|  |  |  |         m_channels[i].m_convertBuffer.resize(DeviceXTRX::blockSize, Sample{0,0}); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | XTRXInputThread::~XTRXInputThread() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |     qDebug("XTRXInputThread::~XTRXInputThread"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_running) { | 
					
						
							|  |  |  |         stopWork(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     delete[] m_channels; | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void XTRXInputThread::startWork() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  |     if (m_running) { | 
					
						
							|  |  |  |         return; // return if running already
 | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_startWaitMutex.lock(); | 
					
						
							|  |  |  |     start(); | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     while (!m_running) { | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  |         m_startWaiter.wait(&m_startWaitMutex, 100); | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  |     m_startWaitMutex.unlock(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void XTRXInputThread::stopWork() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  |     if (!m_running) { | 
					
						
							|  |  |  |         return; // return if not running
 | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_running = false; | 
					
						
							|  |  |  |     wait(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void XTRXInputThread::run() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int res; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_running = true; | 
					
						
							|  |  |  |     m_startWaiter.wakeAll(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |     unsigned int nbFifos = getNbFifos(); | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 10:43:11 +01:00
										 |  |  |     if ((m_nbChannels != 0) && (nbFifos != 0)) | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         xtrx_run_params params; | 
					
						
							|  |  |  |         xtrx_run_params_init(¶ms); | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |         params.dir = XTRX_RX; | 
					
						
							|  |  |  |         params.rx.chs = XTRX_CH_AB; | 
					
						
							|  |  |  |         params.rx.wfmt = XTRX_WF_16; | 
					
						
							|  |  |  |         params.rx.hfmt = XTRX_IQ_INT16; | 
					
						
							| 
									
										
										
										
											2018-12-31 20:22:42 +01:00
										 |  |  |         params.rx_stream_start = 2*DeviceXTRX::blockSize; // was 2*8192
 | 
					
						
							| 
									
										
										
										
											2019-01-03 13:08:11 +01:00
										 |  |  |         params.rx.paketsize = 2*DeviceXTRX::blockSize; | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |         if (m_nbChannels == 1) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-12-31 10:43:11 +01:00
										 |  |  |             qDebug("XTRXInputThread::run: SI mode for channel #%u", m_uniqueChannelIndex); | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |             params.rx.flags |= XTRX_RSP_SISO_MODE; | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |             if (m_uniqueChannelIndex == 1) { | 
					
						
							|  |  |  |                 params.rx.flags |= XTRX_RSP_SWAP_AB; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         res = xtrx_run_ex(m_dev, ¶ms); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (res != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             qCritical("XTRXInputThread::run: could not start stream err:%d", res); | 
					
						
							|  |  |  |             m_running = false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-12-31 10:43:11 +01:00
										 |  |  |             std::this_thread::sleep_for(std::chrono::milliseconds(50)); | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |             qDebug("XTRXInputThread::run: stream started"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 20:22:42 +01:00
										 |  |  |         const unsigned int elemSize = 4; // XTRX uses 4 byte I+Q samples
 | 
					
						
							|  |  |  |         std::vector<std::vector<char>> buffMem(m_nbChannels, std::vector<char>(elemSize*DeviceXTRX::blockSize)); | 
					
						
							|  |  |  |         std::vector<void *> buffs(m_nbChannels); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (std::size_t i = 0; i < m_nbChannels; i++) { | 
					
						
							|  |  |  |             buffs[i] = buffMem[i].data(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |         xtrx_recv_ex_info_t nfo; | 
					
						
							|  |  |  |         nfo.samples = DeviceXTRX::blockSize; | 
					
						
							| 
									
										
										
										
											2018-12-31 20:22:42 +01:00
										 |  |  |         nfo.buffer_count = m_nbChannels; | 
					
						
							|  |  |  |         nfo.buffers = (void* const*) buffs.data(); | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |         nfo.flags = RCVEX_DONT_INSER_ZEROS | RCVEX_DROP_OLD_ON_OVERFLOW; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         while (m_running) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             res = xtrx_recv_sync_ex(m_dev, &nfo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (res < 0) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 qCritical("XTRXInputThread::run read error: %d", res); | 
					
						
							| 
									
										
										
										
											2018-12-31 10:43:11 +01:00
										 |  |  |                 qDebug("XTRXInputThread::run: out_samples: %u out_events: %u", nfo.out_samples, nfo.out_events); | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |                 break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-03 13:08:11 +01:00
										 |  |  |             if (nfo.out_events & RCVEX_EVENT_OVERFLOW) { | 
					
						
							|  |  |  |                 qDebug("XTRXInputThread::run: overflow"); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  |             if (m_nbChannels > 1) | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2018-12-31 20:22:42 +01:00
										 |  |  |                 callbackMI((const qint16*) buffs[0], (const qint16*) buffs[1], 2 * nfo.out_samples); | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 if (m_iqOrder) { | 
					
						
							|  |  |  |                     callbackSIIQ((const qint16*) buffs[0], 2 * nfo.out_samples); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     callbackSIQI((const qint16*) buffs[0], 2 * nfo.out_samples); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         res = xtrx_stop(m_dev, XTRX_RX); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (res != 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             qCritical("XTRXInputThread::run: could not stop stream"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-12-31 10:43:11 +01:00
										 |  |  |             std::this_thread::sleep_for(std::chrono::milliseconds(50)); | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |             qDebug("XTRXInputThread::run: stream stopped"); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |         qWarning("XTRXInputThread::run: no channels or FIFO allocated. Aborting"); | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |     m_running = false; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  | unsigned int XTRXInputThread::getNbFifos() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     unsigned int fifoCount = 0; | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 10:43:11 +01:00
										 |  |  |     for (unsigned int i = 0; i < 2; i++) | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |         if (m_channels[i].m_sampleFifo) { | 
					
						
							|  |  |  |             fifoCount++; | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |     return fifoCount; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  | void XTRXInputThread::setLog2Decimation(unsigned int channel, unsigned int log2_decim) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-12-31 10:43:11 +01:00
										 |  |  |     if (channel < 2) { | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |         m_channels[channel].m_log2Decim = log2_decim; | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | unsigned int XTRXInputThread::getLog2Decimation(unsigned int channel) const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-12-31 10:43:11 +01:00
										 |  |  |     if (channel < 2) { | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |         return m_channels[channel].m_log2Decim; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return 0; | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-12-30 00:46:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  | void XTRXInputThread::setFifo(unsigned int channel, SampleSinkFifo *sampleFifo) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-12-31 10:43:11 +01:00
										 |  |  |     if (channel < 2) { | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |         m_channels[channel].m_sampleFifo = sampleFifo; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  | SampleSinkFifo *XTRXInputThread::getFifo(unsigned int channel) | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-12-31 10:43:11 +01:00
										 |  |  |     if (channel < 2) { | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |         return m_channels[channel].m_sampleFifo; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  | void XTRXInputThread::callbackSIIQ(const qint16* buf, qint32 len) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SampleVector::iterator it = m_channels[m_uniqueChannelIndex].m_convertBuffer.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_channels[m_uniqueChannelIndex].m_log2Decim == 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate1(&it, buf, len); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         switch (m_channels[m_uniqueChannelIndex].m_log2Decim) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |         case 1: | 
					
						
							|  |  |  |             m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate2_cen(&it, buf, len); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case 2: | 
					
						
							|  |  |  |             m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate4_cen(&it, buf, len); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case 3: | 
					
						
							|  |  |  |             m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate8_cen(&it, buf, len); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case 4: | 
					
						
							|  |  |  |             m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate16_cen(&it, buf, len); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case 5: | 
					
						
							|  |  |  |             m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate32_cen(&it, buf, len); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case 6: | 
					
						
							|  |  |  |             m_channels[m_uniqueChannelIndex].m_decimatorsIQ.decimate64_cen(&it, buf, len); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_channels[m_uniqueChannelIndex].m_sampleFifo->write(m_channels[m_uniqueChannelIndex].m_convertBuffer.begin(), it); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void XTRXInputThread::callbackSIQI(const qint16* buf, qint32 len) | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     SampleVector::iterator it = m_channels[m_uniqueChannelIndex].m_convertBuffer.begin(); | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |     if (m_channels[m_uniqueChannelIndex].m_log2Decim == 0) | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  |         m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate1(&it, buf, len); | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |         switch (m_channels[m_uniqueChannelIndex].m_log2Decim) | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2018-12-30 10:18:57 +01:00
										 |  |  |         case 1: | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  |             m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate2_cen(&it, buf, len); | 
					
						
							| 
									
										
										
										
											2018-12-30 10:18:57 +01:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case 2: | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  |             m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate4_cen(&it, buf, len); | 
					
						
							| 
									
										
										
										
											2018-12-30 10:18:57 +01:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case 3: | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  |             m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate8_cen(&it, buf, len); | 
					
						
							| 
									
										
										
										
											2018-12-30 10:18:57 +01:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case 4: | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  |             m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate16_cen(&it, buf, len); | 
					
						
							| 
									
										
										
										
											2018-12-30 10:18:57 +01:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case 5: | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  |             m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate32_cen(&it, buf, len); | 
					
						
							| 
									
										
										
										
											2018-12-30 10:18:57 +01:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case 6: | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  |             m_channels[m_uniqueChannelIndex].m_decimatorsQI.decimate64_cen(&it, buf, len); | 
					
						
							| 
									
										
										
										
											2018-12-30 10:18:57 +01:00
										 |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  |     m_channels[m_uniqueChannelIndex].m_sampleFifo->write(m_channels[m_uniqueChannelIndex].m_convertBuffer.begin(), it); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 20:22:42 +01:00
										 |  |  | void XTRXInputThread::callbackMI(const qint16* buf0, const qint16* buf1, qint32 len) | 
					
						
							| 
									
										
										
										
											2018-12-31 01:43:24 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-12-31 20:22:42 +01:00
										 |  |  |     unsigned int uniqueChannelIndex = m_uniqueChannelIndex; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // channel 0
 | 
					
						
							|  |  |  |     m_uniqueChannelIndex = 0; | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (m_iqOrder) { | 
					
						
							|  |  |  |         callbackSIIQ(buf0, len); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         callbackSIQI(buf0, len); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-31 20:22:42 +01:00
										 |  |  |     // channel 1
 | 
					
						
							|  |  |  |     m_uniqueChannelIndex = 1; | 
					
						
							| 
									
										
										
										
											2020-06-21 11:46:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (m_iqOrder) { | 
					
						
							|  |  |  |         callbackSIIQ(buf1, len); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         callbackSIQI(buf1, len); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-12-31 20:22:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_uniqueChannelIndex = uniqueChannelIndex; | 
					
						
							| 
									
										
										
										
											2018-12-29 01:20:48 +01:00
										 |  |  | } |