mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-23 18:52:28 -04:00
TestSource: moved thread start and quit/wait to start and stop methods respectively
This commit is contained in:
parent
59127ea4e2
commit
1c75f8d326
@ -47,13 +47,6 @@ TestSourceInput::TestSourceInput(DeviceAPI *deviceAPI) :
|
|||||||
m_sampleFifo.setLabel(m_deviceDescription);
|
m_sampleFifo.setLabel(m_deviceDescription);
|
||||||
m_deviceAPI->setNbSourceStreams(1);
|
m_deviceAPI->setNbSourceStreams(1);
|
||||||
|
|
||||||
if (!m_sampleFifo.setSize(96000 * 4)) {
|
|
||||||
qCritical("TestSourceInput::TestSourceInput: Could not allocate SampleFifo");
|
|
||||||
}
|
|
||||||
|
|
||||||
m_testSourceWorker = new TestSourceWorker(&m_sampleFifo);
|
|
||||||
m_testSourceWorker->moveToThread(&m_testSourceWorkerThread);
|
|
||||||
|
|
||||||
m_networkManager = new QNetworkAccessManager();
|
m_networkManager = new QNetworkAccessManager();
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
m_networkManager,
|
m_networkManager,
|
||||||
@ -76,8 +69,6 @@ TestSourceInput::~TestSourceInput()
|
|||||||
if (m_running) {
|
if (m_running) {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_testSourceWorker->deleteLater();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestSourceInput::destroy()
|
void TestSourceInput::destroy()
|
||||||
@ -98,13 +89,22 @@ bool TestSourceInput::start()
|
|||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_sampleFifo.setSize(96000 * 4))
|
||||||
|
{
|
||||||
|
qCritical("TestSourceInput::TestSourceInput: Could not allocate SampleFifo");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_testSourceWorker = new TestSourceWorker(&m_sampleFifo);
|
||||||
|
m_testSourceWorker->moveToThread(&m_testSourceWorkerThread);
|
||||||
m_testSourceWorker->setSamplerate(m_settings.m_sampleRate);
|
m_testSourceWorker->setSamplerate(m_settings.m_sampleRate);
|
||||||
startWorker();
|
m_testSourceWorker->startWork();
|
||||||
|
m_testSourceWorkerThread.start();
|
||||||
|
m_running = true;
|
||||||
|
|
||||||
mutexLocker.unlock();
|
mutexLocker.unlock();
|
||||||
|
|
||||||
applySettings(m_settings, true);
|
applySettings(m_settings, true);
|
||||||
m_running = true;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -112,24 +112,18 @@ bool TestSourceInput::start()
|
|||||||
void TestSourceInput::stop()
|
void TestSourceInput::stop()
|
||||||
{
|
{
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
stopWorker();
|
m_running = false;
|
||||||
m_running = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestSourceInput::startWorker()
|
if (m_testSourceWorker)
|
||||||
{
|
{
|
||||||
m_testSourceWorker->startWork();
|
m_testSourceWorker->stopWork();
|
||||||
m_testSourceWorkerThread.start();
|
m_testSourceWorkerThread.quit();
|
||||||
|
m_testSourceWorkerThread.wait();
|
||||||
|
delete m_testSourceWorker;
|
||||||
|
m_testSourceWorker = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestSourceInput::stopWorker()
|
|
||||||
{
|
|
||||||
m_testSourceWorker->stopWork();
|
|
||||||
m_testSourceWorkerThread.quit();
|
|
||||||
m_testSourceWorkerThread.wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QByteArray TestSourceInput::serialize() const
|
QByteArray TestSourceInput::serialize() const
|
||||||
{
|
{
|
||||||
return m_settings.serialize();
|
return m_settings.serialize();
|
||||||
|
@ -137,8 +137,6 @@ private:
|
|||||||
QNetworkAccessManager *m_networkManager;
|
QNetworkAccessManager *m_networkManager;
|
||||||
QNetworkRequest m_networkRequest;
|
QNetworkRequest m_networkRequest;
|
||||||
|
|
||||||
void startWorker();
|
|
||||||
void stopWorker();
|
|
||||||
bool applySettings(const TestSourceSettings& settings, bool force);
|
bool applySettings(const TestSourceSettings& settings, bool force);
|
||||||
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const TestSourceSettings& settings, bool force);
|
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const TestSourceSettings& settings, bool force);
|
||||||
void webapiReverseSendStartStop(bool start);
|
void webapiReverseSendStartStop(bool start);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user