mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-16 13:21:50 -05:00
BladeRF plugins: fixed deadlock due to useless mutex and disable modules on stop
This commit is contained in:
parent
171ba7674e
commit
f1ac22576c
@ -54,7 +54,7 @@ bool BladerfOutput::init(const Message& cmd)
|
|||||||
|
|
||||||
bool BladerfOutput::start(int device)
|
bool BladerfOutput::start(int device)
|
||||||
{
|
{
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
// QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
|
||||||
if (m_dev != 0)
|
if (m_dev != 0)
|
||||||
{
|
{
|
||||||
@ -78,6 +78,8 @@ bool BladerfOutput::start(int device)
|
|||||||
|
|
||||||
if (buddy->getDeviceSourceEngine()->state() == DSPDeviceSourceEngine::StRunning) // Rx side is running so it must have device ownership
|
if (buddy->getDeviceSourceEngine()->state() == DSPDeviceSourceEngine::StRunning) // Rx side is running so it must have device ownership
|
||||||
{
|
{
|
||||||
|
qDebug("BladerfOutput::start: Rx side is running");
|
||||||
|
|
||||||
if ((m_dev = buddySharedParams->m_dev) == 0) // get device handle from Rx but do not take ownership
|
if ((m_dev = buddySharedParams->m_dev) == 0) // get device handle from Rx but do not take ownership
|
||||||
{
|
{
|
||||||
qCritical("BladerfOutput::start: could not get BladeRF handle from buddy");
|
qCritical("BladerfOutput::start: could not get BladeRF handle from buddy");
|
||||||
@ -86,6 +88,8 @@ bool BladerfOutput::start(int device)
|
|||||||
}
|
}
|
||||||
else // Rx is not running so Tx opens device and takes ownership
|
else // Rx is not running so Tx opens device and takes ownership
|
||||||
{
|
{
|
||||||
|
qDebug("BladerfOutput::start: Rx side is not running");
|
||||||
|
|
||||||
if (!DeviceBladeRF::open_bladerf(&m_dev, 0)) // TODO: fix; Open first available device as there is no proper handling for multiple devices
|
if (!DeviceBladeRF::open_bladerf(&m_dev, 0)) // TODO: fix; Open first available device as there is no proper handling for multiple devices
|
||||||
{
|
{
|
||||||
qCritical("BladerfOutput::start: could not open BladeRF");
|
qCritical("BladerfOutput::start: could not open BladeRF");
|
||||||
@ -97,6 +101,8 @@ bool BladerfOutput::start(int device)
|
|||||||
}
|
}
|
||||||
else // No Rx part open so Tx opens device and takes ownership
|
else // No Rx part open so Tx opens device and takes ownership
|
||||||
{
|
{
|
||||||
|
qDebug("BladerfOutput::start: Rx side is not open");
|
||||||
|
|
||||||
if (!DeviceBladeRF::open_bladerf(&m_dev, 0)) // TODO: fix; Open first available device as there is no proper handling for multiple devices
|
if (!DeviceBladeRF::open_bladerf(&m_dev, 0)) // TODO: fix; Open first available device as there is no proper handling for multiple devices
|
||||||
{
|
{
|
||||||
qCritical("BladerfOutput::start: could not open BladeRF");
|
qCritical("BladerfOutput::start: could not open BladeRF");
|
||||||
@ -127,7 +133,7 @@ bool BladerfOutput::start(int device)
|
|||||||
|
|
||||||
m_bladerfThread->startWork();
|
m_bladerfThread->startWork();
|
||||||
|
|
||||||
mutexLocker.unlock();
|
// mutexLocker.unlock();
|
||||||
applySettings(m_settings, true);
|
applySettings(m_settings, true);
|
||||||
|
|
||||||
qDebug("BladerfOutput::start: started");
|
qDebug("BladerfOutput::start: started");
|
||||||
@ -141,15 +147,21 @@ failed:
|
|||||||
|
|
||||||
void BladerfOutput::stop()
|
void BladerfOutput::stop()
|
||||||
{
|
{
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
// QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
int res;
|
||||||
|
|
||||||
if(m_bladerfThread != 0)
|
if(m_bladerfThread != 0)
|
||||||
{
|
{
|
||||||
m_bladerfThread->stopWork();
|
m_bladerfThread->stopWork();
|
||||||
delete m_bladerfThread;
|
delete m_bladerfThread;
|
||||||
m_bladerfThread = 0;
|
m_bladerfThread = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((res = bladerf_enable_module(m_dev, BLADERF_MODULE_TX, false)) < 0)
|
||||||
|
{
|
||||||
|
qCritical("BladerfOutput::stop: bladerf_enable_module with return code %d", res);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_deviceAPI->getSourceBuddies().size() > 0)
|
if (m_deviceAPI->getSourceBuddies().size() > 0)
|
||||||
{
|
{
|
||||||
DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[0];
|
DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[0];
|
||||||
@ -157,6 +169,8 @@ void BladerfOutput::stop()
|
|||||||
|
|
||||||
if (buddy->getDeviceSourceEngine()->state() == DSPDeviceSourceEngine::StRunning) // Rx side running
|
if (buddy->getDeviceSourceEngine()->state() == DSPDeviceSourceEngine::StRunning) // Rx side running
|
||||||
{
|
{
|
||||||
|
qDebug("BladerfOutput::stop: Rx side is running");
|
||||||
|
|
||||||
if ((m_sharedParams.m_dev != 0) && (buddySharedParams->m_dev == 0)) // Tx has the ownership but not the Rx
|
if ((m_sharedParams.m_dev != 0) && (buddySharedParams->m_dev == 0)) // Tx has the ownership but not the Rx
|
||||||
{
|
{
|
||||||
buddySharedParams->m_dev = m_dev; // transfer ownership
|
buddySharedParams->m_dev = m_dev; // transfer ownership
|
||||||
@ -164,6 +178,8 @@ void BladerfOutput::stop()
|
|||||||
}
|
}
|
||||||
else // Rx is not running so Tx must have the ownership
|
else // Rx is not running so Tx must have the ownership
|
||||||
{
|
{
|
||||||
|
qDebug("BladerfOutput::stop: Rx side is not running");
|
||||||
|
|
||||||
if(m_dev != 0) // close BladeRF
|
if(m_dev != 0) // close BladeRF
|
||||||
{
|
{
|
||||||
bladerf_close(m_dev);
|
bladerf_close(m_dev);
|
||||||
@ -173,6 +189,8 @@ void BladerfOutput::stop()
|
|||||||
}
|
}
|
||||||
else // No Rx part open
|
else // No Rx part open
|
||||||
{
|
{
|
||||||
|
qDebug("BladerfOutput::stop: Rx side is not open");
|
||||||
|
|
||||||
if(m_dev != 0) // close BladeRF
|
if(m_dev != 0) // close BladeRF
|
||||||
{
|
{
|
||||||
bladerf_close(m_dev);
|
bladerf_close(m_dev);
|
||||||
@ -222,7 +240,7 @@ bool BladerfOutput::handleMessage(const Message& message)
|
|||||||
bool BladerfOutput::applySettings(const BladeRFOutputSettings& settings, bool force)
|
bool BladerfOutput::applySettings(const BladeRFOutputSettings& settings, bool force)
|
||||||
{
|
{
|
||||||
bool forwardChange = false;
|
bool forwardChange = false;
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
// QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
|
||||||
qDebug() << "BladerfOutput::applySettings: m_dev: " << m_dev;
|
qDebug() << "BladerfOutput::applySettings: m_dev: " << m_dev;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ bool BladerfInput::init(const Message& cmd)
|
|||||||
|
|
||||||
bool BladerfInput::start(int device)
|
bool BladerfInput::start(int device)
|
||||||
{
|
{
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
// QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
|
||||||
if (m_dev != 0)
|
if (m_dev != 0)
|
||||||
{
|
{
|
||||||
@ -151,7 +151,7 @@ bool BladerfInput::start(int device)
|
|||||||
|
|
||||||
m_bladerfThread->startWork();
|
m_bladerfThread->startWork();
|
||||||
|
|
||||||
mutexLocker.unlock();
|
// mutexLocker.unlock();
|
||||||
applySettings(m_settings, true);
|
applySettings(m_settings, true);
|
||||||
|
|
||||||
qDebug("BladerfInput::startInput: started");
|
qDebug("BladerfInput::startInput: started");
|
||||||
@ -165,7 +165,8 @@ failed:
|
|||||||
|
|
||||||
void BladerfInput::stop()
|
void BladerfInput::stop()
|
||||||
{
|
{
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
// QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
int res;
|
||||||
|
|
||||||
if(m_bladerfThread != 0)
|
if(m_bladerfThread != 0)
|
||||||
{
|
{
|
||||||
@ -174,6 +175,11 @@ void BladerfInput::stop()
|
|||||||
m_bladerfThread = 0;
|
m_bladerfThread = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((res = bladerf_enable_module(m_dev, BLADERF_MODULE_RX, false)) < 0)
|
||||||
|
{
|
||||||
|
qCritical("BladerfInput::stop: bladerf_enable_module with return code %d", res);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_deviceAPI->getSinkBuddies().size() > 0)
|
if (m_deviceAPI->getSinkBuddies().size() > 0)
|
||||||
{
|
{
|
||||||
DeviceSinkAPI *buddy = m_deviceAPI->getSinkBuddies()[0];
|
DeviceSinkAPI *buddy = m_deviceAPI->getSinkBuddies()[0];
|
||||||
@ -252,7 +258,7 @@ bool BladerfInput::handleMessage(const Message& message)
|
|||||||
bool BladerfInput::applySettings(const BladeRFInputSettings& settings, bool force)
|
bool BladerfInput::applySettings(const BladeRFInputSettings& settings, bool force)
|
||||||
{
|
{
|
||||||
bool forwardChange = false;
|
bool forwardChange = false;
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
// QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
|
||||||
qDebug() << "BladerfInput::applySettings: m_dev: " << m_dev;
|
qDebug() << "BladerfInput::applySettings: m_dev: " << m_dev;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user