diff --git a/include/dsp/dspcommands.h b/include/dsp/dspcommands.h index 094c584cc..a3140ea8e 100644 --- a/include/dsp/dspcommands.h +++ b/include/dsp/dspcommands.h @@ -28,10 +28,6 @@ class SampleSink; class ThreadedSampleSink; class AudioFifo; -class SDRANGEL_API DSPPing : public Message { - MESSAGE_CLASS_DECLARATION -}; - class SDRANGEL_API DSPExit : public Message { MESSAGE_CLASS_DECLARATION }; diff --git a/include/dsp/samplefifo.h b/include/dsp/samplefifo.h index 58eac0596..f2cfe1648 100644 --- a/include/dsp/samplefifo.h +++ b/include/dsp/samplefifo.h @@ -48,7 +48,7 @@ public: bool setSize(int size); inline uint size() const { return m_size; } - inline uint fill() const { return m_fill; } + inline uint fill() { QMutexLocker mutexLocker(&m_mutex); uint fill = m_fill; return fill; } uint write(const quint8* data, uint count); uint write(SampleVector::const_iterator begin, SampleVector::const_iterator end); diff --git a/plugins/samplesource/hackrf/hackrfinput.cpp b/plugins/samplesource/hackrf/hackrfinput.cpp index 74b27bb8c..fefbb1084 100644 --- a/plugins/samplesource/hackrf/hackrfinput.cpp +++ b/plugins/samplesource/hackrf/hackrfinput.cpp @@ -83,12 +83,12 @@ bool HackRFInput::start(int device) return false; } - m_hackRFThread->startWork(); - mutexLocker.unlock(); applySettings(m_settings, true); + m_hackRFThread->startWork(); + qDebug("HackRFInput::startInput: started"); return true; diff --git a/plugins/samplesource/hackrf/hackrfthread.cpp b/plugins/samplesource/hackrf/hackrfthread.cpp index 92045146a..96089860b 100644 --- a/plugins/samplesource/hackrf/hackrfthread.cpp +++ b/plugins/samplesource/hackrf/hackrfthread.cpp @@ -43,16 +43,18 @@ HackRFThread::~HackRFThread() void HackRFThread::startWork() { - m_startWaitMutex.lock(); + //m_startWaitMutex.lock(); + m_running = true; start(); + /* while(!m_running) m_startWaiter.wait(&m_startWaitMutex, 100); - m_startWaitMutex.unlock(); + m_startWaitMutex.unlock();*/ } void HackRFThread::stopWork() { - qDebug("AirspyThread::stopWork"); + qDebug("HackRFThread::stopWork"); m_running = false; wait(); } @@ -76,7 +78,7 @@ void HackRFThread::run() { hackrf_error rc; - m_running = true; + //m_running = true; m_startWaiter.wakeAll(); rc = (hackrf_error) hackrf_start_rx(m_dev, rx_callback, NULL); @@ -104,7 +106,7 @@ void HackRFThread::run() qDebug("HackRFThread::run: failed to stop HackRF Rx: %s", hackrf_error_name(rc)); } - m_running = false; + //m_running = false; } // Decimate according to specified log2 (ex: log2=4 => decim=16) diff --git a/sdrbase/dsp/dspcommands.cpp b/sdrbase/dsp/dspcommands.cpp index f6f8a19b4..e18487e33 100644 --- a/sdrbase/dsp/dspcommands.cpp +++ b/sdrbase/dsp/dspcommands.cpp @@ -17,7 +17,6 @@ #include "dsp/dspcommands.h" -MESSAGE_CLASS_DEFINITION(DSPPing, Message) MESSAGE_CLASS_DEFINITION(DSPExit, Message) MESSAGE_CLASS_DEFINITION(DSPAcquisitionInit, Message) MESSAGE_CLASS_DEFINITION(DSPAcquisitionStart, Message) diff --git a/sdrbase/dsp/dspdeviceengine.cpp b/sdrbase/dsp/dspdeviceengine.cpp index cd13e5092..2149c096f 100644 --- a/sdrbase/dsp/dspdeviceengine.cpp +++ b/sdrbase/dsp/dspdeviceengine.cpp @@ -41,6 +41,9 @@ DSPDeviceEngine::DSPDeviceEngine(QObject* parent) : m_qRange(1 << 16), m_imbalance(65536) { + connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection); + connect(&m_syncMessenger, SIGNAL(messageSent()), this, SLOT(handleSynchronousMessages()), Qt::QueuedConnection); + moveToThread(this); } @@ -53,21 +56,16 @@ void DSPDeviceEngine::run() { qDebug() << "DSPDeviceEngine::run"; - connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection); - connect(&m_syncMessenger, SIGNAL(messageSent()), this, SLOT(handleSynchronousMessages()), Qt::QueuedConnection); - m_state = StIdle; - m_syncMessenger.done(); // Release start() that is waiting in main trhead + m_syncMessenger.done(); // Release start() that is waiting in main thread exec(); } void DSPDeviceEngine::start() { qDebug() << "DSPDeviceEngine::start"; - DSPPing cmd; QThread::start(); - m_syncMessenger.sendWait(cmd); } void DSPDeviceEngine::stop()