diff --git a/plugins/channel/udpsrc/udpsrc.cpp b/plugins/channel/udpsrc/udpsrc.cpp index b203dd611..9f950864f 100644 --- a/plugins/channel/udpsrc/udpsrc.cpp +++ b/plugins/channel/udpsrc/udpsrc.cpp @@ -46,6 +46,7 @@ UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* s m_outputSampleRate = 48000; m_rfBandwidth = 32000; m_udpPort = 9999; + m_audioPort = m_udpPort - 1; m_nco.setFreq(0, m_inputSampleRate); m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.0); m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate; @@ -64,9 +65,9 @@ UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* s m_sampleBufferSSB.resize(udpFftLen); UDPFilter = new fftfilt(0.3 / 48.0, 16.0 / 48.0, udpFftLen); - if (m_audioSocket->bind(QHostAddress::LocalHost, m_udpPort-1)) + if (m_audioSocket->bind(QHostAddress::LocalHost, m_audioPort)) { - qDebug("UDPSrc::UDPSrc: bind audio socket to port %d", m_udpPort - 1); + qDebug("UDPSrc::UDPSrc: bind audio socket to port %d", m_audioPort); connect(m_audioSocket, SIGNAL(readyRead()), this, SLOT(audioReadyRead())); } else @@ -91,6 +92,7 @@ void UDPSrc::configure(MessageQueue* messageQueue, Real rfBandwidth, QString& udpAddress, int udpPort, + int audioPort, bool audioActive) { Message* cmd = MsgUDPSrcConfigure::create(sampleFormat, @@ -98,6 +100,7 @@ void UDPSrc::configure(MessageQueue* messageQueue, rfBandwidth, udpAddress, udpPort, + audioPort, audioActive); messageQueue->push(cmd); } @@ -284,12 +287,15 @@ bool UDPSrc::handleMessage(const Message& cmd) if (cfg.getUDPPort() != m_udpPort) { m_udpPort = cfg.getUDPPort(); + } + if (cfg.getAudioPort() != m_audioPort) + { disconnect(m_audioSocket, SIGNAL(readyRead()), this, SLOT(audioReadyRead())); delete m_audioSocket; m_audioSocket = new QUdpSocket(this); - if (m_audioSocket->bind(QHostAddress::Any, m_udpPort-1)) + if (m_audioSocket->bind(QHostAddress::Any, m_audioPort)) { connect(m_audioSocket, SIGNAL(readyRead()), this, SLOT(audioReadyRead())); } @@ -334,7 +340,8 @@ bool UDPSrc::handleMessage(const Message& cmd) << " m_boost: " << m_boost << " m_udpAddress: " << cfg.getUDPAddress() << " m_udpPort: " << m_udpPort - << " m+audioActive: " << m_audioActive; + << " m_audioPort: " << m_audioPort + << " m_audioActive: " << m_audioActive; return true; } diff --git a/plugins/channel/udpsrc/udpsrc.h b/plugins/channel/udpsrc/udpsrc.h index b170286a8..c8c4b0c54 100644 --- a/plugins/channel/udpsrc/udpsrc.h +++ b/plugins/channel/udpsrc/udpsrc.h @@ -43,6 +43,7 @@ public: Real rfBandwidth, QString& udpAddress, int udpPort, + int audioPort, bool audioActive); void configureImmediate(MessageQueue* messageQueue, int boost, @@ -68,6 +69,7 @@ protected: Real getRFBandwidth() const { return m_rfBandwidth; } const QString& getUDPAddress() const { return m_udpAddress; } int getUDPPort() const { return m_udpPort; } + int getAudioPort() const { return m_audioPort; } bool getAudioActive() const { return m_audioActive; } static MsgUDPSrcConfigure* create(SampleFormat @@ -76,6 +78,7 @@ protected: Real rfBandwidth, QString& udpAddress, int udpPort, + int audioPort, bool audioActive) { return new MsgUDPSrcConfigure(sampleFormat, @@ -83,6 +86,7 @@ protected: rfBandwidth, udpAddress, udpPort, + audioPort, audioActive); } @@ -92,6 +96,7 @@ protected: Real m_rfBandwidth; QString m_udpAddress; int m_udpPort; + int m_audioPort; bool m_audioActive; MsgUDPSrcConfigure(SampleFormat sampleFormat, @@ -99,6 +104,7 @@ protected: Real rfBandwidth, QString& udpAddress, int udpPort, + int audioPort, bool audioActive) : Message(), m_sampleFormat(sampleFormat), @@ -106,6 +112,7 @@ protected: m_rfBandwidth(rfBandwidth), m_udpAddress(udpAddress), m_udpPort(udpPort), + m_audioPort(audioPort), m_audioActive(audioActive) { } }; @@ -171,6 +178,7 @@ protected: Real m_rfBandwidth; QHostAddress m_udpAddress; quint16 m_udpPort; + quint16 m_audioPort; int m_boost; bool m_audioActive; int m_volume; diff --git a/plugins/channel/udpsrc/udpsrcgui.cpp b/plugins/channel/udpsrc/udpsrcgui.cpp index b28d5dc86..86348989a 100644 --- a/plugins/channel/udpsrc/udpsrcgui.cpp +++ b/plugins/channel/udpsrc/udpsrcgui.cpp @@ -331,6 +331,7 @@ void UDPSrcGUI::applySettings() rfBandwidth, m_udpAddress, udpPort, + udpPort - 1, // TODO: replace with the audio port audioActive); ui->applyBtn->setEnabled(false);