1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-28 07:46:37 -04:00

LimeSDR: suspend buddy threads only around calls to LMS_SetupStream or LMS_DestroyStream. In output plugin move them back to open/close (undoes #50)

This commit is contained in:
f4exb 2017-10-25 22:20:30 +02:00
parent 8b93c5f48d
commit e9af2f6dff
2 changed files with 77 additions and 5 deletions

View File

@ -161,6 +161,46 @@ bool LimeSDROutput::openDevice()
m_deviceAPI->setBuddySharedPtr(&m_deviceShared); // propagate common parameters to API
// acquire the channel
if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_TX, m_deviceShared.m_channel, true) != 0)
{
qCritical("LimeSDROutput::acquireChannel: cannot enable Tx channel %d", m_deviceShared.m_channel);
return false;
}
else
{
qDebug("LimeSDROutput::acquireChannel: Tx channel %d enabled", m_deviceShared.m_channel);
}
// set up the stream
m_streamId.channel = m_deviceShared.m_channel; // channel number
m_streamId.fifoSize = 512 * 1024; // fifo size in samples (SR / 10 take ~5MS/s)
m_streamId.throughputVsLatency = 0.0; // optimize for min latency
m_streamId.isTx = true; // TX channel
m_streamId.dataFmt = lms_stream_t::LMS_FMT_I12; // 12-bit integers
suspendRxBuddies();
suspendTxBuddies();
if (LMS_SetupStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0)
{
qCritical("LimeSDROutput::acquireChannel: cannot setup the stream on Tx channel %d", m_deviceShared.m_channel);
resumeTxBuddies();
resumeRxBuddies();
return false;
}
else
{
qDebug("LimeSDROutput::acquireChannel: stream set up on Tx channel %d", m_deviceShared.m_channel);
}
resumeTxBuddies();
resumeRxBuddies();
m_channelAcquired = true;
return true;
}
@ -244,6 +284,26 @@ void LimeSDROutput::closeDevice()
if (m_running) stop();
// destroy the stream
suspendRxBuddies();
suspendTxBuddies();
LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId);
m_streamId.handle = 0;
resumeTxBuddies();
resumeRxBuddies();
// release the channel
if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_TX, m_deviceShared.m_channel, false) != 0)
{
qWarning("LimeSDROutput::releaseChannel: cannot disable Tx channel %d", m_deviceShared.m_channel);
}
m_channelAcquired = false;
// No buddies so effectively close the device
if ((m_deviceAPI->getSourceBuddies().size() == 0) && (m_deviceAPI->getSinkBuddies().size() == 0))
@ -329,10 +389,10 @@ bool LimeSDROutput::start()
if (m_running) { stop(); }
if (!acquireChannel())
{
return false;
}
// if (!acquireChannel())
// {
// return false;
// }
applySettings(m_settings, true);
@ -371,7 +431,7 @@ void LimeSDROutput::stop()
m_deviceShared.m_thread = 0;
m_running = false;
releaseChannel();
// releaseChannel();
}
const QString& LimeSDROutput::getDeviceDescription() const

View File

@ -198,6 +198,9 @@ bool LimeSDRInput::openDevice()
m_streamId.isTx = false; //RX channel
m_streamId.dataFmt = lms_stream_t::LMS_FMT_I12; //12-bit integers
suspendRxBuddies();
suspendTxBuddies();
if (LMS_SetupStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0)
{
qCritical("LimeSDRInput::start: cannot setup the stream on Rx channel %d", m_deviceShared.m_channel);
@ -208,6 +211,9 @@ bool LimeSDRInput::openDevice()
qDebug("LimeSDRInput::start: stream set up on Rx channel %d", m_deviceShared.m_channel);
}
resumeTxBuddies();
resumeRxBuddies();
return true;
}
@ -290,10 +296,16 @@ void LimeSDRInput::closeDevice()
if (m_running) { stop(); }
suspendRxBuddies();
suspendTxBuddies();
// destroy the stream
LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId);
m_streamId.handle = 0;
resumeTxBuddies();
resumeRxBuddies();
// release the channel
if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, false) != 0)