diff --git a/plugins/samplesink/limesdroutput/limesdroutput.cpp b/plugins/samplesink/limesdroutput/limesdroutput.cpp index 853b640db..ae6e3bc20 100644 --- a/plugins/samplesink/limesdroutput/limesdroutput.cpp +++ b/plugins/samplesink/limesdroutput/limesdroutput.cpp @@ -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 diff --git a/plugins/samplesource/limesdrinput/limesdrinput.cpp b/plugins/samplesource/limesdrinput/limesdrinput.cpp index 5fd48f412..96098c639 100644 --- a/plugins/samplesource/limesdrinput/limesdrinput.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinput.cpp @@ -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)