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

#include <limesdroutputthread.h>

+ Inheritance diagram for LimeSDROutputThread:
+ Collaboration diagram for LimeSDROutputThread:

Public Member Functions

 LimeSDROutputThread (lms_stream_t *stream, SampleSourceFifo *sampleFifo, QObject *parent=0)
 
 ~LimeSDROutputThread ()
 
virtual void startWork ()
 
virtual void stopWork ()
 
virtual void setDeviceSampleRate (int sampleRate)
 
virtual bool isRunning ()
 
void setLog2Interpolation (unsigned int log2_ioterp)
 

Private Member Functions

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

Private Attributes

QMutex m_startWaitMutex
 
QWaitCondition m_startWaiter
 
bool m_running
 
lms_stream_t * m_stream
 
qint16 m_buf [2 *LIMESDROUTPUT_BLOCKSIZE]
 
SampleSourceFifom_sampleFifo
 
unsigned int m_log2Interp
 
Interpolators< qint16, SDR_TX_SAMP_SZ, 12 > m_interpolators
 

Detailed Description

Definition at line 33 of file limesdroutputthread.h.

Constructor & Destructor Documentation

◆ LimeSDROutputThread()

LimeSDROutputThread::LimeSDROutputThread ( lms_stream_t *  stream,
SampleSourceFifo sampleFifo,
QObject *  parent = 0 
)

Definition at line 24 of file limesdroutputthread.cpp.

References LIMESDROUTPUT_BLOCKSIZE, and m_buf.

24  :
25  QThread(parent),
26  m_running(false),
27  m_stream(stream),
28  m_sampleFifo(sampleFifo),
29  m_log2Interp(0)
30 {
31  std::fill(m_buf, m_buf + 2*LIMESDROUTPUT_BLOCKSIZE, 0);
32 }
qint16 m_buf[2 *LIMESDROUTPUT_BLOCKSIZE]
#define LIMESDROUTPUT_BLOCKSIZE
SampleSourceFifo * m_sampleFifo

◆ ~LimeSDROutputThread()

LimeSDROutputThread::~LimeSDROutputThread ( )

Definition at line 34 of file limesdroutputthread.cpp.

References stopWork().

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

Member Function Documentation

◆ callback()

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

Definition at line 109 of file limesdroutputthread.cpp.

References Interpolators< T, SdrBits, OutputBits >::interpolate1(), Interpolators< T, SdrBits, OutputBits >::interpolate16_cen(), Interpolators< T, SdrBits, OutputBits >::interpolate2_cen(), Interpolators< T, SdrBits, OutputBits >::interpolate32_cen(), Interpolators< T, SdrBits, OutputBits >::interpolate4_cen(), Interpolators< T, SdrBits, OutputBits >::interpolate64_cen(), Interpolators< T, SdrBits, OutputBits >::interpolate8_cen(), m_interpolators, m_log2Interp, m_sampleFifo, and SampleSourceFifo::readAdvance().

Referenced by run().

110 {
111  SampleVector::iterator beginRead;
112  m_sampleFifo->readAdvance(beginRead, len/(1<<m_log2Interp));
113  beginRead -= len;
114 
115  if (m_log2Interp == 0)
116  {
117  m_interpolators.interpolate1(&beginRead, buf, len*2);
118  }
119  else
120  {
121  switch (m_log2Interp)
122  {
123  case 1:
124  m_interpolators.interpolate2_cen(&beginRead, buf, len*2);
125  break;
126  case 2:
127  m_interpolators.interpolate4_cen(&beginRead, buf, len*2);
128  break;
129  case 3:
130  m_interpolators.interpolate8_cen(&beginRead, buf, len*2);
131  break;
132  case 4:
133  m_interpolators.interpolate16_cen(&beginRead, buf, len*2);
134  break;
135  case 5:
136  m_interpolators.interpolate32_cen(&beginRead, buf, len*2);
137  break;
138  case 6:
139  m_interpolators.interpolate64_cen(&beginRead, buf, len*2);
140  break;
141  default:
142  break;
143  }
144  }
145 }
void interpolate64_cen(SampleVector::iterator *it, T *buf, qint32 len, bool invertIQ=false)
void interpolate32_cen(SampleVector::iterator *it, T *buf, qint32 len, bool invertIQ=false)
void interpolate8_cen(SampleVector::iterator *it, T *buf, qint32 len, bool invertIQ=false)
void interpolate2_cen(SampleVector::iterator *it, T *buf, qint32 len, bool invertIQ=false)
SampleSourceFifo * m_sampleFifo
void readAdvance(SampleVector::iterator &readUntil, unsigned int nbSamples)
void interpolate1(SampleVector::iterator *it, T *buf, qint32 len, bool invertIQ=false)
void interpolate16_cen(SampleVector::iterator *it, T *buf, qint32 len, bool invertIQ=false)
void interpolate4_cen(SampleVector::iterator *it, T *buf, qint32 len, bool invertIQ=false)
Interpolators< qint16, SDR_TX_SAMP_SZ, 12 > m_interpolators
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isRunning()

virtual bool LimeSDROutputThread::isRunning ( )
inlinevirtual

Implements DeviceLimeSDRShared::ThreadInterface.

Definition at line 44 of file limesdroutputthread.h.

References m_running, and setLog2Interpolation().

Referenced by LimeSDROutput::applySettings().

44 { return m_running; }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

void LimeSDROutputThread::run ( )
private

Definition at line 77 of file limesdroutputthread.cpp.

References callback(), LIMESDROUTPUT_BLOCKSIZE, m_buf, m_running, m_startWaiter, and m_stream.

78 {
79  int res;
80 
81  lms_stream_meta_t metadata; //Use metadata for additional control over sample receive function behaviour
82  metadata.flushPartialPacket = false; //Do not discard data remainder when read size differs from packet size
83  metadata.waitForTimestamp = false; //Do not wait for specific timestamps
84 
85  m_running = true;
86  m_startWaiter.wakeAll();
87 
88  while (m_running)
89  {
91 
92  res = LMS_SendStream(m_stream, (void *) m_buf, LIMESDROUTPUT_BLOCKSIZE, &metadata, 1000000);
93 
94  if (res < 0)
95  {
96  qCritical("LimeSDROutputThread::run write error: %s", strerror(errno));
97  break;
98  }
99  else if (res != LIMESDROUTPUT_BLOCKSIZE)
100  {
101  qDebug("LimeSDROutputThread::run written %d/%d samples", res, LIMESDROUTPUT_BLOCKSIZE);
102  }
103  }
104 
105  m_running = false;
106 }
qint16 m_buf[2 *LIMESDROUTPUT_BLOCKSIZE]
#define LIMESDROUTPUT_BLOCKSIZE
QWaitCondition m_startWaiter
void callback(qint16 *buf, qint32 len)
+ Here is the call graph for this function:

◆ setDeviceSampleRate()

virtual void LimeSDROutputThread::setDeviceSampleRate ( int  sampleRate)
inlinevirtual

Implements DeviceLimeSDRShared::ThreadInterface.

Definition at line 43 of file limesdroutputthread.h.

43 { (void) sampleRate; }

◆ setLog2Interpolation()

void LimeSDROutputThread::setLog2Interpolation ( unsigned int  log2_ioterp)

Definition at line 72 of file limesdroutputthread.cpp.

References m_log2Interp.

Referenced by LimeSDROutput::applySettings(), isRunning(), and LimeSDROutput::start().

73 {
74  m_log2Interp = log2_interp;
75 }
+ Here is the caller graph for this function:

◆ startWork()

void LimeSDROutputThread::startWork ( )
virtual

Implements DeviceLimeSDRShared::ThreadInterface.

Definition at line 39 of file limesdroutputthread.cpp.

References m_running, m_startWaiter, m_startWaitMutex, and m_stream.

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

40 {
41  if (m_running) return; // return if running already
42 
43  if (LMS_StartStream(m_stream) < 0) {
44  qCritical("LimeSDROutputThread::startWork: could not start stream");
45  } else {
46  usleep(50000);
47  qDebug("LimeSDROutputThread::startWork: stream started");
48  }
49 
50  m_startWaitMutex.lock();
51  start();
52  while(!m_running)
53  m_startWaiter.wait(&m_startWaitMutex, 100);
54  m_startWaitMutex.unlock();
55 }
QWaitCondition m_startWaiter
+ Here is the caller graph for this function:

◆ stopWork()

void LimeSDROutputThread::stopWork ( )
virtual

Implements DeviceLimeSDRShared::ThreadInterface.

Definition at line 57 of file limesdroutputthread.cpp.

References m_running, and m_stream.

Referenced by LimeSDROutput::applySettings(), LimeSDROutput::stop(), and ~LimeSDROutputThread().

58 {
59  if (!m_running) return; // return if not running
60 
61  m_running = false;
62  wait();
63 
64  if (LMS_StopStream(m_stream) < 0) {
65  qCritical("LimeSDROutputThread::stopWork: could not stop stream");
66  } else {
67  usleep(50000);
68  qDebug("LimeSDROutputThread::stopWork: stream stopped");
69  }
70 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_buf

qint16 LimeSDROutputThread::m_buf[2 *LIMESDROUTPUT_BLOCKSIZE]
private

Definition at line 53 of file limesdroutputthread.h.

Referenced by LimeSDROutputThread(), and run().

◆ m_interpolators

Interpolators<qint16, SDR_TX_SAMP_SZ, 12> LimeSDROutputThread::m_interpolators
private

Definition at line 58 of file limesdroutputthread.h.

Referenced by callback().

◆ m_log2Interp

unsigned int LimeSDROutputThread::m_log2Interp
private

Definition at line 56 of file limesdroutputthread.h.

Referenced by callback(), and setLog2Interpolation().

◆ m_running

bool LimeSDROutputThread::m_running
private

Definition at line 50 of file limesdroutputthread.h.

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

◆ m_sampleFifo

SampleSourceFifo* LimeSDROutputThread::m_sampleFifo
private

Definition at line 54 of file limesdroutputthread.h.

Referenced by callback().

◆ m_startWaiter

QWaitCondition LimeSDROutputThread::m_startWaiter
private

Definition at line 49 of file limesdroutputthread.h.

Referenced by run(), and startWork().

◆ m_startWaitMutex

QMutex LimeSDROutputThread::m_startWaitMutex
private

Definition at line 48 of file limesdroutputthread.h.

Referenced by startWork().

◆ m_stream

lms_stream_t* LimeSDROutputThread::m_stream
private

Definition at line 52 of file limesdroutputthread.h.

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


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