diff --git a/plugins/channeltx/udpsink/CMakeLists.txt b/plugins/channeltx/udpsink/CMakeLists.txt index 3b35aaf2d..7e3fe30be 100644 --- a/plugins/channeltx/udpsink/CMakeLists.txt +++ b/plugins/channeltx/udpsink/CMakeLists.txt @@ -5,6 +5,7 @@ set(udpsink_SOURCES udpsinkgui.cpp udpsinkplugin.cpp udpsinkudphandler.cpp + udpsinkmsg.cpp ) set(udpsink_HEADERS @@ -12,6 +13,7 @@ set(udpsink_HEADERS udpsinkgui.h udpsinkplugin.h udpsinkudphandler.h + udpsinkmsg.h ) set(udpsink_FORMS diff --git a/plugins/channeltx/udpsink/udpsink.cpp b/plugins/channeltx/udpsink/udpsink.cpp index 257ea259a..4d44ef98b 100644 --- a/plugins/channeltx/udpsink/udpsink.cpp +++ b/plugins/channeltx/udpsink/udpsink.cpp @@ -17,6 +17,7 @@ #include #include "dsp/upchannelizer.h" +#include "udpsinkmsg.h" #include "udpsink.h" MESSAGE_CLASS_DEFINITION(UDPSink::MsgUDPSinkConfigure, Message) @@ -31,7 +32,7 @@ UDPSink::UDPSink(MessageQueue* uiMessageQueue, UDPSinkGUI* udpSinkGUI, BasebandS m_settingsMutex(QMutex::Recursive) { setObjectName("UDPSink"); - + m_udpHandler.setFeedbackMessageQueue(&m_inputMessageQueue); apply(true); } @@ -164,6 +165,11 @@ bool UDPSink::handleMessage(const Message& cmd) return true; } + else if (UDPSinkMessages::MsgSampleRateCorrection::match(cmd)) + { + // TODO + return true; + } else { return false; diff --git a/plugins/channeltx/udpsink/udpsinkmsg.cpp b/plugins/channeltx/udpsink/udpsinkmsg.cpp new file mode 100644 index 000000000..87f3cdbb4 --- /dev/null +++ b/plugins/channeltx/udpsink/udpsinkmsg.cpp @@ -0,0 +1,20 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "udpsinkmsg.h" + +MESSAGE_CLASS_DEFINITION(UDPSinkMessages::MsgSampleRateCorrection, Message) + diff --git a/plugins/channeltx/udpsink/udpsinkmsg.h b/plugins/channeltx/udpsink/udpsinkmsg.h new file mode 100644 index 000000000..1843250a9 --- /dev/null +++ b/plugins/channeltx/udpsink/udpsinkmsg.h @@ -0,0 +1,50 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef PLUGINS_CHANNELTX_UDPSINK_UDPSINKMSG_H_ +#define PLUGINS_CHANNELTX_UDPSINK_UDPSINKMSG_H_ + +#include "util/message.h" + +/** + * Message(s) used to communicate back from UDPSinkUDPHandler to UDPSink + */ +class UDPSinkMessages +{ +public: + class MsgSampleRateCorrection : public Message { + MESSAGE_CLASS_DECLARATION + + public: + float getCorrectionFactor() const { return m_correctionFactor; } + + static MsgSampleRateCorrection* create(float correctionFactor) + { + return new MsgSampleRateCorrection(correctionFactor); + } + + private: + float m_correctionFactor; + + MsgSampleRateCorrection(float correctionFactor) : + Message(), + m_correctionFactor(correctionFactor) + { } + }; +}; + + +#endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSINKMSG_H_ */ diff --git a/plugins/channeltx/udpsink/udpsinkudphandler.cpp b/plugins/channeltx/udpsink/udpsinkudphandler.cpp index e1e419217..1db891f4e 100644 --- a/plugins/channeltx/udpsink/udpsinkudphandler.cpp +++ b/plugins/channeltx/udpsink/udpsinkudphandler.cpp @@ -28,7 +28,8 @@ UDPSinkUDPHandler::UDPSinkUDPHandler() : m_writeIndex(0), m_readFrameIndex(m_nbUDPFrames/2), m_readIndex(0), - m_rwDelta(m_nbUDPFrames/2) + m_rwDelta(m_nbUDPFrames/2), + m_feedbackMessageQueue(0) { } diff --git a/plugins/channeltx/udpsink/udpsinkudphandler.h b/plugins/channeltx/udpsink/udpsinkudphandler.h index 17d74f697..a426f45a0 100644 --- a/plugins/channeltx/udpsink/udpsinkudphandler.h +++ b/plugins/channeltx/udpsink/udpsinkudphandler.h @@ -24,6 +24,8 @@ #include "dsp/dsptypes.h" +class MessageQueue; + class UDPSinkUDPHandler : public QObject { Q_OBJECT @@ -39,6 +41,8 @@ public: void readSample(Real &t); void readSample(Sample &s); + void setFeedbackMessageQueue(MessageQueue *messageQueue) { m_feedbackMessageQueue = messageQueue; } + /** Get buffer gauge value in % of buffer size ([-50:50]) * [-50:0] : write leads or read lags * [0:50] : read leads or write lags @@ -71,6 +75,7 @@ private: int m_readFrameIndex; int m_readIndex; int m_rwDelta; + MessageQueue *m_feedbackMessageQueue; };