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

#include <localsinkthread.h>

Inherits QThread.

+ Collaboration diagram for LocalSinkThread:

Classes

class  MsgStartStop
 

Public Slots

void processSamples (const quint8 *data, uint count)
 

Public Member Functions

 LocalSinkThread (QObject *parent=0)
 
 ~LocalSinkThread ()
 
void startStop (bool start)
 
void setSampleFifo (SampleSinkFifo *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
 
SampleSinkFifom_sampleFifo
 
MessageQueue m_inputMessageQueue
 

Detailed Description

Definition at line 31 of file localsinkthread.h.

Constructor & Destructor Documentation

◆ LocalSinkThread()

LocalSinkThread::LocalSinkThread ( QObject *  parent = 0)

Definition at line 24 of file localsinkthread.cpp.

Referenced by LocalSinkThread::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 }
SampleSinkFifo * m_sampleFifo
MessageQueue m_inputMessageQueue
volatile bool m_running
+ Here is the caller graph for this function:

◆ ~LocalSinkThread()

LocalSinkThread::~LocalSinkThread ( )

Definition at line 32 of file localsinkthread.cpp.

Referenced by LocalSinkThread::MsgStartStop::MsgStartStop().

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

Member Function Documentation

◆ handleInputMessages

void LocalSinkThread::handleInputMessages ( )
privateslot

Definition at line 82 of file localsinkthread.cpp.

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

83 {
84  Message* message;
85 
86  while ((message = m_inputMessageQueue.pop()) != 0)
87  {
88  if (MsgStartStop::match(*message))
89  {
90  MsgStartStop* notif = (MsgStartStop*) message;
91  qDebug("LocalSinkThread::handleInputMessages: MsgStartStop: %s", notif->getStartStop() ? "start" : "stop");
92 
93  if (notif->getStartStop()) {
94  startWork();
95  } else {
96  stopWork();
97  }
98 
99  delete message;
100  }
101  }
102 }
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:

◆ processSamples

void LocalSinkThread::processSamples ( const quint8 *  data,
uint  count 
)
slot

Definition at line 75 of file localsinkthread.cpp.

References m_sampleFifo, and SampleSinkFifo::write().

Referenced by setSampleFifo().

76 {
77  if (m_sampleFifo) {
78  m_sampleFifo->write(data, count);
79  }
80 }
SampleSinkFifo * m_sampleFifo
uint write(const quint8 *data, uint count)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

void LocalSinkThread::run ( )
private

Definition at line 60 of file localsinkthread.cpp.

References m_running, and m_startWaiter.

61 {
62  qDebug("LocalSinkThread::run: begin");
63  m_running = true;
64  m_startWaiter.wakeAll();
65 
66  while (m_running)
67  {
68  sleep(1); // Do nothing as everything is in the data handler (dequeuer)
69  }
70 
71  m_running = false;
72  qDebug("LocalSinkThread::run: end");
73 }
QWaitCondition m_startWaiter
volatile bool m_running

◆ setSampleFifo()

void LocalSinkThread::setSampleFifo ( SampleSinkFifo sampleFifo)
inline

Definition at line 58 of file localsinkthread.h.

References m_sampleFifo, and processSamples().

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

58 { m_sampleFifo = sampleFifo; }
SampleSinkFifo * m_sampleFifo
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startStop()

void LocalSinkThread::startStop ( bool  start)

Definition at line 37 of file localsinkthread.cpp.

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

Referenced by LocalSinkThread::MsgStartStop::MsgStartStop(), LocalSink::start(), and LocalSink::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 LocalSinkThread::startWork ( )
private

Definition at line 43 of file localsinkthread.cpp.

References m_running, m_startWaiter, and m_startWaitMutex.

Referenced by handleInputMessages().

44 {
45  qDebug("LocalSinkThread::startWork");
46  m_startWaitMutex.lock();
47  start();
48  while(!m_running)
49  m_startWaiter.wait(&m_startWaitMutex, 100);
50  m_startWaitMutex.unlock();
51 }
QWaitCondition m_startWaiter
volatile bool m_running
+ Here is the caller graph for this function:

◆ stopWork()

void LocalSinkThread::stopWork ( )
private

Definition at line 53 of file localsinkthread.cpp.

References m_running.

Referenced by handleInputMessages().

54 {
55  qDebug("LocalSinkThread::stopWork");
56  m_running = false;
57  wait();
58 }
volatile bool m_running
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_inputMessageQueue

MessageQueue LocalSinkThread::m_inputMessageQueue
private

Definition at line 69 of file localsinkthread.h.

Referenced by handleInputMessages(), and startStop().

◆ m_running

volatile bool LocalSinkThread::m_running
private

Definition at line 66 of file localsinkthread.h.

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

◆ m_sampleFifo

SampleSinkFifo* LocalSinkThread::m_sampleFifo
private

Definition at line 67 of file localsinkthread.h.

Referenced by processSamples(), and setSampleFifo().

◆ m_startWaiter

QWaitCondition LocalSinkThread::m_startWaiter
private

Definition at line 65 of file localsinkthread.h.

Referenced by run(), and startWork().

◆ m_startWaitMutex

QMutex LocalSinkThread::m_startWaitMutex
private

Definition at line 64 of file localsinkthread.h.

Referenced by startWork().


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