1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-27 02:09:14 -05:00
sdrangel/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkthread.h

88 lines
3.0 KiB
C
Raw Normal View History

2017-05-14 18:58:56 -04:00
///////////////////////////////////////////////////////////////////////////////////
// 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 <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_SDRDAEMONSINKTHREAD_H
#define INCLUDE_SDRDAEMONSINKTHREAD_H
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QTimer>
#include <QElapsedTimer>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <stdint.h>
#include "dsp/inthalfbandfilter.h"
#include "dsp/interpolators.h"
#include "udpsinkfec.h"
2017-05-14 18:58:56 -04:00
#define SDRDAEMONSINK_THROTTLE_MS 50
class SampleSourceFifo;
class SDRdaemonSinkThread : public QThread {
Q_OBJECT
public:
SDRdaemonSinkThread(SampleSourceFifo* sampleFifo, QObject* parent = 0);
2017-05-14 18:58:56 -04:00
~SDRdaemonSinkThread();
void startWork();
void stopWork();
2017-05-21 14:13:17 -04:00
void setCenterFrequency(uint64_t centerFrequency) { m_udpSinkFEC.setCenterFrequency(centerFrequency); }
2017-05-14 18:58:56 -04:00
void setSamplerate(int samplerate);
void setNbBlocksFEC(uint32_t nbBlocksFEC) { m_udpSinkFEC.setNbBlocksFEC(nbBlocksFEC); };
void setTxDelay(uint32_t txDelay) { m_udpSinkFEC.setTxDelay(txDelay); };
void setRemoteAddress(const QString& address, uint16_t port) { m_udpSinkFEC.setRemoteAddress(address, port); }
2017-05-21 14:13:17 -04:00
bool isRunning() const { return m_running; }
2017-05-14 18:58:56 -04:00
std::size_t getSamplesCount() const { return m_samplesCount; }
void setSamplesCount(int samplesCount) { m_samplesCount = samplesCount; }
void setChunkCorrection(int chunkCorrection) { m_chunkCorrection = chunkCorrection; }
2017-05-14 18:58:56 -04:00
void connectTimer(const QTimer& timer);
private:
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;
volatile bool m_running;
2017-05-14 18:58:56 -04:00
int m_samplesChunkSize;
2017-05-14 18:58:56 -04:00
SampleSourceFifo* m_sampleFifo;
std::size_t m_samplesCount;
int m_chunkCorrection;
2017-05-14 18:58:56 -04:00
int m_samplerate;
int m_throttlems;
int m_maxThrottlems;
QElapsedTimer m_elapsedTimer;
bool m_throttleToggle;
UDPSinkFEC m_udpSinkFEC;
2017-05-14 18:58:56 -04:00
void run();
private slots:
void tick();
};
#endif // INCLUDE_SDRDAEMONSINKTHREAD_H