mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-25 17:28:50 -05:00
SDRPlay V3 API - don't call close unless open was a success, as will crash on Mac,
This commit is contained in:
parent
e75900b666
commit
cdb78c903f
@ -43,25 +43,38 @@ static constexpr const char* const m_hardwareID = "SDRplayV3";
|
||||
static constexpr const char* const m_deviceTypeID = SDRPLAYV3_DEVICE_TYPE_ID;
|
||||
|
||||
SDRPlayV3Plugin::SDRPlayV3Plugin(QObject* parent) :
|
||||
QObject(parent)
|
||||
QObject(parent),
|
||||
m_opened(false)
|
||||
{
|
||||
sdrplay_api_ErrT err;
|
||||
float ver = 0.0f;
|
||||
|
||||
qDebug() << "SDRPlayV3Plugin: calling sdrplay_api_Open()";
|
||||
if ((err = sdrplay_api_Open()) != sdrplay_api_Success)
|
||||
qCritical() << "SDRPlayV3Plugin::SDRPlayV3Plugin: sdrplay_api_Open() was unsuccessful. " << sdrplay_api_GetErrorString(err);
|
||||
if ((err = sdrplay_api_Open()) == sdrplay_api_Success)
|
||||
{
|
||||
m_opened = true;
|
||||
|
||||
if ((err = sdrplay_api_ApiVersion(&ver)) != sdrplay_api_Success)
|
||||
qCritical() << "SDRPlayV3Plugin::SDRPlayV3Plugin: failed to get SDRPlay API version.";
|
||||
|
||||
if (ver != SDRPLAY_API_VERSION)
|
||||
if ((err = sdrplay_api_ApiVersion(&ver)) == sdrplay_api_Success)
|
||||
{
|
||||
if (ver != SDRPLAY_API_VERSION) {
|
||||
qCritical() << "SDRPlayV3Plugin::SDRPlayV3Plugin: SDRPlay API versions do not match " << ver << " " << SDRPLAY_API_VERSION;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "SDRPlayV3Plugin::SDRPlayV3Plugin: failed to get SDRPlay API version.";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "SDRPlayV3Plugin::SDRPlayV3Plugin: sdrplay_api_Open() was unsuccessful. " << sdrplay_api_GetErrorString(err);
|
||||
}
|
||||
}
|
||||
|
||||
SDRPlayV3Plugin::~SDRPlayV3Plugin()
|
||||
{
|
||||
if (m_opened) {
|
||||
sdrplay_api_Close();
|
||||
}
|
||||
}
|
||||
|
||||
const PluginDescriptor& SDRPlayV3Plugin::getPluginDescriptor() const
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
virtual DeviceWebAPIAdapter* createDeviceWebAPIAdapter() const;
|
||||
|
||||
private:
|
||||
bool m_opened; // Whether sdrplay_api_Open was successful
|
||||
static const PluginDescriptor m_pluginDescriptor;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user