SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
soapysdrinputthread.h
Go to the documentation of this file.
1 // Copyright (C) 2018 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #ifndef PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTTHREAD_H_
19 #define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTTHREAD_H_
20 
21 // SoapySDR is a device wrapper with a single stream supporting one or many Rx
22 // Therefore only one thread can be allocated for the Rx side
23 // All FIFOs must be registered before calling startWork()
24 
25 #include <QThread>
26 #include <QMutex>
27 #include <QWaitCondition>
28 
29 #include <SoapySDR/Device.hpp>
30 
32 #include "dsp/decimators.h"
33 #include "dsp/decimatorsfi.h"
34 
35 class SampleSinkFifo;
36 
37 class SoapySDRInputThread : public QThread {
38  Q_OBJECT
39 
40 public:
41  SoapySDRInputThread(SoapySDR::Device* dev, unsigned int nbRxChannels, QObject* parent = 0);
43 
44  void startWork();
45  void stopWork();
46  bool isRunning() const { return m_running; }
47  unsigned int getNbChannels() const { return m_nbChannels; }
48  void setLog2Decimation(unsigned int channel, unsigned int log2_decim);
49  unsigned int getLog2Decimation(unsigned int channel) const;
50  void setSampleRate(unsigned int sampleRate) { m_sampleRate = sampleRate; }
51  unsigned int getSampleRate() const { return m_sampleRate; }
52  void setFcPos(unsigned int channel, int fcPos);
53  int getFcPos(unsigned int channel) const;
54  void setFifo(unsigned int channel, SampleSinkFifo *sampleFifo);
55  SampleSinkFifo *getFifo(unsigned int channel);
56 
57 private:
58  struct Channel
59  {
62  unsigned int m_log2Decim;
63  int m_fcPos;
68 
69  Channel() :
70  m_sampleFifo(0),
71  m_log2Decim(0),
72  m_fcPos(0)
73  {}
74 
76  {}
77  };
78 
80  {
85  };
86 
88  QWaitCondition m_startWaiter;
89  bool m_running;
90  SoapySDR::Device* m_dev;
91 
93  unsigned int m_sampleRate;
94  unsigned int m_nbChannels;
96 
97  void run();
98  unsigned int getNbFifos();
99  void callbackSI8(const qint8* buf, qint32 len, unsigned int channel = 0);
100  void callbackSI12(const qint16* buf, qint32 len, unsigned int channel = 0);
101  void callbackSI16(const qint16* buf, qint32 len, unsigned int channel = 0);
102  void callbackSIF(const float* buf, qint32 len, unsigned int channel = 0);
103  void callbackMI(std::vector<void *>& buffs, qint32 samplesPerChannel);
104 };
105 
106 
107 
108 #endif /* PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTTHREAD_H_ */
std::vector< Sample > SampleVector
Definition: dsptypes.h:96
unsigned int getSampleRate() const
DecimatorType m_decimatorType
Channel * m_channels
Array of channels dynamically allocated for the given number of Rx channels.
Decimators< qint32, qint8, SDR_RX_SAMP_SZ, 8 > m_decimators8
void callbackMI(std::vector< void *> &buffs, qint32 samplesPerChannel)
void setFcPos(unsigned int channel, int fcPos)
void callbackSI12(const qint16 *buf, qint32 len, unsigned int channel=0)
void callbackSI8(const qint8 *buf, qint32 len, unsigned int channel=0)
QWaitCondition m_startWaiter
void setSampleRate(unsigned int sampleRate)
int getFcPos(unsigned int channel) const
SoapySDR::Device * m_dev
void callbackSIF(const float *buf, qint32 len, unsigned int channel=0)
void setLog2Decimation(unsigned int channel, unsigned int log2_decim)
SampleSinkFifo * getFifo(unsigned int channel)
void callbackSI16(const qint16 *buf, qint32 len, unsigned int channel=0)
Decimators< qint32, qint16, SDR_RX_SAMP_SZ, 16 > m_decimators16
unsigned int getLog2Decimation(unsigned int channel) const
Decimators< qint32, qint16, SDR_RX_SAMP_SZ, 12 > m_decimators12
SoapySDRInputThread(SoapySDR::Device *dev, unsigned int nbRxChannels, QObject *parent=0)
void setFifo(unsigned int channel, SampleSinkFifo *sampleFifo)
unsigned int getNbChannels() const