mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-09-27 15:26:33 -04:00
Attempt at fixing some race conditions #1
This commit is contained in:
parent
2f9dd5a7ab
commit
35440d60f6
@ -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
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user