mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-10 10:33:29 -05:00
ATV Demod: applied now threading model
This commit is contained in:
parent
a2a584440c
commit
596d2ef149
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QThread>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <complex.h>
|
#include <complex.h>
|
||||||
@ -42,9 +41,8 @@ ATVDemod::ATVDemod(DeviceAPI *deviceAPI) :
|
|||||||
qDebug("ATVDemod::ATVDemod");
|
qDebug("ATVDemod::ATVDemod");
|
||||||
setObjectName(m_channelId);
|
setObjectName(m_channelId);
|
||||||
|
|
||||||
m_thread = new QThread(this);
|
|
||||||
m_basebandSink = new ATVDemodBaseband();
|
m_basebandSink = new ATVDemodBaseband();
|
||||||
m_basebandSink->moveToThread(m_thread);
|
m_basebandSink->moveToThread(&m_thread);
|
||||||
|
|
||||||
applySettings(m_settings, true);
|
applySettings(m_settings, true);
|
||||||
|
|
||||||
@ -57,8 +55,12 @@ ATVDemod::~ATVDemod()
|
|||||||
qDebug("ATVDemod::~ATVDemod");
|
qDebug("ATVDemod::~ATVDemod");
|
||||||
m_deviceAPI->removeChannelSinkAPI(this);
|
m_deviceAPI->removeChannelSinkAPI(this);
|
||||||
m_deviceAPI->removeChannelSink(this);
|
m_deviceAPI->removeChannelSink(this);
|
||||||
|
|
||||||
|
if (m_basebandSink->isRunning()) {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
delete m_basebandSink;
|
delete m_basebandSink;
|
||||||
delete m_thread;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATVDemod::start()
|
void ATVDemod::start()
|
||||||
@ -66,7 +68,8 @@ void ATVDemod::start()
|
|||||||
qDebug("ATVDemod::start");
|
qDebug("ATVDemod::start");
|
||||||
|
|
||||||
m_basebandSink->reset();
|
m_basebandSink->reset();
|
||||||
m_thread->start();
|
m_basebandSink->startWork();
|
||||||
|
m_thread.start();
|
||||||
|
|
||||||
// re-apply essential messages
|
// re-apply essential messages
|
||||||
|
|
||||||
@ -80,8 +83,9 @@ void ATVDemod::start()
|
|||||||
void ATVDemod::stop()
|
void ATVDemod::stop()
|
||||||
{
|
{
|
||||||
qDebug("ATVDemod::stop");
|
qDebug("ATVDemod::stop");
|
||||||
m_thread->exit();
|
m_basebandSink->stopWork();
|
||||||
m_thread->wait();
|
m_thread.exit();
|
||||||
|
m_thread.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst)
|
void ATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst)
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#define INCLUDE_ATVDEMOD_H
|
#define INCLUDE_ATVDEMOD_H
|
||||||
|
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
|
#include <QThread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "dsp/basebandsamplesink.h"
|
#include "dsp/basebandsamplesink.h"
|
||||||
@ -30,7 +31,6 @@
|
|||||||
|
|
||||||
#include "atvdemodbaseband.h"
|
#include "atvdemodbaseband.h"
|
||||||
|
|
||||||
class QThread;
|
|
||||||
class DeviceAPI;
|
class DeviceAPI;
|
||||||
|
|
||||||
class ATVDemod : public BasebandSampleSink, public ChannelAPI
|
class ATVDemod : public BasebandSampleSink, public ChannelAPI
|
||||||
@ -97,7 +97,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DeviceAPI* m_deviceAPI;
|
DeviceAPI* m_deviceAPI;
|
||||||
QThread *m_thread;
|
QThread m_thread;
|
||||||
ATVDemodBaseband* m_basebandSink;
|
ATVDemodBaseband* m_basebandSink;
|
||||||
ATVDemodSettings m_settings;
|
ATVDemodSettings m_settings;
|
||||||
qint64 m_centerFrequency; //!< center frequency stored from device message used when starting baseband sink
|
qint64 m_centerFrequency; //!< center frequency stored from device message used when starting baseband sink
|
||||||
|
@ -26,21 +26,12 @@
|
|||||||
MESSAGE_CLASS_DEFINITION(ATVDemodBaseband::MsgConfigureATVDemodBaseband, Message)
|
MESSAGE_CLASS_DEFINITION(ATVDemodBaseband::MsgConfigureATVDemodBaseband, Message)
|
||||||
|
|
||||||
ATVDemodBaseband::ATVDemodBaseband() :
|
ATVDemodBaseband::ATVDemodBaseband() :
|
||||||
|
m_running(false),
|
||||||
m_mutex(QMutex::Recursive)
|
m_mutex(QMutex::Recursive)
|
||||||
{
|
{
|
||||||
qDebug("ATVDemodBaseband::ATVDemodBaseband");
|
qDebug("ATVDemodBaseband::ATVDemodBaseband");
|
||||||
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000));
|
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000));
|
||||||
m_channelizer = new DownChannelizer(&m_sink);
|
m_channelizer = new DownChannelizer(&m_sink);
|
||||||
|
|
||||||
QObject::connect(
|
|
||||||
&m_sampleFifo,
|
|
||||||
&SampleSinkFifo::dataReady,
|
|
||||||
this,
|
|
||||||
&ATVDemodBaseband::handleData,
|
|
||||||
Qt::QueuedConnection
|
|
||||||
);
|
|
||||||
|
|
||||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ATVDemodBaseband::~ATVDemodBaseband()
|
ATVDemodBaseband::~ATVDemodBaseband()
|
||||||
@ -55,6 +46,34 @@ void ATVDemodBaseband::reset()
|
|||||||
m_sampleFifo.reset();
|
m_sampleFifo.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ATVDemodBaseband::startWork()
|
||||||
|
{
|
||||||
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
QObject::connect(
|
||||||
|
&m_sampleFifo,
|
||||||
|
&SampleSinkFifo::dataReady,
|
||||||
|
this,
|
||||||
|
&ATVDemodBaseband::handleData,
|
||||||
|
Qt::QueuedConnection
|
||||||
|
);
|
||||||
|
|
||||||
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
||||||
|
m_running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ATVDemodBaseband::stopWork()
|
||||||
|
{
|
||||||
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
||||||
|
QObject::disconnect(
|
||||||
|
&m_sampleFifo,
|
||||||
|
&SampleSinkFifo::dataReady,
|
||||||
|
this,
|
||||||
|
&ATVDemodBaseband::handleData
|
||||||
|
);
|
||||||
|
m_running = false;
|
||||||
|
}
|
||||||
|
|
||||||
void ATVDemodBaseband::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end)
|
void ATVDemodBaseband::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end)
|
||||||
{
|
{
|
||||||
m_sampleFifo.write(begin, end);
|
m_sampleFifo.write(begin, end);
|
||||||
|
@ -59,6 +59,8 @@ public:
|
|||||||
ATVDemodBaseband();
|
ATVDemodBaseband();
|
||||||
~ATVDemodBaseband();
|
~ATVDemodBaseband();
|
||||||
void reset();
|
void reset();
|
||||||
|
void startWork();
|
||||||
|
void stopWork();
|
||||||
void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
|
void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
|
||||||
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
|
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
|
||||||
int getChannelSampleRate() const;
|
int getChannelSampleRate() const;
|
||||||
@ -68,6 +70,7 @@ public:
|
|||||||
bool getBFOLocked() { return m_sink.getBFOLocked(); }
|
bool getBFOLocked() { return m_sink.getBFOLocked(); }
|
||||||
void setVideoTabIndex(int videoTabIndex) { m_sink.setVideoTabIndex(videoTabIndex); }
|
void setVideoTabIndex(int videoTabIndex) { m_sink.setVideoTabIndex(videoTabIndex); }
|
||||||
void setBasebandSampleRate(int sampleRate); //!< To be used when supporting thread is stopped
|
void setBasebandSampleRate(int sampleRate); //!< To be used when supporting thread is stopped
|
||||||
|
bool isRunning() const { return m_running; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SampleSinkFifo m_sampleFifo;
|
SampleSinkFifo m_sampleFifo;
|
||||||
@ -75,6 +78,7 @@ private:
|
|||||||
ATVDemodSink m_sink;
|
ATVDemodSink m_sink;
|
||||||
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
|
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
|
||||||
ATVDemodSettings m_settings;
|
ATVDemodSettings m_settings;
|
||||||
|
bool m_running;
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
|
|
||||||
bool handleMessage(const Message& cmd);
|
bool handleMessage(const Message& cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user