diff --git a/plugins/channel/udpsrc/udpsrc.cpp b/plugins/channel/udpsrc/udpsrc.cpp index b780c2ca6..516881633 100644 --- a/plugins/channel/udpsrc/udpsrc.cpp +++ b/plugins/channel/udpsrc/udpsrc.cpp @@ -31,6 +31,7 @@ UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* s m_settingsMutex(QMutex::Recursive), m_audioFifo(4, 24000), m_audioActive(false), + m_audioStereo(false), m_volume(20) { setObjectName("UDPSrc"); @@ -382,24 +383,49 @@ void UDPSrc::audioReadyRead() if (m_audioActive) { - for (int i = 0; i < buffer.size() - 3; i += 4) + if (m_audioStereo) { - qint16 l_sample = (qint16) *(&buffer.data()[i]); - qint16 r_sample = (qint16) *(&buffer.data()[i+2]); - m_audioBuffer[m_audioBufferFill].l = l_sample * 10 * m_volume; - m_audioBuffer[m_audioBufferFill].r = r_sample * 10 * m_volume; - ++m_audioBufferFill; - - if (m_audioBufferFill >= m_audioBuffer.size()) + for (int i = 0; i < buffer.size() - 3; i += 4) { - uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1); + qint16 l_sample = (qint16) *(&buffer.data()[i]); + qint16 r_sample = (qint16) *(&buffer.data()[i+2]); + m_audioBuffer[m_audioBufferFill].l = l_sample * 10 * m_volume; + m_audioBuffer[m_audioBufferFill].r = r_sample * 10 * m_volume; + ++m_audioBufferFill; - if (res != m_audioBufferFill) + if (m_audioBufferFill >= m_audioBuffer.size()) { - qDebug("UDPSrc::audioReadyRead: lost %u samples", m_audioBufferFill - res); - } + uint res = m_audioFifo.write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1); - m_audioBufferFill = 0; + if (res != m_audioBufferFill) + { + qDebug("UDPSrc::audioReadyRead: (stereo) lost %u samples", m_audioBufferFill - res); + } + + m_audioBufferFill = 0; + } + } + } + else + { + for (int i = 0; i < buffer.size() - 1; i += 2) + { + qint16 sample = (qint16) *(&buffer.data()[i]); + m_audioBuffer[m_audioBufferFill].l = sample * 10 * m_volume; + m_audioBuffer[m_audioBufferFill].r = sample * 10 * 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; + } } } diff --git a/plugins/channel/udpsrc/udpsrc.h b/plugins/channel/udpsrc/udpsrc.h index c8c4b0c54..874288f45 100644 --- a/plugins/channel/udpsrc/udpsrc.h +++ b/plugins/channel/udpsrc/udpsrc.h @@ -181,6 +181,7 @@ protected: quint16 m_audioPort; int m_boost; bool m_audioActive; + bool m_audioStereo; int m_volume; Real m_magsq; diff --git a/plugins/channel/udpsrc/udpsrcgui.cpp b/plugins/channel/udpsrc/udpsrcgui.cpp index 568e646f5..c69fa25f7 100644 --- a/plugins/channel/udpsrc/udpsrcgui.cpp +++ b/plugins/channel/udpsrc/udpsrcgui.cpp @@ -402,7 +402,7 @@ void UDPSrcGUI::on_applyBtn_clicked() applySettings(); } -void UDPSrcGUI::on_audioActive_toggled(bool checked) +void UDPSrcGUI::on_audioActive_toggled(bool active) { ui->applyBtn->setEnabled(true); } diff --git a/plugins/channel/udpsrc/udpsrcgui.h b/plugins/channel/udpsrc/udpsrcgui.h index 0fae6df23..8971de9e2 100644 --- a/plugins/channel/udpsrc/udpsrcgui.h +++ b/plugins/channel/udpsrc/udpsrcgui.h @@ -47,7 +47,7 @@ private slots: void on_udpAddress_textEdited(const QString& arg1); void on_udpPort_textEdited(const QString& arg1); void on_audioPort_textEdited(const QString& arg1); - void on_audioActive_toggled(bool checked); + void on_audioActive_toggled(bool active); void on_applyBtn_clicked(); void onWidgetRolled(QWidget* widget, bool rollDown); void onMenuDoubleClicked(); diff --git a/plugins/channel/udpsrc/udpsrcgui.ui b/plugins/channel/udpsrc/udpsrcgui.ui index 9be79fa62..57e1d3f7b 100644 --- a/plugins/channel/udpsrc/udpsrcgui.ui +++ b/plugins/channel/udpsrc/udpsrcgui.ui @@ -167,6 +167,9 @@ + + Frequency shift direction + ... @@ -323,16 +326,6 @@ - - - - Activate audio - - - - - - @@ -343,6 +336,24 @@ + + + + Toggle audio input + + + ... + + + + :/sound_off.png + :/sound_on.png:/sound_off.png + + + true + + + diff --git a/sdrbase/resources/mono.png b/sdrbase/resources/mono.png new file mode 100644 index 000000000..d99257e7b Binary files /dev/null and b/sdrbase/resources/mono.png differ diff --git a/sdrbase/resources/res.qrc b/sdrbase/resources/res.qrc index ca493175f..332524034 100644 --- a/sdrbase/resources/res.qrc +++ b/sdrbase/resources/res.qrc @@ -37,5 +37,9 @@ mem.png minusw.png plusw.png + mono.png + stereo.png + sound_off.png + sound_on.png diff --git a/sdrbase/resources/sound_off.png b/sdrbase/resources/sound_off.png new file mode 100644 index 000000000..bee07d8fe Binary files /dev/null and b/sdrbase/resources/sound_off.png differ diff --git a/sdrbase/resources/sound_on.png b/sdrbase/resources/sound_on.png new file mode 100644 index 000000000..9d0ccec26 Binary files /dev/null and b/sdrbase/resources/sound_on.png differ diff --git a/sdrbase/resources/stereo.png b/sdrbase/resources/stereo.png new file mode 100644 index 000000000..77a319ec5 Binary files /dev/null and b/sdrbase/resources/stereo.png differ