SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
filesinkthread.h
Go to the documentation of this file.
1 // Copyright (C) 2016 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #ifndef INCLUDE_FILESINKTHREAD_H
19 #define INCLUDE_FILESINKTHREAD_H
20 
21 #include <QThread>
22 #include <QMutex>
23 #include <QWaitCondition>
24 #include <QTimer>
25 #include <QElapsedTimer>
26 #include <iostream>
27 #include <fstream>
28 #include <cstdlib>
29 #include <stdint.h>
30 
31 #include "dsp/inthalfbandfilter.h"
32 #include "dsp/interpolators.h"
33 
34 #define FILESINK_THROTTLE_MS 50
35 
36 class SampleSourceFifo;
37 
38 class FileSinkThread : public QThread {
39  Q_OBJECT
40 
41 public:
42  FileSinkThread(std::ofstream *samplesStream, SampleSourceFifo* sampleFifo, QObject* parent = 0);
44 
45  void startWork();
46  void stopWork();
47  void setSamplerate(int samplerate);
48  void setLog2Interpolation(int log2Interpolation);
49  void setBuffer(std::size_t chunksize);
50  bool isRunning() const { return m_running; }
51  std::size_t getSamplesCount() const { return m_samplesCount; }
52  void setSamplesCount(int samplesCount) { m_samplesCount = samplesCount; }
53 
54  void connectTimer(const QTimer& timer);
55 
56 private:
58  QWaitCondition m_startWaiter;
59  volatile bool m_running;
60 
61  std::ofstream* m_ofstream;
62  std::size_t m_bufsize;
63  unsigned int m_samplesChunkSize;
65  std::size_t m_samplesCount;
66 
71  QElapsedTimer m_elapsedTimer;
73 
76 
77  void run();
78 
79 private slots:
80  void tick();
81 };
82 
83 #endif // INCLUDE_FILESINKTHREAD_H
short int16_t
Definition: rtptypes_win.h:43
void setLog2Interpolation(int log2Interpolation)
QWaitCondition m_startWaiter
volatile bool m_running
FileSinkThread(std::ofstream *samplesStream, SampleSourceFifo *sampleFifo, QObject *parent=0)
void setBuffer(std::size_t chunksize)
void setSamplesCount(int samplesCount)
unsigned int m_samplesChunkSize
int16_t * m_buf
QElapsedTimer m_elapsedTimer
SampleSourceFifo * m_sampleFifo
std::size_t m_samplesCount
std::size_t getSamplesCount() const
bool isRunning() const
std::size_t m_bufsize
Interpolators< qint16, SDR_TX_SAMP_SZ, 16 > m_interpolators
QMutex m_startWaitMutex
void connectTimer(const QTimer &timer)
std::ofstream * m_ofstream
void setSamplerate(int samplerate)