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.
threadedbasebandsamplesource.cpp
Go to the documentation of this file.
1 // Copyright (C) 2016 F4EXB //
3 // written by Edouard Griffiths //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #include <QDebug>
20 #include <QThread>
21 
23 
25  m_basebandSampleSource(sampleSource)
26 {
27  QString name = "ThreadedBasebandSampleSource(" + m_basebandSampleSource->objectName() + ")";
28  setObjectName(name);
29 
30  qDebug() << "ThreadedBasebandSampleSource::ThreadedBasebandSampleSource: " << name;
31 
32  m_thread = new QThread(parent);
33  m_basebandSampleSource->moveToThread(m_thread);
34 
35  qDebug() << "ThreadedBasebandSampleSource::ThreadedBasebandSampleSource: thread: " << thread() << " m_thread: " << m_thread;
36 }
37 
39 {
40  if (m_thread->isRunning()) {
41  stop();
42  }
43 
44  delete m_thread;
45 }
46 
48 {
49  qDebug() << "ThreadedBasebandSampleSource::start";
50  m_thread->start();
52 }
53 
55 {
56  qDebug() << "ThreadedBasebandSampleSource::stop";
58  m_thread->exit();
59  m_thread->wait();
60 }
61 
63 {
65 }
66 
68  int nbSamples)
69 {
70  m_basebandSampleSource->feed(sampleFifo, nbSamples);
71 }
72 
74 {
76 }
77 
79 {
80  return m_basebandSampleSource->objectName();
81 }
BasebandSampleSource * m_basebandSampleSource
virtual bool handleMessage(const Message &cmd)=0
Processing of a message. Returns true if message has actually been processed.
virtual void stop()=0
ThreadedBasebandSampleSource(BasebandSampleSource *sampleSource, QObject *parent=0)
virtual void start()=0
virtual void pull(Sample &sample)=0
void feed(SampleSourceFifo *sampleFifo, int nbSamples)
void stop()
this thread exit() and wait()
QThread * m_thread
The thead object.
void pull(Sample &sample)
Pull one sample from source.
void feed(SampleSourceFifo *sampleFifo, int nbSamples)
bool handleSourceMessage(const Message &cmd)
Send message to source synchronously.