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 <fstream>
|
|
|
|
#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-01-24 13:21:21 -05:00
|
|
|
class SDRdaemonThread : public QThread {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
SDRdaemonThread(std::ifstream *samplesStream, SampleFifo* sampleFifo, QObject* parent = NULL);
|
|
|
|
~SDRdaemonThread();
|
|
|
|
|
|
|
|
void startWork();
|
|
|
|
void stopWork();
|
2016-01-26 17:48:52 -05:00
|
|
|
void setSamplerate(uint32_t samplerate);
|
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;
|
|
|
|
|
|
|
|
std::ifstream* m_ifstream;
|
2016-01-24 17:38:55 -05:00
|
|
|
QUdpSocket *m_dataSocket;
|
2016-01-26 17:48:52 -05:00
|
|
|
QHostAddress m_dataAddress;
|
|
|
|
int m_dataPort;
|
|
|
|
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-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
|
|
|
|
|
|
|
void run();
|
|
|
|
private slots:
|
|
|
|
void tick();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_SDRDAEMONTHREAD_H
|