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.
soapysdroutputthread.h
Go to the documentation of this file.
1 // Copyright (C) 2015 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_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUTTHREAD_H_
19 #define PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUTTHREAD_H_
20 
21 
22 #include <QThread>
23 #include <QMutex>
24 #include <QWaitCondition>
25 
26 #include <SoapySDR/Device.hpp>
27 
29 #include "dsp/interpolators.h"
30 #include "dsp/interpolatorsif.h"
31 
32 class SampleSourceFifo;
33 
34 class SoapySDROutputThread : public QThread {
35  Q_OBJECT
36 
37 public:
38  SoapySDROutputThread(SoapySDR::Device* dev, unsigned int nbTxChannels, QObject* parent = 0);
40 
41  void startWork();
42  void stopWork();
43  bool isRunning() const { return m_running; }
44  unsigned int getNbChannels() const { return m_nbChannels; }
45  void setLog2Interpolation(unsigned int channel, unsigned int log2_interp);
46  unsigned int getLog2Interpolation(unsigned int channel) const;
47  void setSampleRate(unsigned int sampleRate) { m_sampleRate = sampleRate; }
48  unsigned int getSampleRate() const { return m_sampleRate; }
49  void setFifo(unsigned int channel, SampleSourceFifo *sampleFifo);
50  SampleSourceFifo *getFifo(unsigned int channel);
51 
52 private:
53  struct Channel
54  {
56  unsigned int m_log2Interp;
61 
62  Channel() :
63  m_sampleFifo(0),
64  m_log2Interp(0)
65  {}
66 
68  {}
69  };
70 
72  {
77  };
78 
79 
81  QWaitCondition m_startWaiter;
82  bool m_running;
83  SoapySDR::Device* m_dev;
84 
86  unsigned int m_sampleRate;
87  unsigned int m_nbChannels;
89 
90  void run();
91  unsigned int getNbFifos();
92  void callbackSO8(qint8* buf, qint32 len, unsigned int channel = 0);
93  void callbackSO12(qint16* buf, qint32 len, unsigned int channel = 0);
94  void callbackSO16(qint16* buf, qint32 len, unsigned int channel = 0);
95  void callbackSOIF(float* buf, qint32 len, unsigned int channel = 0);
96  void callbackMO(std::vector<void *>& buffs, qint32 samplesPerChannel);
97 };
98 
99 
100 #endif /* PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUTTHREAD_H_ */
unsigned int getLog2Interpolation(unsigned int channel) const
void callbackSO16(qint16 *buf, qint32 len, unsigned int channel=0)
Interpolators< qint16, SDR_TX_SAMP_SZ, 12 > m_interpolators12
void setSampleRate(unsigned int sampleRate)
QWaitCondition m_startWaiter
SoapySDR::Device * m_dev
unsigned int getNbChannels() const
void callbackSOIF(float *buf, qint32 len, unsigned int channel=0)
InterpolatorType m_interpolatorType
Interpolators< qint8, SDR_TX_SAMP_SZ, 8 > m_interpolators8
InterpolatorsIF< SDR_TX_SAMP_SZ, SDR_TX_SAMP_SZ > m_interpolatorsIF
SoapySDROutputThread(SoapySDR::Device *dev, unsigned int nbTxChannels, QObject *parent=0)
Interpolators< qint16, SDR_TX_SAMP_SZ, 16 > m_interpolators16
void setFifo(unsigned int channel, SampleSourceFifo *sampleFifo)
void callbackMO(std::vector< void *> &buffs, qint32 samplesPerChannel)
void callbackSO8(qint8 *buf, qint32 len, unsigned int channel=0)
Channel * m_channels
Array of channels dynamically allocated for the given number of Tx channels.
SampleSourceFifo * getFifo(unsigned int channel)
unsigned int getSampleRate() const
void callbackSO12(qint16 *buf, qint32 len, unsigned int channel=0)
void setLog2Interpolation(unsigned int channel, unsigned int log2_interp)