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.
Classes | Public Slots | Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
LocalSourceThread Class Reference

#include <localsourcethread.h>

Inherits QThread.

+ Collaboration diagram for LocalSourceThread:

Classes

class  MsgStartStop
 

Public Slots

void pullSamples (unsigned int count)
 

Signals

void samplesAvailable (int offset)
 

Public Member Functions

 LocalSourceThread (QObject *parent=0)
 
 ~LocalSourceThread ()
 
void startStop (bool start)
 
void setSampleFifo (SampleSourceFifo *sampleFifo)
 

Private Slots

void handleInputMessages ()
 

Private Member Functions

void startWork ()
 
void stopWork ()
 
void run ()
 

Private Attributes

QMutex m_startWaitMutex
 
QWaitCondition m_startWaiter
 
volatile bool m_running
 
SampleSourceFifom_sampleFifo
 
MessageQueue m_inputMessageQueue
 

Detailed Description

Definition at line 31 of file localsourcethread.h.

Constructor & Destructor Documentation

◆ LocalSourceThread()

LocalSourceThread::LocalSourceThread ( QObject *  parent = 0)

Definition at line 24 of file localsourcethread.cpp.

Referenced by LocalSourceThread::MsgStartStop::MsgStartStop().

24  :
25  QThread(parent),
26  m_running(false),
27  m_sampleFifo(0)
28 {
29  connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
30 }
MessageQueue m_inputMessageQueue
volatile bool m_running
SampleSourceFifo * m_sampleFifo
+ Here is the caller graph for this function:

◆ ~LocalSourceThread()

LocalSourceThread::~LocalSourceThread ( )

Definition at line 32 of file localsourcethread.cpp.

Referenced by LocalSourceThread::MsgStartStop::MsgStartStop().

33 {
34  qDebug("LocalSourceThread::~LocalSourceThread");
35 }
+ Here is the caller graph for this function:

Member Function Documentation

◆ handleInputMessages

void LocalSourceThread::handleInputMessages ( )
privateslot

Definition at line 90 of file localsourcethread.cpp.

References LocalSourceThread::MsgStartStop::getStartStop(), m_inputMessageQueue, Message::match(), MessageQueue::pop(), startWork(), and stopWork().

91 {
92  Message* message;
93 
94  while ((message = m_inputMessageQueue.pop()) != 0)
95  {
96  if (MsgStartStop::match(*message))
97  {
98  MsgStartStop* notif = (MsgStartStop*) message;
99  qDebug("LocalSourceThread::handleInputMessages: MsgStartStop: %s", notif->getStartStop() ? "start" : "stop");
100 
101  if (notif->getStartStop()) {
102  startWork();
103  } else {
104  stopWork();
105  }
106 
107  delete message;
108  }
109  }
110 }
Message * pop()
Pop message from queue.
MessageQueue m_inputMessageQueue
static bool match(const Message *message)
Definition: message.cpp:45
+ Here is the call graph for this function:

◆ pullSamples

void LocalSourceThread::pullSamples ( unsigned int  count)
slot

Definition at line 48 of file localsourcethread.cpp.

References SampleSourceFifo::getIteratorOffset(), m_sampleFifo, SampleSourceFifo::readAdvance(), and samplesAvailable().

Referenced by LocalSourceThread::MsgStartStop::MsgStartStop().

49 {
50  SampleVector::iterator beginRead;
51  m_sampleFifo->readAdvance(beginRead, count);
53 }
int getIteratorOffset(const SampleVector::iterator &iterator)
void readAdvance(SampleVector::iterator &readUntil, unsigned int nbSamples)
SampleSourceFifo * m_sampleFifo
void samplesAvailable(int offset)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

void LocalSourceThread::run ( )
private

Definition at line 75 of file localsourcethread.cpp.

References m_running, and m_startWaiter.

76 {
77  qDebug("LocalSinkThread::run: begin");
78  m_running = true;
79  m_startWaiter.wakeAll();
80 
81  while (m_running)
82  {
83  sleep(1); // Do nothing as everything is in the data handler (dequeuer)
84  }
85 
86  m_running = false;
87  qDebug("LocalSinkThread::run: end");
88 }
QWaitCondition m_startWaiter
volatile bool m_running

◆ samplesAvailable

void LocalSourceThread::samplesAvailable ( int  offset)
signal

Referenced by LocalSourceThread::MsgStartStop::MsgStartStop(), and pullSamples().

+ Here is the caller graph for this function:

◆ setSampleFifo()

void LocalSourceThread::setSampleFifo ( SampleSourceFifo sampleFifo)

Definition at line 43 of file localsourcethread.cpp.

References m_sampleFifo.

Referenced by LocalSource::applySettings(), LocalSourceThread::MsgStartStop::MsgStartStop(), and LocalSource::start().

44 {
45  m_sampleFifo = sampleFifo;
46 }
SampleSourceFifo * m_sampleFifo
+ Here is the caller graph for this function:

◆ startStop()

void LocalSourceThread::startStop ( bool  start)

Definition at line 37 of file localsourcethread.cpp.

References LocalSourceThread::MsgStartStop::create(), m_inputMessageQueue, and MessageQueue::push().

Referenced by LocalSourceThread::MsgStartStop::MsgStartStop(), LocalSource::start(), and LocalSource::stop().

38 {
39  MsgStartStop *msg = MsgStartStop::create(start);
41 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
static MsgStartStop * create(bool startStop)
MessageQueue m_inputMessageQueue
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startWork()

void LocalSourceThread::startWork ( )
private

Definition at line 55 of file localsourcethread.cpp.

References m_running, m_startWaiter, and m_startWaitMutex.

Referenced by handleInputMessages().

56 {
57  qDebug("LocalSourceThread::startWork");
58  m_startWaitMutex.lock();
59  start();
60 
61  while(!m_running) {
62  m_startWaiter.wait(&m_startWaitMutex, 100);
63  }
64 
65  m_startWaitMutex.unlock();
66 }
QWaitCondition m_startWaiter
volatile bool m_running
+ Here is the caller graph for this function:

◆ stopWork()

void LocalSourceThread::stopWork ( )
private

Definition at line 68 of file localsourcethread.cpp.

References m_running.

Referenced by handleInputMessages().

69 {
70  qDebug("LocalSourceThread::stopWork");
71  m_running = false;
72  wait();
73 }
volatile bool m_running
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_inputMessageQueue

MessageQueue LocalSourceThread::m_inputMessageQueue
private

Definition at line 72 of file localsourcethread.h.

Referenced by handleInputMessages(), and startStop().

◆ m_running

volatile bool LocalSourceThread::m_running
private

Definition at line 69 of file localsourcethread.h.

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

◆ m_sampleFifo

SampleSourceFifo* LocalSourceThread::m_sampleFifo
private

Definition at line 70 of file localsourcethread.h.

Referenced by pullSamples(), and setSampleFifo().

◆ m_startWaiter

QWaitCondition LocalSourceThread::m_startWaiter
private

Definition at line 68 of file localsourcethread.h.

Referenced by run(), and startWork().

◆ m_startWaitMutex

QMutex LocalSourceThread::m_startWaitMutex
private

Definition at line 67 of file localsourcethread.h.

Referenced by startWork().


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