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 | Static Private Attributes | List of all members
AirspyHFThread Class Reference

#include <airspyhfthread.h>

Inherits QThread.

+ Collaboration diagram for AirspyHFThread:

Public Member Functions

 AirspyHFThread (airspyhf_device_t *dev, SampleSinkFifo *sampleFifo, QObject *parent=0)
 
 ~AirspyHFThread ()
 
void startWork ()
 
void stopWork ()
 
void setSamplerate (uint32_t samplerate)
 
void setLog2Decimation (unsigned int log2_decim)
 

Private Member Functions

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

Static Private Member Functions

static int rx_callback (airspyhf_transfer_t *transfer)
 

Private Attributes

QMutex m_startWaitMutex
 
QWaitCondition m_startWaiter
 
bool m_running
 
airspyhf_device_t * m_dev
 
qint16 m_buf [2 *AIRSPYHF_BLOCKSIZE]
 
SampleVector m_convertBuffer
 
SampleSinkFifom_sampleFifo
 
int m_samplerate
 
unsigned int m_log2Decim
 
DecimatorsFI m_decimators
 

Static Private Attributes

static AirspyHFThreadm_this = 0
 

Detailed Description

Definition at line 31 of file airspyhfthread.h.

Constructor & Destructor Documentation

◆ AirspyHFThread()

AirspyHFThread::AirspyHFThread ( airspyhf_device_t *  dev,
SampleSinkFifo sampleFifo,
QObject *  parent = 0 
)

Definition at line 27 of file airspyhfthread.cpp.

References AIRSPYHF_BLOCKSIZE, m_buf, and m_this.

27  :
28  QThread(parent),
29  m_running(false),
30  m_dev(dev),
32  m_sampleFifo(sampleFifo),
33  m_samplerate(10),
34  m_log2Decim(0)
35 {
36  memset((char*) m_buf, 0, 2*AIRSPYHF_BLOCKSIZE*sizeof(qint16));
37  m_this = this;
38 }
#define AIRSPYHF_BLOCKSIZE
qint16 m_buf[2 *AIRSPYHF_BLOCKSIZE]
unsigned int m_log2Decim
SampleVector m_convertBuffer
static AirspyHFThread * m_this
SampleSinkFifo * m_sampleFifo
airspyhf_device_t * m_dev

◆ ~AirspyHFThread()

AirspyHFThread::~AirspyHFThread ( )

Definition at line 40 of file airspyhfthread.cpp.

References m_this, and stopWork().

41 {
42  stopWork();
43  m_this = 0;
44 }
static AirspyHFThread * m_this
+ Here is the call graph for this function:

Member Function Documentation

◆ callback()

void AirspyHFThread::callback ( const float *  buf,
qint32  len 
)
private

Definition at line 105 of file airspyhfthread.cpp.

References DecimatorsFI::decimate1(), DecimatorsFI::decimate16_cen(), DecimatorsFI::decimate2_cen(), DecimatorsFI::decimate32_cen(), DecimatorsFI::decimate4_cen(), DecimatorsFI::decimate64_cen(), DecimatorsFI::decimate8_cen(), m_convertBuffer, m_decimators, m_log2Decim, m_sampleFifo, and SampleSinkFifo::write().

Referenced by rx_callback().

106 {
107  SampleVector::iterator it = m_convertBuffer.begin();
108 
109  switch (m_log2Decim)
110  {
111  case 0:
112  m_decimators.decimate1(&it, buf, len);
113  break;
114  case 1:
115  m_decimators.decimate2_cen(&it, buf, len);
116  break;
117  case 2:
118  m_decimators.decimate4_cen(&it, buf, len);
119  break;
120  case 3:
121  m_decimators.decimate8_cen(&it, buf, len);
122  break;
123  case 4:
124  m_decimators.decimate16_cen(&it, buf, len);
125  break;
126  case 5:
127  m_decimators.decimate32_cen(&it, buf, len);
128  break;
129  case 6:
130  m_decimators.decimate64_cen(&it, buf, len);
131  break;
132  default:
133  break;
134  }
135 
136  m_sampleFifo->write(m_convertBuffer.begin(), it);
137 }
void decimate32_cen(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
uint write(const quint8 *data, uint count)
void decimate16_cen(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)
unsigned int m_log2Decim
void decimate8_cen(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
DecimatorsFI m_decimators
SampleVector m_convertBuffer
SampleSinkFifo * m_sampleFifo
void decimate64_cen(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
void decimate1(SampleVector::iterator *it, const float *buf, qint32 nbIAndQ)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

void AirspyHFThread::run ( )
private

Definition at line 72 of file airspyhfthread.cpp.

References m_dev, m_running, m_startWaiter, and rx_callback().

73 {
74  airspyhf_error rc;
75 
76  m_running = true;
77  m_startWaiter.wakeAll();
78 
79  rc = (airspyhf_error) airspyhf_start(m_dev, rx_callback, 0);
80 
81  if (rc != AIRSPYHF_SUCCESS)
82  {
83  qCritical("AirspyHFFThread::run: failed to start Airspy HF Rx");
84  }
85  else
86  {
87  while ((m_running) && (airspyhf_is_streaming(m_dev) != 0))
88  {
89  sleep(1);
90  }
91  }
92 
93  rc = (airspyhf_error) airspyhf_stop(m_dev);
94 
95  if (rc == AIRSPYHF_SUCCESS) {
96  qDebug("AirspyHFFThread::run: stopped Airspy HF Rx");
97  } else {
98  qDebug("AirspyHFFThread::run: failed to stop Airspy HF Rx");
99  }
100 
101  m_running = false;
102 }
QWaitCondition m_startWaiter
static int rx_callback(airspyhf_transfer_t *transfer)
airspyhf_device_t * m_dev
+ Here is the call graph for this function:

◆ rx_callback()

int AirspyHFThread::rx_callback ( airspyhf_transfer_t *  transfer)
staticprivate

Definition at line 140 of file airspyhfthread.cpp.

References callback(), and m_this.

Referenced by run().

141 {
142  qint32 nbIAndQ = transfer->sample_count * 2;
143  m_this->callback((float *) transfer->samples, nbIAndQ);
144  return 0;
145 }
void callback(const float *buf, qint32 len)
static AirspyHFThread * m_this
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setLog2Decimation()

void AirspyHFThread::setLog2Decimation ( unsigned int  log2_decim)

Definition at line 67 of file airspyhfthread.cpp.

References m_log2Decim.

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

68 {
69  m_log2Decim = log2_decim;
70 }
unsigned int m_log2Decim
+ Here is the caller graph for this function:

◆ setSamplerate()

void AirspyHFThread::setSamplerate ( uint32_t  samplerate)

Definition at line 62 of file airspyhfthread.cpp.

References m_samplerate.

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

63 {
64  m_samplerate = samplerate;
65 }
+ Here is the caller graph for this function:

◆ startWork()

void AirspyHFThread::startWork ( )

Definition at line 46 of file airspyhfthread.cpp.

References m_running, m_startWaiter, and m_startWaitMutex.

Referenced by AirspyHFInput::start().

47 {
48  m_startWaitMutex.lock();
49  start();
50  while(!m_running)
51  m_startWaiter.wait(&m_startWaitMutex, 100);
52  m_startWaitMutex.unlock();
53 }
QWaitCondition m_startWaiter
QMutex m_startWaitMutex
+ Here is the caller graph for this function:

◆ stopWork()

void AirspyHFThread::stopWork ( )

Definition at line 55 of file airspyhfthread.cpp.

References m_running.

Referenced by AirspyHFInput::stop(), and ~AirspyHFThread().

56 {
57  qDebug("AirspyThread::stopWork");
58  m_running = false;
59  wait();
60 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_buf

qint16 AirspyHFThread::m_buf[2 *AIRSPYHF_BLOCKSIZE]
private

Definition at line 49 of file airspyhfthread.h.

Referenced by AirspyHFThread().

◆ m_convertBuffer

SampleVector AirspyHFThread::m_convertBuffer
private

Definition at line 50 of file airspyhfthread.h.

Referenced by callback().

◆ m_decimators

DecimatorsFI AirspyHFThread::m_decimators
private

Definition at line 57 of file airspyhfthread.h.

Referenced by callback().

◆ m_dev

airspyhf_device_t* AirspyHFThread::m_dev
private

Definition at line 48 of file airspyhfthread.h.

Referenced by run().

◆ m_log2Decim

unsigned int AirspyHFThread::m_log2Decim
private

Definition at line 54 of file airspyhfthread.h.

Referenced by callback(), and setLog2Decimation().

◆ m_running

bool AirspyHFThread::m_running
private

Definition at line 46 of file airspyhfthread.h.

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

◆ m_sampleFifo

SampleSinkFifo* AirspyHFThread::m_sampleFifo
private

Definition at line 51 of file airspyhfthread.h.

Referenced by callback().

◆ m_samplerate

int AirspyHFThread::m_samplerate
private

Definition at line 53 of file airspyhfthread.h.

Referenced by setSamplerate().

◆ m_startWaiter

QWaitCondition AirspyHFThread::m_startWaiter
private

Definition at line 45 of file airspyhfthread.h.

Referenced by run(), and startWork().

◆ m_startWaitMutex

QMutex AirspyHFThread::m_startWaitMutex
private

Definition at line 44 of file airspyhfthread.h.

Referenced by startWork().

◆ m_this

AirspyHFThread * AirspyHFThread::m_this = 0
staticprivate

Definition at line 55 of file airspyhfthread.h.

Referenced by AirspyHFThread(), rx_callback(), and ~AirspyHFThread().


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