2016-11-12 20:59:31 -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 PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYINPUT_H_
|
|
|
|
#define PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYINPUT_H_
|
|
|
|
|
|
|
|
#include <dsp/devicesamplesource.h>
|
|
|
|
|
|
|
|
#include "sdrplaysettings.h"
|
2016-11-15 12:58:17 -05:00
|
|
|
#include <mirisdr.h>
|
2016-11-12 20:59:31 -05:00
|
|
|
#include <QString>
|
2016-11-15 12:58:17 -05:00
|
|
|
#include <stdint.h>
|
2016-11-12 20:59:31 -05:00
|
|
|
|
|
|
|
class DeviceSourceAPI;
|
|
|
|
class SDRPlayThread;
|
2017-09-04 18:40:42 -04:00
|
|
|
class FileRecord;
|
2016-11-12 20:59:31 -05:00
|
|
|
|
|
|
|
class SDRPlayInput : public DeviceSampleSource {
|
|
|
|
public:
|
|
|
|
class MsgConfigureSDRPlay : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const SDRPlaySettings& getSettings() const { return m_settings; }
|
2017-10-14 01:02:21 -04:00
|
|
|
bool getForce() const { return m_force; }
|
2016-11-12 20:59:31 -05:00
|
|
|
|
2017-10-14 01:02:21 -04:00
|
|
|
static MsgConfigureSDRPlay* create(const SDRPlaySettings& settings, bool force)
|
2016-11-12 20:59:31 -05:00
|
|
|
{
|
2017-10-14 01:02:21 -04:00
|
|
|
return new MsgConfigureSDRPlay(settings, force);
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SDRPlaySettings m_settings;
|
2017-10-14 01:02:21 -04:00
|
|
|
bool m_force;
|
2016-11-12 20:59:31 -05:00
|
|
|
|
2017-10-14 01:02:21 -04:00
|
|
|
MsgConfigureSDRPlay(const SDRPlaySettings& settings, bool force) :
|
2016-11-12 20:59:31 -05:00
|
|
|
Message(),
|
2017-10-14 01:02:21 -04:00
|
|
|
m_settings(settings),
|
|
|
|
m_force(force)
|
2016-11-12 20:59:31 -05:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2016-11-17 20:46:35 -05:00
|
|
|
class MsgReportSDRPlayGains : public Message {
|
2016-11-12 20:59:31 -05:00
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2016-11-17 20:46:35 -05:00
|
|
|
static MsgReportSDRPlayGains* create(int lnaGain, int mixerGain, int basebandGain, int tunerGain)
|
2016-11-12 20:59:31 -05:00
|
|
|
{
|
2016-11-17 20:46:35 -05:00
|
|
|
return new MsgReportSDRPlayGains(lnaGain, mixerGain, basebandGain, tunerGain);
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
|
|
|
|
2016-11-17 20:46:35 -05:00
|
|
|
int getLNAGain() const { return m_lnaGain; }
|
|
|
|
int getMixerGain() const { return m_mixerGain; }
|
|
|
|
int getBasebandGain() const { return m_basebandGain; }
|
|
|
|
int getTunerGain() const { return m_tunerGain; }
|
|
|
|
|
2016-11-12 20:59:31 -05:00
|
|
|
protected:
|
2016-11-17 20:46:35 -05:00
|
|
|
int m_lnaGain;
|
|
|
|
int m_mixerGain;
|
|
|
|
int m_basebandGain;
|
|
|
|
int m_tunerGain;
|
2016-11-15 12:58:17 -05:00
|
|
|
|
2016-11-17 20:46:35 -05:00
|
|
|
MsgReportSDRPlayGains(int lnaGain, int mixerGain, int basebandGain, int tunerGain) :
|
2016-11-15 12:58:17 -05:00
|
|
|
Message(),
|
2016-11-17 20:46:35 -05:00
|
|
|
m_lnaGain(lnaGain),
|
|
|
|
m_mixerGain(mixerGain),
|
|
|
|
m_basebandGain(basebandGain),
|
|
|
|
m_tunerGain(tunerGain)
|
2016-11-12 20:59:31 -05:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-09-04 18:40:42 -04:00
|
|
|
class MsgFileRecord : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getStartStop() const { return m_startStop; }
|
|
|
|
|
|
|
|
static MsgFileRecord* create(bool startStop) {
|
|
|
|
return new MsgFileRecord(startStop);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_startStop;
|
|
|
|
|
|
|
|
MsgFileRecord(bool startStop) :
|
|
|
|
Message(),
|
|
|
|
m_startStop(startStop)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2016-11-12 20:59:31 -05:00
|
|
|
SDRPlayInput(DeviceSourceAPI *deviceAPI);
|
|
|
|
virtual ~SDRPlayInput();
|
2017-09-14 20:32:30 -04:00
|
|
|
virtual void destroy();
|
2016-11-12 20:59:31 -05:00
|
|
|
|
2017-04-13 21:40:45 -04:00
|
|
|
virtual bool start();
|
2016-11-12 20:59:31 -05:00
|
|
|
virtual void stop();
|
|
|
|
|
|
|
|
virtual const QString& getDeviceDescription() const;
|
|
|
|
virtual int getSampleRate() const;
|
|
|
|
virtual quint64 getCenterFrequency() const;
|
|
|
|
|
|
|
|
virtual bool handleMessage(const Message& message);
|
|
|
|
|
|
|
|
private:
|
2017-04-13 20:49:41 -04:00
|
|
|
bool openDevice();
|
|
|
|
void closeDevice();
|
2016-11-18 22:11:19 -05:00
|
|
|
bool applySettings(const SDRPlaySettings& settings, bool forwardChange, bool force);
|
2016-11-15 20:38:21 -05:00
|
|
|
bool setCenterFrequency(quint64 freq);
|
2016-11-12 20:59:31 -05:00
|
|
|
|
|
|
|
DeviceSourceAPI *m_deviceAPI;
|
|
|
|
QMutex m_mutex;
|
|
|
|
SDRPlaySettings m_settings;
|
2016-11-15 12:58:17 -05:00
|
|
|
mirisdr_dev_t* m_dev;
|
2016-11-12 20:59:31 -05:00
|
|
|
SDRPlayThread* m_sdrPlayThread;
|
|
|
|
QString m_deviceDescription;
|
2016-11-18 22:11:19 -05:00
|
|
|
int m_devNumber;
|
2017-04-13 20:49:41 -04:00
|
|
|
bool m_running;
|
2017-09-04 18:40:42 -04:00
|
|
|
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
2016-11-12 20:59:31 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYINPUT_H_ */
|