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;
|
|
|
|
|
|
|
|
class SDRPlayInput : public DeviceSampleSource {
|
|
|
|
public:
|
|
|
|
class MsgConfigureSDRPlay : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const SDRPlaySettings& getSettings() const { return m_settings; }
|
|
|
|
|
|
|
|
static MsgConfigureSDRPlay* create(const SDRPlaySettings& settings)
|
|
|
|
{
|
|
|
|
return new MsgConfigureSDRPlay(settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SDRPlaySettings m_settings;
|
|
|
|
|
|
|
|
MsgConfigureSDRPlay(const SDRPlaySettings& settings) :
|
|
|
|
Message(),
|
|
|
|
m_settings(settings)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
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
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
SDRPlayInput(DeviceSourceAPI *deviceAPI);
|
|
|
|
virtual ~SDRPlayInput();
|
|
|
|
|
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;
|
2016-11-12 20:59:31 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYINPUT_H_ */
|