1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-23 08:28:36 -05:00

LimeSDR input: suspend/resume Rx buddy thread when opening/closing so that the stream can be allocated/de-allocated properly

This commit is contained in:
f4exb 2017-04-20 01:39:05 +02:00
parent edfcb36dab
commit 01b469ec80

View File

@ -102,6 +102,10 @@ bool LimeSDRInput::openDevice()
DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[i]; DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[i];
DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr();
busyChannels[buddyShared->m_channel] = 1; busyChannels[buddyShared->m_channel] = 1;
if (buddyShared->m_thread) { // suspend Rx buddy's thread for proper stream allocation later
((LimeSDRInputThread *) buddyShared->m_thread)->stopWork();
}
} }
std::size_t ch = 0; std::size_t ch = 0;
@ -183,6 +187,18 @@ bool LimeSDRInput::openDevice()
qDebug("LimeSDRInput::start: stream set up on Rx channel %lu", m_deviceShared.m_channel); qDebug("LimeSDRInput::start: stream set up on Rx channel %lu", m_deviceShared.m_channel);
} }
// resume Rx buddy's threads
for (int i = 0; i < m_deviceAPI->getSourceBuddies().size(); i++)
{
DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[i];
DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr();
if (buddyShared->m_thread) {
((LimeSDRInputThread *) buddyShared->m_thread)->startWork();
}
}
return true; return true;
} }
@ -192,6 +208,18 @@ void LimeSDRInput::closeDevice()
return; return;
} }
// suspend Rx buddy's threads
for (int i = 0; i < m_deviceAPI->getSourceBuddies().size(); i++)
{
DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[i];
DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr();
if (buddyShared->m_thread) {
((LimeSDRInputThread *) buddyShared->m_thread)->stopWork();
}
}
// destroy the stream // destroy the stream
LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId); LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId);
@ -204,6 +232,18 @@ void LimeSDRInput::closeDevice()
m_deviceShared.m_channel = -1; m_deviceShared.m_channel = -1;
// resume Rx buddy's threads
for (int i = 0; i < m_deviceAPI->getSourceBuddies().size(); i++)
{
DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[i];
DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr();
if (buddyShared->m_thread) {
((LimeSDRInputThread *) buddyShared->m_thread)->startWork();
}
}
// No buddies so effectively close the device // No buddies so effectively close the device
if ((m_deviceAPI->getSinkBuddies().size() == 0) && (m_deviceAPI->getSourceBuddies().size() == 0)) if ((m_deviceAPI->getSinkBuddies().size() == 0) && (m_deviceAPI->getSourceBuddies().size() == 0))