diff --git a/plugins/samplesource/limesdrinput/limesdrinput.cpp b/plugins/samplesource/limesdrinput/limesdrinput.cpp index 096f2acdc..3eb448dd2 100644 --- a/plugins/samplesource/limesdrinput/limesdrinput.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinput.cpp @@ -102,6 +102,10 @@ bool LimeSDRInput::openDevice() DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[i]; DeviceLimeSDRShared *buddyShared = (DeviceLimeSDRShared *) buddy->getBuddySharedPtr(); 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; @@ -183,6 +187,18 @@ bool LimeSDRInput::openDevice() 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; } @@ -192,6 +208,18 @@ void LimeSDRInput::closeDevice() 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 LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId); @@ -204,6 +232,18 @@ void LimeSDRInput::closeDevice() 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 if ((m_deviceAPI->getSinkBuddies().size() == 0) && (m_deviceAPI->getSourceBuddies().size() == 0))