Skip to content

Commit

Permalink
Merge pull request f4exb#1886 from srcejon/fix_1885
Browse files Browse the repository at this point in the history
Remote TCP - Fix FIFO size adjustment, so sample rates >3MS/s work.
  • Loading branch information
f4exb authored Nov 13, 2023
2 parents 95da393 + dcd298b commit a3fa916
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions plugins/channelrx/remotetcpsink/remotetcpsinksink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,18 @@ void RemoteTCPSinkSink::processCommand()
int sampleRate = RemoteTCPProtocol::extractUInt32(&cmd[1]);
qDebug() << "RemoteTCPSinkSink::processCommand: set sample rate " << sampleRate;
ChannelWebAPIUtils::setDevSampleRate(m_deviceIndex, sampleRate);
if (m_settings.m_protocol == RemoteTCPSinkSettings::RTL0)
{
// Match channel sample rate with device sample rate for RTL0 protocol
ChannelWebAPIUtils::setSoftDecim(m_deviceIndex, 0);
settings.m_channelSampleRate = sampleRate;
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, {"channelSampleRate"}, false, true));
}
if (m_messageQueueToChannel) {
m_messageQueueToChannel->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, {"channelSampleRate"}, false, true));
}
}
break;
}
case RemoteTCPProtocol::setTunerGainMode:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ RemoteTCPInputTCPHandler::RemoteTCPInputTCPHandler(SampleSinkFifo *sampleFifo, D
m_converterBufferNbSamples(0),
m_settings()
{
m_sampleFifo->setSize(5000000); // Start with large FIFO, to avoid having to resize
m_tcpBuf = new char[m_sampleFifo->size()*2*4];
m_timer.setInterval(125);
connect(&m_reconnectTimer, SIGNAL(timeout()), this, SLOT(reconnect()));
Expand Down Expand Up @@ -455,8 +456,7 @@ void RemoteTCPInputTCPHandler::applySettings(const RemoteTCPInputSettings& setti
if ((settings.m_channelSampleRate != m_settings.m_channelSampleRate) || force)
{
// Resize FIFO to give us 1 second
// Can't do this while running
if (!m_running && settingsKeys.contains("channelSampleRate") && settings.m_channelSampleRate > (qint32)m_sampleFifo->size())
if ((settingsKeys.contains("channelSampleRate") || force) && (settings.m_channelSampleRate > (qint32)m_sampleFifo->size()))
{
qDebug() << "RemoteTCPInputTCPHandler::applySettings: Resizing sample FIFO from " << m_sampleFifo->size() << "to" << settings.m_channelSampleRate;
m_sampleFifo->setSize(settings.m_channelSampleRate);
Expand Down Expand Up @@ -692,7 +692,7 @@ void RemoteTCPInputTCPHandler::processData()
qDebug() << "Buffer primed bytesAvailable:" << m_dataSocket->bytesAvailable();
m_fillBuffer = false;
m_prevDateTime = QDateTime::currentDateTime();
factor = 6.0f / 8.0f;
factor = 1.0f / 4.0f; // If this is too high, samples can just be dropped downstream
}
}
else
Expand Down

0 comments on commit a3fa916

Please sign in to comment.