mirror of https://github.com/f4exb/sdrangel.git
DV serial: alternate timeout handling. Primitives to get information about worker status
This commit is contained in:
parent
32595f81b9
commit
13e832a20e
|
@ -199,7 +199,6 @@ bool DVSerialEngine::scan()
|
||||||
connect(controller.worker, SIGNAL(finished()), controller.worker, SLOT(deleteLater()));
|
connect(controller.worker, SIGNAL(finished()), controller.worker, SLOT(deleteLater()));
|
||||||
connect(controller.thread, SIGNAL(finished()), controller.thread, SLOT(deleteLater()));
|
connect(controller.thread, SIGNAL(finished()), controller.thread, SLOT(deleteLater()));
|
||||||
connect(&controller.worker->m_inputMessageQueue, SIGNAL(messageEnqueued()), controller.worker, SLOT(handleInputMessages()));
|
connect(&controller.worker->m_inputMessageQueue, SIGNAL(messageEnqueued()), controller.worker, SLOT(handleInputMessages()));
|
||||||
connect(controller.worker->m_timer, SIGNAL(timeout()), controller.worker, SLOT(releaseQueue()));
|
|
||||||
controller.thread->start();
|
controller.thread->start();
|
||||||
|
|
||||||
m_controllers.push_back(controller);
|
m_controllers.push_back(controller);
|
||||||
|
@ -255,12 +254,12 @@ void DVSerialEngine::pushMbeFrame(const unsigned char *mbeFrame, int mbeRateInde
|
||||||
|
|
||||||
while (it != m_controllers.end())
|
while (it != m_controllers.end())
|
||||||
{
|
{
|
||||||
if (it->worker->m_audioFifo == audioFifo)
|
if (it->worker->hasFifo(audioFifo))
|
||||||
{
|
{
|
||||||
it->worker->pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, audioFifo);
|
it->worker->pushMbeFrame(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, audioFifo);
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
else if (it->worker->m_audioFifo == 0)
|
else if (it->worker->isAvailable())
|
||||||
{
|
{
|
||||||
itAvail = it;
|
itAvail = it;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,10 @@ DVSerialWorker::DVSerialWorker() :
|
||||||
m_audioBuffer.resize(48000);
|
m_audioBuffer.resize(48000);
|
||||||
m_audioBufferFill = 0;
|
m_audioBufferFill = 0;
|
||||||
m_audioFifo = 0;
|
m_audioFifo = 0;
|
||||||
m_timer = new QTimer(this);
|
|
||||||
m_timer->setSingleShot(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DVSerialWorker::~DVSerialWorker()
|
DVSerialWorker::~DVSerialWorker()
|
||||||
{
|
{
|
||||||
delete m_timer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DVSerialWorker::open(const std::string& serialDevice)
|
bool DVSerialWorker::open(const std::string& serialDevice)
|
||||||
|
@ -73,7 +70,6 @@ void DVSerialWorker::stop()
|
||||||
|
|
||||||
void DVSerialWorker::handleInputMessages()
|
void DVSerialWorker::handleInputMessages()
|
||||||
{
|
{
|
||||||
m_timer->stop(); // suspend FIFO queue holding timeout
|
|
||||||
Message* message;
|
Message* message;
|
||||||
m_audioBufferFill = 0;
|
m_audioBufferFill = 0;
|
||||||
AudioFifo *audioFifo = 0;
|
AudioFifo *audioFifo = 0;
|
||||||
|
@ -109,7 +105,7 @@ void DVSerialWorker::handleInputMessages()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_timer->start(1000); // FIFO queue holding timeout
|
m_timestamp = QDateTime::currentDateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVSerialWorker::pushMbeFrame(const unsigned char *mbeFrame,
|
void DVSerialWorker::pushMbeFrame(const unsigned char *mbeFrame,
|
||||||
|
@ -121,10 +117,18 @@ void DVSerialWorker::pushMbeFrame(const unsigned char *mbeFrame,
|
||||||
m_inputMessageQueue.push(MsgMbeDecode::create(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, audioFifo));
|
m_inputMessageQueue.push(MsgMbeDecode::create(mbeFrame, mbeRateIndex, mbeVolumeIndex, channels, audioFifo));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVSerialWorker::releaseQueue()
|
bool DVSerialWorker::isAvailable()
|
||||||
{
|
{
|
||||||
qDebug("DVSerialWorker::releaseQueue: release %p", m_audioFifo);
|
if (m_audioFifo == 0) {
|
||||||
m_audioFifo = 0;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_timestamp.time().msecsTo(QDateTime::currentDateTime().time()) > 1000; // 1 second inactivity timeout
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DVSerialWorker::hasFifo(AudioFifo *audioFifo)
|
||||||
|
{
|
||||||
|
return m_audioFifo == audioFifo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DVSerialWorker::upsample6(short *in, int nbSamplesIn, unsigned char channels, AudioFifo *audioFifo)
|
void DVSerialWorker::upsample6(short *in, int nbSamplesIn, unsigned char channels, AudioFifo *audioFifo)
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -94,6 +95,8 @@ public:
|
||||||
void close();
|
void close();
|
||||||
void process();
|
void process();
|
||||||
void stop();
|
void stop();
|
||||||
|
bool isAvailable();
|
||||||
|
bool hasFifo(AudioFifo *audioFifo);
|
||||||
|
|
||||||
void postTest()
|
void postTest()
|
||||||
{
|
{
|
||||||
|
@ -103,14 +106,13 @@ public:
|
||||||
|
|
||||||
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
|
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
|
||||||
AudioFifo *m_audioFifo;
|
AudioFifo *m_audioFifo;
|
||||||
QTimer *m_timer;
|
QDateTime m_timestamp;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void handleInputMessages();
|
void handleInputMessages();
|
||||||
void releaseQueue();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct AudioSample {
|
struct AudioSample {
|
||||||
|
|
Loading…
Reference in New Issue