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.
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SDRPlayThread Class Reference

#include <sdrplaythread.h>

Inherits QThread.

+ Collaboration diagram for SDRPlayThread:

Public Member Functions

 SDRPlayThread (mirisdr_dev_t *dev, SampleSinkFifo *sampleFifo, QObject *parent=NULL)
 
 ~SDRPlayThread ()
 
void startWork ()
 
void stopWork ()
 
void setSamplerate (int samplerate)
 
void setLog2Decimation (unsigned int log2_decim)
 
void setFcPos (int fcPos)
 

Private Member Functions

void run ()
 
void callback (const qint16 *buf, qint32 len)
 

Static Private Member Functions

static void callbackHelper (unsigned char *buf, uint32_t len, void *ctx)
 

Private Attributes

QMutex m_startWaitMutex
 
QWaitCondition m_startWaiter
 
bool m_running
 
mirisdr_dev_t * m_dev
 
SampleVector m_convertBuffer
 
SampleSinkFifom_sampleFifo
 
int m_samplerate
 
unsigned int m_log2Decim
 
int m_fcPos
 
Decimators< qint32, qint16, SDR_RX_SAMP_SZ, 12 > m_decimators
 

Detailed Description

Definition at line 30 of file sdrplaythread.h.

Constructor & Destructor Documentation

◆ SDRPlayThread()

SDRPlayThread::SDRPlayThread ( mirisdr_dev_t *  dev,
SampleSinkFifo sampleFifo,
QObject *  parent = NULL 
)

Definition at line 23 of file sdrplaythread.cpp.

23  :
24  QThread(parent),
25  m_running(false),
26  m_dev(dev),
28  m_sampleFifo(sampleFifo),
29  m_samplerate(288000),
30  m_log2Decim(0),
31  m_fcPos(0)
32 {
33 }
mirisdr_dev_t * m_dev
Definition: sdrplaythread.h:48
unsigned int m_log2Decim
Definition: sdrplaythread.h:53
#define SDRPLAY_INIT_NBSAMPLES
Definition: sdrplaythread.h:28
SampleVector m_convertBuffer
Definition: sdrplaythread.h:49
SampleSinkFifo * m_sampleFifo
Definition: sdrplaythread.h:50

◆ ~SDRPlayThread()

SDRPlayThread::~SDRPlayThread ( )

Definition at line 35 of file sdrplaythread.cpp.

References stopWork().

36 {
37  stopWork();
38 }
+ Here is the call graph for this function:

Member Function Documentation

◆ callback()

void SDRPlayThread::callback ( const qint16 *  buf,
qint32  len 
)
private

Definition at line 95 of file sdrplaythread.cpp.

References Decimators< StorageType, T, SdrBits, InputBits >::decimate1(), Decimators< StorageType, T, SdrBits, InputBits >::decimate16_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate16_inf(), Decimators< StorageType, T, SdrBits, InputBits >::decimate16_sup(), Decimators< StorageType, T, SdrBits, InputBits >::decimate2_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate2_inf(), Decimators< StorageType, T, SdrBits, InputBits >::decimate2_sup(), Decimators< StorageType, T, SdrBits, InputBits >::decimate32_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate32_inf(), Decimators< StorageType, T, SdrBits, InputBits >::decimate32_sup(), Decimators< StorageType, T, SdrBits, InputBits >::decimate4_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate4_inf(), Decimators< StorageType, T, SdrBits, InputBits >::decimate4_sup(), Decimators< StorageType, T, SdrBits, InputBits >::decimate64_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate64_inf(), Decimators< StorageType, T, SdrBits, InputBits >::decimate64_sup(), Decimators< StorageType, T, SdrBits, InputBits >::decimate8_cen(), Decimators< StorageType, T, SdrBits, InputBits >::decimate8_inf(), Decimators< StorageType, T, SdrBits, InputBits >::decimate8_sup(), m_convertBuffer, m_decimators, m_dev, m_fcPos, m_log2Decim, m_running, m_sampleFifo, and SampleSinkFifo::write().

Referenced by callbackHelper().

96 {
97  SampleVector::iterator it = m_convertBuffer.begin();
98 
99  if (m_log2Decim == 0)
100  {
101  m_decimators.decimate1(&it, buf, len);
102  }
103  else
104  {
105  if (m_fcPos == 0) // Infradyne
106  {
107  switch (m_log2Decim)
108  {
109  case 1:
110  m_decimators.decimate2_inf(&it, buf, len);
111  break;
112  case 2:
113  m_decimators.decimate4_inf(&it, buf, len);
114  break;
115  case 3:
116  m_decimators.decimate8_inf(&it, buf, len);
117  break;
118  case 4:
119  m_decimators.decimate16_inf(&it, buf, len);
120  break;
121  case 5:
122  m_decimators.decimate32_inf(&it, buf, len);
123  break;
124  case 6:
125  m_decimators.decimate64_inf(&it, buf, len);
126  break;
127  default:
128  break;
129  }
130  }
131  else if (m_fcPos == 1) // Supradyne
132  {
133  switch (m_log2Decim)
134  {
135  case 1:
136  m_decimators.decimate2_sup(&it, buf, len);
137  break;
138  case 2:
139  m_decimators.decimate4_sup(&it, buf, len);
140  break;
141  case 3:
142  m_decimators.decimate8_sup(&it, buf, len);
143  break;
144  case 4:
145  m_decimators.decimate16_sup(&it, buf, len);
146  break;
147  case 5:
148  m_decimators.decimate32_sup(&it, buf, len);
149  break;
150  case 6:
151  m_decimators.decimate64_sup(&it, buf, len);
152  break;
153  default:
154  break;
155  }
156  }
157  else // Centered
158  {
159  switch (m_log2Decim)
160  {
161  case 1:
162  m_decimators.decimate2_cen(&it, buf, len);
163  break;
164  case 2:
165  m_decimators.decimate4_cen(&it, buf, len);
166  break;
167  case 3:
168  m_decimators.decimate8_cen(&it, buf, len);
169  break;
170  case 4:
171  m_decimators.decimate16_cen(&it, buf, len);
172  break;
173  case 5:
174  m_decimators.decimate32_cen(&it, buf, len);
175  break;
176  case 6:
177  m_decimators.decimate64_cen(&it, buf, len);
178  break;
179  default:
180  break;
181  }
182  }
183  }
184 
185  m_sampleFifo->write(m_convertBuffer.begin(), it);
186 
187  if(!m_running)
188  {
189  mirisdr_cancel_async(m_dev);
190  }
191 }
void decimate2_inf(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:498
void decimate64_sup(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:2975
mirisdr_dev_t * m_dev
Definition: sdrplaythread.h:48
void decimate64_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:3040
void decimate2_sup(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:526
unsigned int m_log2Decim
Definition: sdrplaythread.h:53
void decimate2_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:554
uint write(const quint8 *data, uint count)
void decimate8_sup(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:941
void decimate64_inf(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:2418
void decimate32_inf(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1592
void decimate32_sup(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1902
void decimate4_sup(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:682
void decimate8_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1057
void decimate8_inf(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:825
void decimate16_sup(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1300
void decimate4_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:782
SampleVector m_convertBuffer
Definition: sdrplaythread.h:49
void decimate4_inf(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:582
SampleSinkFifo * m_sampleFifo
Definition: sdrplaythread.h:50
void decimate16_inf(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1117
void decimate16_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:1483
void decimate32_cen(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:2212
void decimate1(SampleVector::iterator *it, const T *buf, qint32 len)
Definition: decimators.h:462
Decimators< qint32, qint16, SDR_RX_SAMP_SZ, 12 > m_decimators
Definition: sdrplaythread.h:56
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ callbackHelper()

void SDRPlayThread::callbackHelper ( unsigned char *  buf,
uint32_t  len,
void *  ctx 
)
staticprivate

Definition at line 89 of file sdrplaythread.cpp.

References callback().

Referenced by run().

90 {
91  SDRPlayThread* thread = (SDRPlayThread*) ctx;
92  thread->callback((const qint16*) buf, len/2);
93 }
void callback(const qint16 *buf, qint32 len)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

void SDRPlayThread::run ( )
private

Definition at line 70 of file sdrplaythread.cpp.

References callbackHelper(), m_dev, m_running, m_startWaiter, and SDRPLAY_INIT_NBSAMPLES.

71 {
72  int res;
73 
74  m_running = true;
75  m_startWaiter.wakeAll();
76 
77  while (m_running)
78  {
79  if ((res = mirisdr_read_async(m_dev, &SDRPlayThread::callbackHelper, this, 32, SDRPLAY_INIT_NBSAMPLES)) < 0)
80  {
81  qCritical("SDRPlayThread::run: async read error: rc %d: %s", res, strerror(errno));
82  break;
83  }
84  }
85 
86  m_running = false;
87 }
mirisdr_dev_t * m_dev
Definition: sdrplaythread.h:48
QWaitCondition m_startWaiter
Definition: sdrplaythread.h:45
#define SDRPLAY_INIT_NBSAMPLES
Definition: sdrplaythread.h:28
static void callbackHelper(unsigned char *buf, uint32_t len, void *ctx)
+ Here is the call graph for this function:

◆ setFcPos()

void SDRPlayThread::setFcPos ( int  fcPos)

Definition at line 65 of file sdrplaythread.cpp.

References m_fcPos.

Referenced by SDRPlayInput::applySettings(), and SDRPlayInput::start().

66 {
67  m_fcPos = fcPos;
68 }
+ Here is the caller graph for this function:

◆ setLog2Decimation()

void SDRPlayThread::setLog2Decimation ( unsigned int  log2_decim)

Definition at line 60 of file sdrplaythread.cpp.

References m_log2Decim.

Referenced by SDRPlayInput::applySettings(), and SDRPlayInput::start().

61 {
62  m_log2Decim = log2_decim;
63 }
unsigned int m_log2Decim
Definition: sdrplaythread.h:53
+ Here is the caller graph for this function:

◆ setSamplerate()

void SDRPlayThread::setSamplerate ( int  samplerate)

Definition at line 55 of file sdrplaythread.cpp.

References m_samplerate.

56 {
57  m_samplerate = samplerate;
58 }

◆ startWork()

void SDRPlayThread::startWork ( )

Definition at line 40 of file sdrplaythread.cpp.

References m_running, m_startWaiter, and m_startWaitMutex.

Referenced by SDRPlayInput::start().

41 {
42  m_startWaitMutex.lock();
43  start();
44  while(!m_running)
45  m_startWaiter.wait(&m_startWaitMutex, 100);
46  m_startWaitMutex.unlock();
47 }
QWaitCondition m_startWaiter
Definition: sdrplaythread.h:45
QMutex m_startWaitMutex
Definition: sdrplaythread.h:44
+ Here is the caller graph for this function:

◆ stopWork()

void SDRPlayThread::stopWork ( )

Definition at line 49 of file sdrplaythread.cpp.

References m_running.

Referenced by SDRPlayInput::stop(), and ~SDRPlayThread().

50 {
51  m_running = false;
52  wait();
53 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_convertBuffer

SampleVector SDRPlayThread::m_convertBuffer
private

Definition at line 49 of file sdrplaythread.h.

Referenced by callback().

◆ m_decimators

Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12> SDRPlayThread::m_decimators
private

Definition at line 56 of file sdrplaythread.h.

Referenced by callback().

◆ m_dev

mirisdr_dev_t* SDRPlayThread::m_dev
private

Definition at line 48 of file sdrplaythread.h.

Referenced by callback(), and run().

◆ m_fcPos

int SDRPlayThread::m_fcPos
private

Definition at line 54 of file sdrplaythread.h.

Referenced by callback(), and setFcPos().

◆ m_log2Decim

unsigned int SDRPlayThread::m_log2Decim
private

Definition at line 53 of file sdrplaythread.h.

Referenced by callback(), and setLog2Decimation().

◆ m_running

bool SDRPlayThread::m_running
private

Definition at line 46 of file sdrplaythread.h.

Referenced by callback(), run(), startWork(), and stopWork().

◆ m_sampleFifo

SampleSinkFifo* SDRPlayThread::m_sampleFifo
private

Definition at line 50 of file sdrplaythread.h.

Referenced by callback().

◆ m_samplerate

int SDRPlayThread::m_samplerate
private

Definition at line 52 of file sdrplaythread.h.

Referenced by setSamplerate().

◆ m_startWaiter

QWaitCondition SDRPlayThread::m_startWaiter
private

Definition at line 45 of file sdrplaythread.h.

Referenced by run(), and startWork().

◆ m_startWaitMutex

QMutex SDRPlayThread::m_startWaitMutex
private

Definition at line 44 of file sdrplaythread.h.

Referenced by startWork().


The documentation for this class was generated from the following files: