2016-01-24 13:21:21 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 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 <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef INCLUDE_SDRDAEMONTHREAD_H
|
|
|
|
#define INCLUDE_SDRDAEMONTHREAD_H
|
|
|
|
|
|
|
|
#include <QThread>
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QWaitCondition>
|
|
|
|
#include <QTimer>
|
2016-01-26 17:48:52 -05:00
|
|
|
#include <QHostAddress>
|
2016-01-24 17:38:55 -05:00
|
|
|
|
2016-01-24 13:21:21 -05:00
|
|
|
#include <iostream>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include "dsp/samplefifo.h"
|
|
|
|
#include "dsp/inthalfbandfilter.h"
|
2016-01-26 17:48:52 -05:00
|
|
|
#include "sdrdaemonbuffer.h"
|
2016-01-24 13:21:21 -05:00
|
|
|
|
|
|
|
#define SDRDAEMON_THROTTLE_MS 50
|
|
|
|
|
2016-01-24 17:38:55 -05:00
|
|
|
class QUdpSocket;
|
2016-02-14 14:01:46 -05:00
|
|
|
class MessageQueue;
|
2016-01-24 17:38:55 -05:00
|
|
|
|
2016-01-24 13:21:21 -05:00
|
|
|
class SDRdaemonThread : public QThread {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-02-14 14:01:46 -05:00
|
|
|
SDRdaemonThread(SampleFifo* sampleFifo, MessageQueue *outputMessageQueueToGUI, QObject* parent = NULL);
|
2016-01-24 13:21:21 -05:00
|
|
|
~SDRdaemonThread();
|
|
|
|
|
|
|
|
void startWork();
|
|
|
|
void stopWork();
|
2016-02-01 02:24:14 -05:00
|
|
|
void updateLink(const QString& address, quint16 port);
|
2016-01-24 13:21:21 -05:00
|
|
|
bool isRunning() const { return m_running; }
|
|
|
|
std::size_t getSamplesCount() const { return m_samplesCount; }
|
|
|
|
|
|
|
|
void connectTimer(const QTimer& timer);
|
|
|
|
|
2016-01-26 17:48:52 -05:00
|
|
|
public slots:
|
|
|
|
void dataReadyRead();
|
|
|
|
|
2016-01-24 13:21:21 -05:00
|
|
|
private:
|
|
|
|
QMutex m_startWaitMutex;
|
|
|
|
QWaitCondition m_startWaiter;
|
|
|
|
bool m_running;
|
|
|
|
|
2016-01-24 17:38:55 -05:00
|
|
|
QUdpSocket *m_dataSocket;
|
2016-01-26 17:48:52 -05:00
|
|
|
QHostAddress m_dataAddress;
|
2016-02-07 14:02:13 -05:00
|
|
|
quint16 m_dataPort;
|
2016-01-26 17:48:52 -05:00
|
|
|
bool m_dataConnected;
|
|
|
|
quint8 *m_buf;
|
|
|
|
char *m_udpBuf;
|
2016-01-24 13:21:21 -05:00
|
|
|
std::size_t m_bufsize;
|
|
|
|
std::size_t m_chunksize;
|
|
|
|
SampleFifo* m_sampleFifo;
|
|
|
|
std::size_t m_samplesCount;
|
|
|
|
|
2016-01-26 17:48:52 -05:00
|
|
|
SDRdaemonBuffer m_sdrDaemonBuffer;
|
|
|
|
|
|
|
|
uint32_t m_samplerate;
|
2016-02-14 14:01:46 -05:00
|
|
|
uint32_t m_centerFrequency;
|
|
|
|
MessageQueue *m_outputMessageQueueToGUI;
|
2016-01-24 13:21:21 -05:00
|
|
|
static const int m_rateDivider;
|
2016-01-26 17:48:52 -05:00
|
|
|
static const int m_udpPayloadSize;
|
2016-01-24 13:21:21 -05:00
|
|
|
|
2016-02-07 14:02:13 -05:00
|
|
|
void setSamplerate(uint32_t samplerate);
|
2016-01-24 13:21:21 -05:00
|
|
|
void run();
|
|
|
|
private slots:
|
|
|
|
void tick();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_SDRDAEMONTHREAD_H
|