1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00
sdrangel/plugins/channelrx/udpsrc/udpsrc.cpp

587 lines
20 KiB
C++
Raw Normal View History

///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 F4EXB //
// written by Edouard Griffiths //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
2015-12-01 20:28:31 -05:00
#include <QUdpSocket>
2015-12-02 22:02:21 -05:00
#include <QHostAddress>
2015-12-02 22:02:21 -05:00
#include "dsp/dspengine.h"
#include "util/db.h"
#include "dsp/downchannelizer.h"
#include "dsp/threadedbasebandsamplesink.h"
#include "device/devicesourceapi.h"
#include "udpsrcgui.h"
#include "udpsrc.h"
2017-08-21 07:10:54 -04:00
const Real UDPSrc::m_agcTarget = 16384.0f;
2017-10-06 23:44:43 -04:00
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgConfigureUDPSrc, Message)
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgConfigureChannelizer, Message)
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcSpectrum, Message)
2017-10-04 16:05:38 -04:00
UDPSrc::UDPSrc(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
m_outMovingAverage(480, 1e-10),
m_inMovingAverage(480, 1e-10),
m_amMovingAverage(1200, 1e-10),
m_audioFifo(24000),
2017-10-04 16:05:38 -04:00
m_spectrum(0),
2017-10-07 00:30:30 -04:00
m_squelch(1e-6),
m_squelchOpen(false),
m_squelchOpenCount(0),
m_squelchCloseCount(0),
m_squelchGate(4800),
m_squelchRelease(4800),
m_agc(9600, m_agcTarget, 1e-6),
2017-05-25 14:13:34 -04:00
m_settingsMutex(QMutex::Recursive)
{
setObjectName("UDPSrc");
2017-10-07 00:30:30 -04:00
m_udpBuffer = new UDPSink<Sample>(this, udpBlockSize, m_settings.m_udpPort);
m_udpBufferMono = new UDPSink<FixReal>(this, udpBlockSize, m_settings.m_udpPort);
2015-12-02 22:02:21 -05:00
m_audioSocket = new QUdpSocket(this);
m_udpAudioBuf = new char[m_udpAudioPayloadSize];
2015-12-02 22:02:21 -05:00
m_audioBuffer.resize(1<<9);
m_audioBufferFill = 0;
2015-12-01 20:28:31 -05:00
2017-10-07 00:30:30 -04:00
m_nco.setFreq(0, m_settings.m_inputSampleRate);
m_interpolator.create(16, m_settings.m_inputSampleRate, m_settings.m_rfBandwidth / 2.0);
m_sampleDistanceRemain = m_settings.m_inputSampleRate / m_settings.m_outputSampleRate;
m_spectrumEnabled = false;
m_nextSSBId = 0;
m_nextS16leId = 0;
m_last = 0;
m_this = 0;
m_scale = 0;
m_magsq = 0;
m_inMagsq = 0;
m_channelizer = new DownChannelizer(this);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
2017-10-07 00:30:30 -04:00
UDPFilter = new fftfilt(0.0, (m_settings.m_rfBandwidth / 2.0) / m_settings.m_outputSampleRate, udpBlockSize);
2015-12-02 22:02:21 -05:00
2017-10-07 00:30:30 -04:00
m_phaseDiscri.setFMScaling((float) m_settings. m_outputSampleRate / (2.0f * m_settings.m_fmDeviation));
2017-10-07 00:30:30 -04:00
if (m_audioSocket->bind(QHostAddress::LocalHost, m_settings.m_audioPort))
2015-12-02 22:02:21 -05:00
{
2017-10-07 00:30:30 -04:00
qDebug("UDPSrc::UDPSrc: bind audio socket to port %d", m_settings.m_audioPort);
connect(m_audioSocket, SIGNAL(readyRead()), this, SLOT(audioReadyRead()), Qt::QueuedConnection);
2015-12-02 22:02:21 -05:00
}
else
{
qWarning("UDPSrc::UDPSrc: cannot bind audio port");
}
m_agc.setClampMax(32768.0*32768.0);
m_agc.setClamping(true);
//DSPEngine::instance()->addAudioSink(&m_audioFifo);
2017-10-07 00:30:30 -04:00
applySettings(m_settings, true);
}
UDPSrc::~UDPSrc()
{
2015-12-02 22:02:21 -05:00
delete m_audioSocket;
delete m_udpBuffer;
delete m_udpBufferMono;
delete[] m_udpAudioBuf;
if (UDPFilter) delete UDPFilter;
2017-10-07 00:30:30 -04:00
if (m_settings.m_audioActive) DSPEngine::instance()->removeAudioSink(&m_audioFifo);
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
}
void UDPSrc::setSpectrum(MessageQueue* messageQueue, bool enabled)
{
Message* cmd = MsgUDPSrcSpectrum::create(enabled);
messageQueue->push(cmd);
}
void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly)
{
Complex ci;
fftfilt::cmplx* sideband;
double l, r;
m_sampleBuffer.clear();
m_settingsMutex.lock();
for(SampleVector::const_iterator it = begin; it < end; ++it)
{
Complex c(it->real(), it->imag());
c *= m_nco.nextIQ();
if(m_interpolator.decimate(&m_sampleDistanceRemain, c, &ci))
{
double inMagSq;
double agcFactor = 1.0;
2017-10-07 00:30:30 -04:00
if ((m_settings.m_agc) &&
(m_settings.m_sampleFormat != UDPSrcSettings::FormatNFM) &&
(m_settings.m_sampleFormat != UDPSrcSettings::FormatNFMMono) &&
(m_settings.m_sampleFormat != UDPSrcSettings::FormatS16LE))
{
agcFactor = m_agc.feedAndGetValue(ci);
inMagSq = m_agc.getMagSq();
}
else
{
inMagSq = ci.real()*ci.real() + ci.imag()*ci.imag();
}
m_inMovingAverage.feed(inMagSq / (1<<30));
m_inMagsq = m_inMovingAverage.average();
Sample ss(ci.real(), ci.imag());
m_sampleBuffer.push_back(ss);
2017-10-07 00:30:30 -04:00
m_sampleDistanceRemain += m_settings.m_inputSampleRate / m_settings.m_outputSampleRate;
calculateSquelch(m_inMagsq);
2017-10-07 00:30:30 -04:00
if (m_settings.m_sampleFormat == UDPSrcSettings::FormatLSB) // binaural LSB
{
ci *= agcFactor;
int n_out = UDPFilter->runSSB(ci, &sideband, false);
if (n_out)
{
for (int i = 0; i < n_out; i++)
{
2017-10-07 00:30:30 -04:00
l = m_squelchOpen ? sideband[i].real() * m_settings.m_gain : 0;
r = m_squelchOpen ? sideband[i].imag() * m_settings.m_gain : 0;
m_udpBuffer->write(Sample(l, r));
m_outMovingAverage.feed((l*l + r*r) / (1<<30));
}
}
}
2017-10-07 00:30:30 -04:00
if (m_settings.m_sampleFormat == UDPSrcSettings::FormatUSB) // binaural USB
2015-12-01 20:28:31 -05:00
{
ci *= agcFactor;
int n_out = UDPFilter->runSSB(ci, &sideband, true);
if (n_out)
2015-12-01 20:28:31 -05:00
{
for (int i = 0; i < n_out; i++)
{
2017-10-07 00:30:30 -04:00
l = m_squelchOpen ? sideband[i].real() * m_settings.m_gain : 0;
r = m_squelchOpen ? sideband[i].imag() * m_settings.m_gain : 0;
m_udpBuffer->write(Sample(l, r));
m_outMovingAverage.feed((l*l + r*r) / (1<<30));
}
}
}
2017-10-07 00:30:30 -04:00
else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatNFM)
2015-12-01 20:28:31 -05:00
{
2017-10-07 00:30:30 -04:00
double demod = m_squelchOpen ? 32768.0 * m_phaseDiscri.phaseDiscriminator(ci) * m_settings.m_gain : 0;
m_udpBuffer->write(Sample(demod, demod));
m_outMovingAverage.feed((demod * demod) / (1<<30));
}
2017-10-07 00:30:30 -04:00
else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatNFMMono)
{
2017-10-07 00:30:30 -04:00
FixReal demod = m_squelchOpen ? (FixReal) (32768.0f * m_phaseDiscri.phaseDiscriminator(ci) * m_settings.m_gain) : 0;
m_udpBufferMono->write(demod);
m_outMovingAverage.feed((demod * demod) / 1073741824.0);
}
2017-10-07 00:30:30 -04:00
else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatLSBMono) // Monaural LSB
{
ci *= agcFactor;
int n_out = UDPFilter->runSSB(ci, &sideband, false);
if (n_out)
{
for (int i = 0; i < n_out; i++)
{
2017-10-07 00:30:30 -04:00
l = m_squelchOpen ? (sideband[i].real() + sideband[i].imag()) * 0.7 * m_settings.m_gain : 0;
m_udpBufferMono->write(l);
m_outMovingAverage.feed((l * l) / (1<<30));
}
}
}
2017-10-07 00:30:30 -04:00
else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatUSBMono) // Monaural USB
{
ci *= agcFactor;
int n_out = UDPFilter->runSSB(ci, &sideband, true);
if (n_out)
{
for (int i = 0; i < n_out; i++)
{
2017-10-07 00:30:30 -04:00
l = m_squelchOpen ? (sideband[i].real() + sideband[i].imag()) * 0.7 * m_settings.m_gain : 0;
m_udpBufferMono->write(l);
m_outMovingAverage.feed((l * l) / (1<<30));
}
}
}
2017-10-07 00:30:30 -04:00
else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatAMMono)
{
2017-10-07 00:30:30 -04:00
FixReal demod = m_squelchOpen ? (FixReal) (sqrt(inMagSq) * agcFactor * m_settings.m_gain) : 0;
m_udpBufferMono->write(demod);
m_outMovingAverage.feed((demod * demod) / 1073741824.0);
}
2017-10-07 00:30:30 -04:00
else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatAMNoDCMono)
{
if (m_squelchOpen)
{
double demodf = sqrt(inMagSq);
m_amMovingAverage.feed(demodf);
2017-10-07 00:30:30 -04:00
FixReal demod = (FixReal) ((demodf - m_amMovingAverage.average()) * agcFactor * m_settings.m_gain);
m_udpBufferMono->write(demod);
m_outMovingAverage.feed((demod * demod) / 1073741824.0);
}
else
{
m_udpBufferMono->write(0);
m_outMovingAverage.feed(0);
}
}
2017-10-07 00:30:30 -04:00
else if (m_settings.m_sampleFormat == UDPSrcSettings::FormatAMBPFMono)
{
if (m_squelchOpen)
{
double demodf = sqrt(inMagSq);
demodf = m_bandpass.filter(demodf);
demodf /= 301.0;
2017-10-07 00:30:30 -04:00
FixReal demod = (FixReal) (demodf * agcFactor * m_settings.m_gain);
m_udpBufferMono->write(demod);
m_outMovingAverage.feed((demod * demod) / 1073741824.0);
}
else
{
m_udpBufferMono->write(0);
m_outMovingAverage.feed(0);
}
}
else // Raw I/Q samples
{
if (m_squelchOpen)
{
2017-10-07 00:30:30 -04:00
Sample s(ci.real() * m_settings.m_gain, ci.imag() * m_settings.m_gain);
m_udpBuffer->write(s);
2017-10-07 00:30:30 -04:00
m_outMovingAverage.feed((inMagSq*m_settings.m_gain*m_settings.m_gain) / (1<<30));
}
else
{
Sample s(0, 0);
m_udpBuffer->write(s);
m_outMovingAverage.feed(0);
}
}
m_magsq = m_outMovingAverage.average();
}
}
//qDebug() << "UDPSrc::feed: " << m_sampleBuffer.size() * 4;
if((m_spectrum != 0) && (m_spectrumEnabled))
2015-12-01 20:28:31 -05:00
{
m_spectrum->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), positiveOnly);
2015-12-01 20:28:31 -05:00
}
m_settingsMutex.unlock();
}
void UDPSrc::start()
{
m_phaseDiscri.reset();
}
void UDPSrc::stop()
{
}
bool UDPSrc::handleMessage(const Message& cmd)
{
if (DownChannelizer::MsgChannelizerNotification::match(cmd))
{
DownChannelizer::MsgChannelizerNotification& notif = (DownChannelizer::MsgChannelizerNotification&) cmd;
2017-10-07 00:30:30 -04:00
UDPSrcSettings settings;
settings.m_inputSampleRate = notif.getSampleRate();
settings.m_inputFrequencyOffset = notif.getFrequencyOffset();
2017-10-07 00:30:30 -04:00
//apply(false);
applySettings(settings);
2017-10-07 00:30:30 -04:00
qDebug() << "UDPSrc::handleMessage: MsgChannelizerNotification: m_inputSampleRate: " << settings.m_inputSampleRate
<< " frequencyOffset: " << notif.getFrequencyOffset();
return true;
}
else if (MsgConfigureChannelizer::match(cmd))
{
MsgConfigureChannelizer& cfg = (MsgConfigureChannelizer&) cmd;
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
cfg.getSampleRate(),
cfg.getCenterFrequency());
2017-10-06 23:44:43 -04:00
qDebug() << "UDPSrc::handleMessage: MsgConfigureChannelizer:"
<< " sampleRate: " << cfg.getSampleRate()
<< " centerFrequency: " << cfg.getCenterFrequency();
return true;
}
else if (MsgConfigureUDPSrc::match(cmd))
{
MsgConfigureUDPSrc& cfg = (MsgConfigureUDPSrc&) cmd;
UDPSrcSettings settings = cfg.getSettings();
// These settings are set with DownChannelizer::MsgChannelizerNotification
settings.m_inputSampleRate = m_settings.m_inputSampleRate;
settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset;
2017-10-07 00:30:30 -04:00
applySettings(settings, cfg.getForce());
2017-10-06 23:44:43 -04:00
qDebug() << "UDPSrc::handleMessage: MsgConfigureUDPSrc: "
2017-10-07 00:30:30 -04:00
<< " m_inputSampleRate: " << settings.m_inputSampleRate
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
<< " m_audioActive: " << settings.m_audioActive
<< " m_audioStereo: " << settings.m_audioStereo
<< " m_gain: " << settings.m_gain
<< " m_volume: " << settings.m_volume
<< " m_squelchEnabled: " << settings.m_squelchEnabled
<< " m_squelchdB: " << settings.m_squelchdB
<< " m_squelchGate" << settings.m_squelchGate
<< " m_agc" << settings.m_agc
<< " m_sampleFormat: " << settings.m_sampleFormat
<< " m_outputSampleRate: " << settings.m_outputSampleRate
<< " m_rfBandwidth: " << settings.m_rfBandwidth
<< " m_fmDeviation: " << settings.m_fmDeviation
<< " m_udpAddressStr: " << settings.m_udpAddress
<< " m_udpPort: " << settings.m_udpPort
<< " m_audioPort: " << settings.m_audioPort
2017-10-06 23:44:43 -04:00
<< " force: " << cfg.getForce();
return true;
}
else if (MsgUDPSrcSpectrum::match(cmd))
{
MsgUDPSrcSpectrum& spc = (MsgUDPSrcSpectrum&) cmd;
m_spectrumEnabled = spc.getEnabled();
2015-12-02 22:02:21 -05:00
qDebug() << "UDPSrc::handleMessage: MsgUDPSrcSpectrum: m_spectrumEnabled: " << m_spectrumEnabled;
return true;
}
else
{
if(m_spectrum != 0)
{
return m_spectrum->handleMessage(cmd);
}
else
{
return false;
}
}
}
2015-12-02 22:02:21 -05:00
2017-10-07 00:30:30 -04:00
void UDPSrc::audioReadyRead()
{
while (m_audioSocket->hasPendingDatagrams())
{
qint64 pendingDataSize = m_audioSocket->pendingDatagramSize();
qint64 udpReadBytes = m_audioSocket->readDatagram(m_udpAudioBuf, pendingDataSize, 0, 0);
//qDebug("UDPSrc::audioReadyRead: %lld", udpReadBytes);
if (m_settings.m_audioActive)
{
if (m_settings.m_audioStereo)
{
for (int i = 0; i < udpReadBytes - 3; i += 4)
{
qint16 l_sample = (qint16) *(&m_udpAudioBuf[i]);
qint16 r_sample = (qint16) *(&m_udpAudioBuf[i+2]);
m_audioBuffer[m_audioBufferFill].l = l_sample * m_settings.m_volume;
m_audioBuffer[m_audioBufferFill].r = r_sample * m_settings.m_volume;
++m_audioBufferFill;
if (m_audioBufferFill >= m_audioBuffer.size())
{
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
if (res != m_audioBufferFill)
{
qDebug("UDPSrc::audioReadyRead: (stereo) lost %u samples", m_audioBufferFill - res);
}
m_audioBufferFill = 0;
}
}
}
else
{
for (int i = 0; i < udpReadBytes - 1; i += 2)
{
qint16 sample = (qint16) *(&m_udpAudioBuf[i]);
m_audioBuffer[m_audioBufferFill].l = sample * m_settings.m_volume;
m_audioBuffer[m_audioBufferFill].r = sample * m_settings.m_volume;
++m_audioBufferFill;
if (m_audioBufferFill >= m_audioBuffer.size())
{
uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1);
if (res != m_audioBufferFill)
{
qDebug("UDPSrc::audioReadyRead: (mono) lost %u samples", m_audioBufferFill - res);
}
m_audioBufferFill = 0;
}
}
}
if (m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 0) != m_audioBufferFill)
{
qDebug("UDPSrc::audioReadyRead: lost samples");
}
m_audioBufferFill = 0;
}
}
//qDebug("UDPSrc::audioReadyRead: done");
}
void UDPSrc::applySettings(const UDPSrcSettings& settings, bool force)
{
m_settingsMutex.lock();
2017-10-07 00:30:30 -04:00
if ((settings.m_inputSampleRate != m_settings.m_inputSampleRate) ||
(settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) ||
(settings.m_rfBandwidth != m_settings.m_rfBandwidth) ||
(settings.m_outputSampleRate != m_settings.m_outputSampleRate) || force)
{
2017-10-07 00:30:30 -04:00
m_nco.setFreq(-settings.m_inputFrequencyOffset, settings.m_inputSampleRate);
m_interpolator.create(16, settings.m_inputSampleRate, settings.m_rfBandwidth / 2.0);
m_sampleDistanceRemain = settings.m_inputSampleRate / settings.m_outputSampleRate;
if ((settings.m_sampleFormat == UDPSrcSettings::FormatLSB) ||
(settings.m_sampleFormat == UDPSrcSettings::FormatLSBMono) ||
(settings.m_sampleFormat == UDPSrcSettings::FormatUSB) ||
(settings.m_sampleFormat == UDPSrcSettings::FormatUSBMono))
{
2017-10-07 00:30:30 -04:00
m_squelchGate = settings.m_outputSampleRate * 0.05;
}
else
{
2017-10-07 00:30:30 -04:00
m_squelchGate = (settings.m_outputSampleRate * settings.m_squelchGate) / 100;
}
2017-10-07 00:30:30 -04:00
m_squelchRelease = (settings.m_outputSampleRate * settings.m_squelchGate) / 100;
initSquelch(m_squelchOpen);
2017-10-07 00:30:30 -04:00
m_agc.resize(settings.m_outputSampleRate * 0.2, m_agcTarget); // Fixed 200 ms
int stepDownDelay = (settings.m_outputSampleRate * (settings.m_squelchGate == 0 ? 1 : settings.m_squelchGate))/100;
2017-10-06 23:44:43 -04:00
m_agc.setStepDownDelay(stepDownDelay);
2017-10-07 00:30:30 -04:00
m_agc.setGate(settings.m_outputSampleRate * 0.05);
2017-10-07 00:30:30 -04:00
m_bandpass.create(301, settings.m_outputSampleRate, 300.0, settings.m_rfBandwidth / 2.0f);
2017-10-07 00:30:30 -04:00
m_inMovingAverage.resize(settings.m_outputSampleRate * 0.01, 1e-10); // 10 ms
m_amMovingAverage.resize(settings.m_outputSampleRate * 0.005, 1e-10); // 5 ms
m_outMovingAverage.resize(settings.m_outputSampleRate * 0.01, 1e-10); // 10 ms
}
2017-10-07 00:30:30 -04:00
if ((settings.m_audioActive != m_settings.m_audioActive) || force)
{
2017-10-07 00:30:30 -04:00
if (settings.m_audioActive)
{
m_audioBufferFill = 0;
DSPEngine::instance()->addAudioSink(&m_audioFifo);
}
else
{
DSPEngine::instance()->removeAudioSink(&m_audioFifo);
}
}
2017-10-07 00:30:30 -04:00
if ((settings.m_squelchGate != m_settings.m_squelchGate) || force)
{
2017-10-07 00:30:30 -04:00
if ((settings.m_sampleFormat == UDPSrcSettings::FormatLSB) ||
(settings.m_sampleFormat == UDPSrcSettings::FormatLSBMono) ||
(settings.m_sampleFormat == UDPSrcSettings::FormatUSB) ||
(settings.m_sampleFormat == UDPSrcSettings::FormatUSBMono))
{
2017-10-07 00:30:30 -04:00
m_squelchGate = settings.m_outputSampleRate * 0.05;
}
else
{
2017-10-07 00:30:30 -04:00
m_squelchGate = (settings.m_outputSampleRate * settings.m_squelchGate)/100;
}
2017-10-07 00:30:30 -04:00
m_squelchRelease = (settings.m_outputSampleRate * settings.m_squelchGate)/100;
initSquelch(m_squelchOpen);
2017-10-07 00:30:30 -04:00
int stepDownDelay = (settings.m_outputSampleRate * (settings.m_squelchGate == 0 ? 1 : settings.m_squelchGate))/100;
2017-10-06 23:44:43 -04:00
m_agc.setStepDownDelay(stepDownDelay); // same delay for up and down
}
2017-10-07 00:30:30 -04:00
if ((settings.m_squelchdB != m_settings.m_squelchdB) || force)
{
2017-10-07 00:30:30 -04:00
m_squelch = CalcDb::powerFromdB(settings.m_squelchdB);
m_agc.setThreshold(m_squelch*(1<<23));
}
2017-10-07 00:30:30 -04:00
if ((settings.m_udpAddress != m_settings.m_udpAddress) || force)
{
2017-10-07 00:30:30 -04:00
m_udpBuffer->setAddress(const_cast<QString&>(settings.m_udpAddress));
m_udpBufferMono->setAddress(const_cast<QString&>(settings.m_udpAddress));
}
2017-10-07 00:30:30 -04:00
if ((settings.m_udpPort != m_settings.m_udpPort) || force)
{
2017-10-07 00:30:30 -04:00
m_udpBuffer->setPort(settings.m_udpPort);
m_udpBufferMono->setPort(settings.m_udpPort);
}
2017-10-07 00:30:30 -04:00
if ((settings.m_audioPort != m_settings.m_audioPort) || force)
{
disconnect(m_audioSocket, SIGNAL(readyRead()), this, SLOT(audioReadyRead()));
delete m_audioSocket;
m_audioSocket = new QUdpSocket(this);
2017-10-07 00:30:30 -04:00
if (m_audioSocket->bind(QHostAddress::LocalHost, settings.m_audioPort))
{
connect(m_audioSocket, SIGNAL(readyRead()), this, SLOT(audioReadyRead()), Qt::QueuedConnection);
2017-10-07 00:30:30 -04:00
qDebug("UDPSrc::handleMessage: audio socket bound to port %d", settings.m_audioPort);
}
else
{
qWarning("UDPSrc::handleMessage: cannot bind audio socket");
}
}
2017-10-07 00:30:30 -04:00
if ((settings.m_fmDeviation != m_settings.m_fmDeviation) || force)
{
2017-10-07 00:30:30 -04:00
m_phaseDiscri.setFMScaling((float) settings.m_outputSampleRate / (2.0f * settings.m_fmDeviation));
}
m_settingsMutex.unlock();
2017-10-07 00:30:30 -04:00
m_settings = settings;
2015-12-02 22:02:21 -05:00
}