Browse Source

Use BuddiesMutex, as buddies can change on both engine thread and GUI thread.

chirpmodem-v8.0.0
Jon Beniston 2 months ago
parent
commit
a4ca266bb6
  1. 5
      plugins/samplesink/bladerf1output/bladerf1output.cpp
  2. 9
      plugins/samplesink/bladerf2output/bladerf2output.cpp
  3. 13
      plugins/samplesink/hackrfoutput/hackrfoutput.cpp
  4. 8
      plugins/samplesink/limesdroutput/limesdroutput.cpp
  5. 9
      plugins/samplesink/plutosdroutput/plutosdroutput.cpp
  6. 9
      plugins/samplesink/soapysdroutput/soapysdroutput.cpp
  7. 8
      plugins/samplesink/xtrxoutput/xtrxoutput.cpp
  8. 5
      plugins/samplesource/bladerf1input/bladerf1input.cpp
  9. 9
      plugins/samplesource/bladerf2input/bladerf2input.cpp
  10. 13
      plugins/samplesource/hackrfinput/hackrfinput.cpp
  11. 8
      plugins/samplesource/limesdrinput/limesdrinput.cpp
  12. 9
      plugins/samplesource/plutosdrinput/plutosdrinput.cpp
  13. 9
      plugins/samplesource/soapysdrinput/soapysdrinput.cpp
  14. 8
      plugins/samplesource/xtrxinput/xtrxinput.cpp

5
plugins/samplesink/bladerf1output/bladerf1output.cpp

@ -392,6 +392,9 @@ bool Bladerf1Output::applySettings(const BladeRF1OutputSettings& settings, const @@ -392,6 +392,9 @@ bool Bladerf1Output::applySettings(const BladeRF1OutputSettings& settings, const
{
bool changeSettings;
// Buddy lists can be changed in the GUI thread, but this is also called from start() in the device engine thread
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
if (!m_deviceAPI->getSourceBuddies().empty())
{
DeviceAPI *buddy = m_deviceAPI->getSourceBuddies()[0];
@ -407,6 +410,8 @@ bool Bladerf1Output::applySettings(const BladeRF1OutputSettings& settings, const @@ -407,6 +410,8 @@ bool Bladerf1Output::applySettings(const BladeRF1OutputSettings& settings, const
changeSettings = true;
}
buddiesLocker.unlock();
if (changeSettings)
{
if (settings.m_xb200)

9
plugins/samplesink/bladerf2output/bladerf2output.cpp

@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
#include <errno.h>
#include <QDebug>
#include <QMutexLocker>
#include <QNetworkReply>
#include <QBuffer>
@ -238,6 +239,10 @@ void BladeRF2Output::moveThreadToBuddy() @@ -238,6 +239,10 @@ void BladeRF2Output::moveThreadToBuddy()
bool BladeRF2Output::start()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
// There is a single thread per physical device (Tx side). This thread is unique and referenced by a unique
// buddy in the group of sink buddies associated with this physical device.
//
@ -366,6 +371,10 @@ bool BladeRF2Output::start() @@ -366,6 +371,10 @@ bool BladeRF2Output::start()
void BladeRF2Output::stop()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
// This stop method is responsible for managing the thread and channel disabling when the streaming of
// a Tx channel is stopped
//

13
plugins/samplesink/hackrfoutput/hackrfoutput.cpp

@ -388,11 +388,16 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, const QLi @@ -388,11 +388,16 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, const QLi
}
}
if (m_deviceAPI->getSourceBuddies().size() > 0)
{
DeviceAPI *buddy = m_deviceAPI->getSourceBuddies()[0];
DeviceHackRFShared::MsgSynchronizeSampleRate *sampleRateMsg = DeviceHackRFShared::MsgSynchronizeSampleRate::create(settings.m_devSampleRate);
buddy->getSamplingDeviceInputMessageQueue()->push(sampleRateMsg);
// Buddy lists can be changed in the GUI thread, but this is also called from start() in the device engine thread
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
if (m_deviceAPI->getSourceBuddies().size() > 0)
{
DeviceAPI *buddy = m_deviceAPI->getSourceBuddies()[0];
DeviceHackRFShared::MsgSynchronizeSampleRate *sampleRateMsg = DeviceHackRFShared::MsgSynchronizeSampleRate::create(settings.m_devSampleRate);
buddy->getSamplingDeviceInputMessageQueue()->push(sampleRateMsg);
}
}
}

8
plugins/samplesink/limesdroutput/limesdroutput.cpp

@ -380,6 +380,10 @@ void LimeSDROutput::init() @@ -380,6 +380,10 @@ void LimeSDROutput::init()
bool LimeSDROutput::start()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
QMutexLocker mutexLocker(&m_mutex);
if (m_running) {
@ -412,6 +416,10 @@ bool LimeSDROutput::start() @@ -412,6 +416,10 @@ bool LimeSDROutput::start()
void LimeSDROutput::stop()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
if (!m_running) {
return;
}

9
plugins/samplesink/plutosdroutput/plutosdroutput.cpp

@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <QMutexLocker>
#include <QNetworkReply>
#include <QBuffer>
@ -102,6 +103,10 @@ void PlutoSDROutput::init() @@ -102,6 +103,10 @@ void PlutoSDROutput::init()
bool PlutoSDROutput::start()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
QMutexLocker mutexLocker(&m_mutex);
if (m_running) {
@ -141,6 +146,10 @@ bool PlutoSDROutput::start() @@ -141,6 +146,10 @@ bool PlutoSDROutput::start()
void PlutoSDROutput::stop()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
QMutexLocker mutexLocker(&m_mutex);
if (!m_running) {

9
plugins/samplesink/soapysdroutput/soapysdroutput.cpp

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <QMutexLocker>
#include <QNetworkReply>
#include <QBuffer>
@ -424,6 +425,10 @@ void SoapySDROutput::moveThreadToBuddy() @@ -424,6 +425,10 @@ void SoapySDROutput::moveThreadToBuddy()
bool SoapySDROutput::start()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
// There is a single thread per physical device (Tx side). This thread is unique and referenced by a unique
// buddy in the group of sink buddies associated with this physical device.
//
@ -570,6 +575,10 @@ bool SoapySDROutput::start() @@ -570,6 +575,10 @@ bool SoapySDROutput::start()
void SoapySDROutput::stop()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
// This stop method is responsible for managing the thread and channel disabling when the streaming of
// a Tx channel is stopped
//

8
plugins/samplesink/xtrxoutput/xtrxoutput.cpp

@ -242,6 +242,10 @@ void XTRXOutput::moveThreadToBuddy() @@ -242,6 +242,10 @@ void XTRXOutput::moveThreadToBuddy()
bool XTRXOutput::start()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
// There is a single thread per physical device (Tx side). This thread is unique and referenced by a unique
// buddy in the group of sink buddies associated with this physical device.
//
@ -364,6 +368,10 @@ bool XTRXOutput::start() @@ -364,6 +368,10 @@ bool XTRXOutput::start()
void XTRXOutput::stop()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
// This stop method is responsible for managing the thread when the streaming of a Rx channel is stopped
//
// If the thread is currently managing only one channel (SO mode). The thread can be just stopped and deleted.

5
plugins/samplesource/bladerf1input/bladerf1input.cpp

@ -365,6 +365,9 @@ bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, const Q @@ -365,6 +365,9 @@ bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, const Q
{
bool changeSettings;
// Buddy lists can be changed in the GUI thread, but this is also called from start() in the device engine thread
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
if (!m_deviceAPI->getSinkBuddies().empty())
{
DeviceAPI *buddy = m_deviceAPI->getSinkBuddies()[0];
@ -380,6 +383,8 @@ bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, const Q @@ -380,6 +383,8 @@ bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, const Q
changeSettings = true;
}
buddiesLocker.unlock();
if (changeSettings)
{
if (settings.m_xb200)

9
plugins/samplesource/bladerf2input/bladerf2input.cpp

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <QMutexLocker>
#include <QNetworkReply>
#include <QBuffer>
@ -261,6 +262,10 @@ void BladeRF2Input::moveThreadToBuddy() @@ -261,6 +262,10 @@ void BladeRF2Input::moveThreadToBuddy()
bool BladeRF2Input::start()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
// There is a single thread per physical device (Rx side). This thread is unique and referenced by a unique
// buddy in the group of source buddies associated with this physical device.
//
@ -399,6 +404,10 @@ bool BladeRF2Input::start() @@ -399,6 +404,10 @@ bool BladeRF2Input::start()
void BladeRF2Input::stop()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
// This stop method is responsible for managing the thread and channel disabling when the streaming of
// a Rx channel is stopped
//

13
plugins/samplesource/hackrfinput/hackrfinput.cpp

@ -378,11 +378,16 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, const QList @@ -378,11 +378,16 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, const QList
}
}
if (m_deviceAPI->getSourceBuddies().size() > 0)
{
DeviceAPI *buddy = m_deviceAPI->getSourceBuddies()[0];
DeviceHackRFShared::MsgSynchronizeSampleRate *sampleRateMsg = DeviceHackRFShared::MsgSynchronizeSampleRate::create(settings.m_devSampleRate);
buddy->getSamplingDeviceInputMessageQueue()->push(sampleRateMsg);
// Buddy lists can be changed in the GUI thread, but this is also called from start() in the device engine thread
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
if (m_deviceAPI->getSourceBuddies().size() > 0)
{
DeviceAPI *buddy = m_deviceAPI->getSourceBuddies()[0];
DeviceHackRFShared::MsgSynchronizeSampleRate *sampleRateMsg = DeviceHackRFShared::MsgSynchronizeSampleRate::create(settings.m_devSampleRate);
buddy->getSamplingDeviceInputMessageQueue()->push(sampleRateMsg);
}
}
}

8
plugins/samplesource/limesdrinput/limesdrinput.cpp

@ -409,6 +409,10 @@ void LimeSDRInput::init() @@ -409,6 +409,10 @@ void LimeSDRInput::init()
bool LimeSDRInput::start()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
QMutexLocker mutexLocker(&m_mutex);
if (m_running) {
@ -442,6 +446,10 @@ bool LimeSDRInput::start() @@ -442,6 +446,10 @@ bool LimeSDRInput::start()
void LimeSDRInput::stop()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
QMutexLocker mutexLocker(&m_mutex);
if (!m_running) {

9
plugins/samplesource/plutosdrinput/plutosdrinput.cpp

@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <QMutexLocker>
#include <QNetworkReply>
#include <QBuffer>
@ -102,6 +103,10 @@ void PlutoSDRInput::init() @@ -102,6 +103,10 @@ void PlutoSDRInput::init()
bool PlutoSDRInput::start()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
QMutexLocker mutexLocker(&m_mutex);
if (m_running) {
@ -142,6 +147,10 @@ bool PlutoSDRInput::start() @@ -142,6 +147,10 @@ bool PlutoSDRInput::start()
void PlutoSDRInput::stop()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
QMutexLocker mutexLocker(&m_mutex);
if (!m_running) {

9
plugins/samplesource/soapysdrinput/soapysdrinput.cpp

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <QMutexLocker>
#include <QNetworkReply>
#include <QBuffer>
@ -448,6 +449,10 @@ void SoapySDRInput::moveThreadToBuddy() @@ -448,6 +449,10 @@ void SoapySDRInput::moveThreadToBuddy()
bool SoapySDRInput::start()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
// There is a single thread per physical device (Rx side). This thread is unique and referenced by a unique
// buddy in the group of source buddies associated with this physical device.
//
@ -582,6 +587,10 @@ bool SoapySDRInput::start() @@ -582,6 +587,10 @@ bool SoapySDRInput::start()
void SoapySDRInput::stop()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
// This stop method is responsible for managing the thread and channel disabling when the streaming of
// a Rx channel is stopped
//

8
plugins/samplesource/xtrxinput/xtrxinput.cpp

@ -252,6 +252,10 @@ void XTRXInput::moveThreadToBuddy() @@ -252,6 +252,10 @@ void XTRXInput::moveThreadToBuddy()
bool XTRXInput::start()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
// There is a single thread per physical device (Rx side). This thread is unique and referenced by a unique
// buddy in the group of source buddies associated with this physical device.
//
@ -375,6 +379,10 @@ bool XTRXInput::start() @@ -375,6 +379,10 @@ bool XTRXInput::start()
void XTRXInput::stop()
{
// Buddy lists can be changed in the GUI thread, but are accessed here (and in functions called from here)
// in the device engine thread. Lock before any of our own mutexes, to keep a consistent lock order.
QMutexLocker buddiesLocker(&DeviceAPI::getBuddiesMutex());
// This stop method is responsible for managing the thread when the streaming of a Rx channel is stopped
//
// If the thread is currently managing only one channel (SI mode). The thread can be just stopped and deleted.

Loading…
Cancel
Save