diff --git a/plugins/samplesource/limesdrinput/limesdrinput.cpp b/plugins/samplesource/limesdrinput/limesdrinput.cpp index db4758a0f..c8dd7c89d 100644 --- a/plugins/samplesource/limesdrinput/limesdrinput.cpp +++ b/plugins/samplesource/limesdrinput/limesdrinput.cpp @@ -163,6 +163,24 @@ bool LimeSDRInput::openDevice() qDebug("LimeSDRInput::openDevice: Rx channel %lu enabled", m_deviceShared.m_channel); } + // set up the stream + + m_streamId.channel = m_deviceShared.m_channel; //channel number + m_streamId.fifoSize = 1024 * 128; //fifo size in samples + m_streamId.throughputVsLatency = 1.0; //optimize for max throughput + m_streamId.isTx = false; //RX channel + m_streamId.dataFmt = lms_stream_t::LMS_FMT_I12; //12-bit integers + + if (LMS_SetupStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0) + { + qCritical("LimeSDRInput::start: cannot setup the stream on Rx channel %lu", m_deviceShared.m_channel); + return false; + } + else + { + qDebug("LimeSDRInput::start: stream set up on Rx channel %lu", m_deviceShared.m_channel); + } + return true; } @@ -172,6 +190,9 @@ void LimeSDRInput::closeDevice() return; } + // destroy the stream + LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId); + // release the channel if (LMS_EnableChannel(m_deviceShared.m_deviceParams->getDevice(), LMS_CH_RX, m_deviceShared.m_channel, false) != 0) @@ -199,24 +220,6 @@ bool LimeSDRInput::start() if (m_running) stop(); - // set up the stream - - m_streamId.channel = m_deviceShared.m_channel; //channel number - m_streamId.fifoSize = 1024 * 128; //fifo size in samples - m_streamId.throughputVsLatency = 1.0; //optimize for max throughput - m_streamId.isTx = false; //RX channel - m_streamId.dataFmt = lms_stream_t::LMS_FMT_I12; //12-bit integers - - if (LMS_SetupStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId) != 0) - { - qCritical("LimeSDRInput::start: cannot setup the stream on Rx channel %lu", m_deviceShared.m_channel); - return false; - } - else - { - qDebug("LimeSDRInput::start: stream set up on Rx channel %lu", m_deviceShared.m_channel); - } - // start / stop streaming is done in the thread. if ((m_limeSDRInputThread = new LimeSDRInputThread(&m_streamId, &m_sampleFifo)) == 0) @@ -249,9 +252,6 @@ void LimeSDRInput::stop() m_limeSDRInputThread = 0; } - // destroy the stream - LMS_DestroyStream(m_deviceShared.m_deviceParams->getDevice(), &m_streamId); - m_running = false; }