diff --git a/devices/xtrx/devicextrx.cpp b/devices/xtrx/devicextrx.cpp index eaa83b2a0..38d32cf8e 100644 --- a/devices/xtrx/devicextrx.cpp +++ b/devices/xtrx/devicextrx.cpp @@ -125,14 +125,16 @@ double DeviceXTRX::set_samplerate(double rate, double master, bool output) m_inputRate = rate; } - int res = xtrx_set_samplerate(m_dev, - m_masterRate, - m_inputRate, - m_outputRate, - 0, - &m_clockGen, - &m_actualInputRate, - &m_actualOutputRate); + int res = xtrx_set_samplerate( + m_dev, + m_masterRate, + m_inputRate, + m_outputRate, + XTRX_SAMPLERATE_FORCE_UPDATE, + &m_clockGen, + &m_actualInputRate, + &m_actualOutputRate + ); if (res) { diff --git a/plugins/samplesink/xtrxoutput/xtrxoutput.cpp b/plugins/samplesink/xtrxoutput/xtrxoutput.cpp index 232d49c46..6ecd3a7f0 100644 --- a/plugins/samplesink/xtrxoutput/xtrxoutput.cpp +++ b/plugins/samplesink/xtrxoutput/xtrxoutput.cpp @@ -382,12 +382,6 @@ void XTRXOutput::stop() // remove old thread address from buddies (reset in all buddies) const std::vector& sinkBuddies = m_deviceAPI->getSinkBuddies(); std::vector::const_iterator it = sinkBuddies.begin(); - - for (; it != sinkBuddies.end(); ++it) - { - ((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_sink->setThread(0); - ((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_thread = 0; - } } else if (nbOriginalChannels == 2) // Reduce from MO to SO by deleting and re-creating the thread { @@ -404,13 +398,6 @@ void XTRXOutput::stop() // remove old thread address from buddies (reset in all buddies). The address being held only in the owning source. const std::vector& sinkBuddies = m_deviceAPI->getSinkBuddies(); std::vector::const_iterator it = sinkBuddies.begin(); - - for (; it != sinkBuddies.end(); ++it) - { - ((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_sink->setThread(0); - ((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_thread = 0; - } - applySettings(m_settings, true); xtrxOutputThread->startWork(); } @@ -503,24 +490,20 @@ int XTRXOutput::getSampleRate() const uint32_t XTRXOutput::getDevSampleRate() const { - uint32_t devSampleRate = m_settings.m_devSampleRate; - if (m_deviceShared.m_dev) { - devSampleRate = m_deviceShared.m_dev->getActualOutputRate(); + return m_deviceShared.m_dev->getActualOutputRate(); + } else { + return m_settings.m_devSampleRate; } - - return devSampleRate; } uint32_t XTRXOutput::getLog2HardInterp() const { - uint32_t log2HardInterp = m_settings.m_log2HardInterp; - if (m_deviceShared.m_dev && (m_deviceShared.m_dev->getActualOutputRate() != 0.0)) { - log2HardInterp = log2(m_deviceShared.m_dev->getClockGen() / m_deviceShared.m_dev->getActualOutputRate() / 4); + return log2(m_deviceShared.m_dev->getClockGen() / m_deviceShared.m_dev->getActualOutputRate() / 4); + } else { + return m_settings.m_log2HardInterp; } - - return log2HardInterp; } double XTRXOutput::getClockGen() const @@ -964,42 +947,40 @@ bool XTRXOutput::applySettings(const XTRXOutputSettings& settings, bool force, b if (doChangeSampleRate && (settings.m_devSampleRate != 0)) { - XTRXOutputThread *txThread = findThread(); + // XTRXOutputThread *txThread = findThread(); - if (txThread && txThread->isRunning()) - { - txThread->stopWork(); - txThreadWasRunning = true; - } + // if (txThread && txThread->isRunning()) + // { + // txThread->stopWork(); + // txThreadWasRunning = true; + // } - suspendRxThread(); + // suspendRxThread(); - double master = (settings.m_log2HardInterp == 0) ? 0 : (settings.m_devSampleRate * 4 * (1 << settings.m_log2HardInterp)); + double master = (m_settings.m_log2HardInterp == 0) ? 0 : (m_settings.m_devSampleRate * 4 * (1 << m_settings.m_log2HardInterp)); - if (m_deviceShared.m_dev->set_samplerate(settings.m_devSampleRate, - master, //(settings.m_devSampleRate<setSamplerate( + m_settings.m_devSampleRate, + master, + true + ); - qDebug("XTRXOutput::applySettings: sample rate set to %f with oversampling of %d", - m_deviceShared.m_dev->getActualOutputRate(), - 1 << getLog2HardInterp()); - } + doChangeFreq = true; + forceNCOFrequency = true; + forwardChangeAllDSP = true; + m_settings.m_devSampleRate = m_deviceShared.m_dev->getActualOutputRate(); + m_settings.m_log2HardInterp = getLog2HardInterp(); - resumeRxThread(); + qDebug("XTRXOutput::applySettings: sample rate set %s to %f with hard interpolation of %d", + (res < 0) ? "changed" : "unchanged", + m_settings.m_devSampleRate, + m_settings.m_log2HardInterp); - if (txThreadWasRunning) { - txThread->startWork(); - } + // resumeRxThread(); + + // if (txThreadWasRunning) { + // txThread->startWork(); + // } } if (doLPCalibration) @@ -1022,12 +1003,12 @@ bool XTRXOutput::applySettings(const XTRXOutputSettings& settings, bool force, b { if (xtrx_tune(m_deviceShared.m_dev->getDevice(), XTRX_TUNE_TX_FDD, - settings.m_centerFrequency, + m_settings.m_centerFrequency, 0) < 0) { - qCritical("XTRXOutput::applySettings: could not set frequency to %lu", settings.m_centerFrequency); + qCritical("XTRXOutput::applySettings: could not set frequency to %lu", m_settings.m_centerFrequency); } else { //doCalibration = true; - qDebug("XTRXOutput::applySettings: frequency set to %lu", settings.m_centerFrequency); + qDebug("XTRXOutput::applySettings: frequency set to %lu", m_settings.m_centerFrequency); } } } @@ -1039,19 +1020,19 @@ bool XTRXOutput::applySettings(const XTRXOutputSettings& settings, bool force, b if (xtrx_tune_ex(m_deviceShared.m_dev->getDevice(), XTRX_TUNE_BB_TX, m_deviceShared.m_channel == 0 ? XTRX_CH_A : XTRX_CH_B, - (settings.m_ncoEnable) ? settings.m_ncoFrequency : 0, + (m_settings.m_ncoEnable) ? m_settings.m_ncoFrequency : 0, NULL) < 0) { qCritical("XTRXOutput::applySettings: could not %s and set NCO to %d Hz", - settings.m_ncoEnable ? "enable" : "disable", - settings.m_ncoFrequency); + m_settings.m_ncoEnable ? "enable" : "disable", + m_settings.m_ncoFrequency); } else { forwardChangeOwnDSP = true; qDebug("XTRXOutput::applySettings: %sd and set NCO to %d Hz", - settings.m_ncoEnable ? "enable" : "disable", - settings.m_ncoFrequency); + m_settings.m_ncoEnable ? "enable" : "disable", + m_settings.m_ncoFrequency); } } } diff --git a/plugins/samplesink/xtrxoutput/xtrxoutputgui.cpp b/plugins/samplesink/xtrxoutput/xtrxoutputgui.cpp index 022cdd004..25f62eadb 100644 --- a/plugins/samplesink/xtrxoutput/xtrxoutputgui.cpp +++ b/plugins/samplesink/xtrxoutput/xtrxoutputgui.cpp @@ -173,6 +173,7 @@ bool XTRXOutputGUI::handleMessage(const Message& message) else if (XTRXOutput::MsgReportClockGenChange::match(message)) { m_settings.m_devSampleRate = m_XTRXOutput->getDevSampleRate(); + m_settings.m_log2HardInterp = m_XTRXOutput->getLog2HardInterp(); blockApplySettings(true); displaySettings(); diff --git a/plugins/samplesink/xtrxoutput/xtrxoutputgui.ui b/plugins/samplesink/xtrxoutput/xtrxoutputgui.ui index 72191049f..c04dd6267 100644 --- a/plugins/samplesink/xtrxoutput/xtrxoutputgui.ui +++ b/plugins/samplesink/xtrxoutput/xtrxoutputgui.ui @@ -302,6 +302,71 @@ 2 + + + + + 24 + 0 + + + + + 24 + 16777215 + + + + Toggle between device to host (SR) and base band (BB) sample rate input + + + SR + + + true + + + true + + + + + + + + 0 + 0 + + + + + 32 + 16 + + + + + Liberation Mono + 12 + 50 + false + + + + PointingHandCursor + + + Device to host sample rate + + + + + + + S/s + + + @@ -356,6 +421,11 @@ 32 + + + 64 + + @@ -432,71 +502,6 @@ - - - - - 24 - 0 - - - - - 24 - 16777215 - - - - Toggle between device to host (SR) and base band (BB) sample rate input - - - SR - - - true - - - true - - - - - - - - 0 - 0 - - - - - 32 - 16 - - - - - Liberation Mono - 12 - 50 - false - - - - PointingHandCursor - - - Device to host sample rate - - - - - - - S/s - - - diff --git a/plugins/samplesink/xtrxoutput/xtrxoutputplugin.cpp b/plugins/samplesink/xtrxoutput/xtrxoutputplugin.cpp index 3275035c6..216e7dbf5 100644 --- a/plugins/samplesink/xtrxoutput/xtrxoutputplugin.cpp +++ b/plugins/samplesink/xtrxoutput/xtrxoutputplugin.cpp @@ -36,7 +36,7 @@ const PluginDescriptor XTRXOutputPlugin::m_pluginDescriptor = { QString("XTRX"), QString("XTRX Output"), - QString("4.12.3"), + QString("4.14.4"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, diff --git a/plugins/samplesource/xtrxinput/xtrxinput.cpp b/plugins/samplesource/xtrxinput/xtrxinput.cpp index b52ac3bf2..7cbf6a9b6 100644 --- a/plugins/samplesource/xtrxinput/xtrxinput.cpp +++ b/plugins/samplesource/xtrxinput/xtrxinput.cpp @@ -400,12 +400,6 @@ void XTRXInput::stop() // remove old thread address from buddies (reset in all buddies) const std::vector& sourceBuddies = m_deviceAPI->getSourceBuddies(); std::vector::const_iterator it = sourceBuddies.begin(); - - for (; it != sourceBuddies.end(); ++it) - { - ((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_source->setThread(0); - ((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_thread = 0; - } } else if (nbOriginalChannels == 2) // Reduce from MI to SI by deleting and re-creating the thread { @@ -422,13 +416,6 @@ void XTRXInput::stop() // remove old thread address from buddies (reset in all buddies). The address being held only in the owning source. const std::vector& sourceBuddies = m_deviceAPI->getSourceBuddies(); std::vector::const_iterator it = sourceBuddies.begin(); - - for (; it != sourceBuddies.end(); ++it) - { - ((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_source->setThread(0); - ((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_thread = 0; - } - applySettings(m_settings, true); xtrxInputThread->startWork(); } @@ -521,24 +508,20 @@ int XTRXInput::getSampleRate() const uint32_t XTRXInput::getDevSampleRate() const { - uint32_t devSampleRate = m_settings.m_devSampleRate; - if (m_deviceShared.m_dev) { - devSampleRate = m_deviceShared.m_dev->getActualInputRate(); + return m_deviceShared.m_dev->getActualInputRate(); + } else { + return m_settings.m_devSampleRate; } - - return devSampleRate; } uint32_t XTRXInput::getLog2HardDecim() const { - uint32_t log2HardDecim = m_settings.m_log2HardDecim; - if (m_deviceShared.m_dev && (m_deviceShared.m_dev->getActualInputRate() != 0.0)) { - log2HardDecim = log2(m_deviceShared.m_dev->getClockGen() / m_deviceShared.m_dev->getActualInputRate() / 4); + return log2(m_deviceShared.m_dev->getClockGen() / m_deviceShared.m_dev->getActualInputRate() / 4); + } else { + return m_settings.m_log2HardDecim; } - - return log2HardDecim; } double XTRXInput::getClockGen() const @@ -630,15 +613,14 @@ bool XTRXInput::handleMessage(const Message& message) { m_settings.m_devSampleRate = m_deviceShared.m_dev->getActualInputRate(); m_settings.m_log2HardDecim = getLog2HardDecim(); - - qDebug() << "XTRXInput::handleMessage: MsgReportBuddyChange:" - << " host_Hz: " << m_deviceShared.m_dev->getActualInputRate() - << " adc_Hz: " << m_deviceShared.m_dev->getClockGen() / 4 - << " m_log2HardDecim: " << m_settings.m_log2HardDecim; } - if (m_settings.m_ncoEnable) // need to reset NCO after sample rate change - { + qDebug() << "XTRXInput::handleMessage: MsgReportBuddyChange:" + << " host_Hz: " << m_deviceShared.m_dev->getActualInputRate() + << " adc_Hz: " << m_deviceShared.m_dev->getClockGen() / 4 + << " m_log2HardDecim: " << m_settings.m_log2HardDecim; + + if (m_settings.m_ncoEnable) { // need to reset NCO after sample rate change applySettings(m_settings, false, true); } @@ -1102,44 +1084,42 @@ bool XTRXInput::applySettings(const XTRXInputSettings& settings, bool force, boo m_settings = settings; - if (doChangeSampleRate && (settings.m_devSampleRate != 0)) + if (doChangeSampleRate && (m_settings.m_devSampleRate != 0)) { - XTRXInputThread *rxThread = findThread(); + // XTRXInputThread *rxThread = findThread(); - if (rxThread && rxThread->isRunning()) - { - rxThread->stopWork(); - rxThreadWasRunning = true; - } + // if (rxThread && rxThread->isRunning()) + // { + // rxThread->stopWork(); + // rxThreadWasRunning = true; + // } - suspendTxThread(); + // suspendTxThread(); - double master = (settings.m_log2HardDecim == 0) ? 0 : (settings.m_devSampleRate * 4 * (1 << settings.m_log2HardDecim)); + double master = (m_settings.m_log2HardDecim == 0) ? 0 : (m_settings.m_devSampleRate * 4 * (1 << m_settings.m_log2HardDecim)); - if (m_deviceShared.m_dev->set_samplerate(settings.m_devSampleRate, - master, //(settings.m_devSampleRate<setSamplerate( + m_settings.m_devSampleRate, + master, + false + ); - qDebug("XTRXInput::applySettings: sample rate set to %f with oversampling of %d", - m_deviceShared.m_dev->getActualInputRate(), - 1 << getLog2HardDecim()); - } + doChangeFreq = true; + forceNCOFrequency = true; + forwardChangeAllDSP = true; + m_settings.m_devSampleRate = m_deviceShared.m_dev->getActualInputRate(); + m_settings.m_log2HardDecim = getLog2HardDecim(); - resumeTxThread(); + qDebug("XTRXInput::applySettings: sample rate set %s to %f with hard decimation of %d", + (res < 0) ? "changed" : "unchanged", + m_settings.m_devSampleRate, + m_settings.m_log2HardDecim); - if (rxThreadWasRunning) { - rxThread->startWork(); - } + // resumeTxThread(); + + // if (rxThreadWasRunning) { + // rxThread->startWork(); + // } } if (doLPCalibration) @@ -1179,12 +1159,12 @@ bool XTRXInput::applySettings(const XTRXInputSettings& settings, bool force, boo { if (xtrx_tune(m_deviceShared.m_dev->getDevice(), XTRX_TUNE_RX_FDD, - settings.m_centerFrequency, + m_settings.m_centerFrequency, 0) < 0) { - qCritical("XTRXInput::applySettings: could not set frequency to %lu", settings.m_centerFrequency); + qCritical("XTRXInput::applySettings: could not set frequency to %lu", m_settings.m_centerFrequency); } else { //doCalibration = true; - qDebug("XTRXInput::applySettings: frequency set to %lu", settings.m_centerFrequency); + qDebug("XTRXInput::applySettings: frequency set to %lu", m_settings.m_centerFrequency); } } } @@ -1196,19 +1176,19 @@ bool XTRXInput::applySettings(const XTRXInputSettings& settings, bool force, boo if (xtrx_tune_ex(m_deviceShared.m_dev->getDevice(), XTRX_TUNE_BB_RX, m_deviceShared.m_channel == 0 ? XTRX_CH_A : XTRX_CH_B, - (settings.m_ncoEnable) ? settings.m_ncoFrequency : 0, + (m_settings.m_ncoEnable) ? m_settings.m_ncoFrequency : 0, NULL) < 0) { qCritical("XTRXInput::applySettings: could not %s and set NCO to %d Hz", - settings.m_ncoEnable ? "enable" : "disable", - settings.m_ncoFrequency); + m_settings.m_ncoEnable ? "enable" : "disable", + m_settings.m_ncoFrequency); } else { forwardChangeOwnDSP = true; qDebug("XTRXInput::applySettings: %sd and set NCO to %d Hz", - settings.m_ncoEnable ? "enable" : "disable", - settings.m_ncoFrequency); + m_settings.m_ncoEnable ? "enable" : "disable", + m_settings.m_ncoFrequency); } } } diff --git a/plugins/samplesource/xtrxinput/xtrxinputgui.cpp b/plugins/samplesource/xtrxinput/xtrxinputgui.cpp index e2dca64d0..9f1f2b86b 100644 --- a/plugins/samplesource/xtrxinput/xtrxinputgui.cpp +++ b/plugins/samplesource/xtrxinput/xtrxinputgui.cpp @@ -179,6 +179,7 @@ bool XTRXInputGUI::handleMessage(const Message& message) else if (XTRXInput::MsgReportClockGenChange::match(message)) { m_settings.m_devSampleRate = m_XTRXInput->getDevSampleRate(); + m_settings.m_log2HardDecim = m_XTRXInput->getLog2HardDecim(); blockApplySettings(true); displaySettings(); diff --git a/plugins/samplesource/xtrxinput/xtrxinputgui.ui b/plugins/samplesource/xtrxinput/xtrxinputgui.ui index 2a97dbc35..42139f59a 100644 --- a/plugins/samplesource/xtrxinput/xtrxinputgui.ui +++ b/plugins/samplesource/xtrxinput/xtrxinputgui.ui @@ -337,6 +337,71 @@ 2 + + + + + 24 + 0 + + + + + 24 + 16777215 + + + + Toggle between device to host (SR) and base band (BB) sample rate input + + + SR + + + true + + + true + + + + + + + + 0 + 0 + + + + + 32 + 16 + + + + + Liberation Mono + 12 + 50 + false + + + + PointingHandCursor + + + Device to host sample rate + + + + + + + S/s + + + @@ -391,6 +456,11 @@ 32 + + + 64 + + @@ -467,71 +537,6 @@ - - - - - 24 - 0 - - - - - 24 - 16777215 - - - - Toggle between device to host (SR) and base band (BB) sample rate input - - - SR - - - true - - - true - - - - - - - - 0 - 0 - - - - - 32 - 16 - - - - - Liberation Mono - 12 - 50 - false - - - - PointingHandCursor - - - Device to host sample rate - - - - - - - S/s - - - diff --git a/plugins/samplesource/xtrxinput/xtrxinputplugin.cpp b/plugins/samplesource/xtrxinput/xtrxinputplugin.cpp index ab6acfe93..cfcea7352 100644 --- a/plugins/samplesource/xtrxinput/xtrxinputplugin.cpp +++ b/plugins/samplesource/xtrxinput/xtrxinputplugin.cpp @@ -38,7 +38,7 @@ const PluginDescriptor XTRXInputPlugin::m_pluginDescriptor = { QString("XTRX"), QString("XTRX Input"), - QString("4.12.3"), + QString("4.14.4"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true,