mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-16 05:11:49 -05:00
AirspyHF: prevent segfault with wrong sample rate index when the Airspy HF is not opened (yet)
This commit is contained in:
parent
9162a51f41
commit
790e5d3bc8
@ -82,18 +82,19 @@ bool AirspyHFInput::openDevice()
|
|||||||
|
|
||||||
if (!m_sampleFifo.setSize(1<<19))
|
if (!m_sampleFifo.setSize(1<<19))
|
||||||
{
|
{
|
||||||
qCritical("AirspyHFInput::start: could not allocate SampleFifo");
|
qCritical("AirspyHFInput::openDevice: could not allocate SampleFifo");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_dev = open_airspyhf_from_serial(m_deviceAPI->getSampleSourceSerial())) == 0)
|
if ((m_dev = open_airspyhf_from_serial(m_deviceAPI->getSampleSourceSerial())) == 0)
|
||||||
{
|
{
|
||||||
qCritical("AirspyHFInput::start: could not open Airspy HF with serial %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
|
qCritical("AirspyHFInput::openDevice: could not open Airspy HF with serial %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
|
||||||
|
m_dev = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug("AirspyHFInput::start: opened Airspy HF with serial %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
|
qDebug("AirspyHFInput::openDevice: opened Airspy HF with serial %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t nbSampleRates;
|
uint32_t nbSampleRates;
|
||||||
@ -103,11 +104,12 @@ bool AirspyHFInput::openDevice()
|
|||||||
|
|
||||||
if (rc == AIRSPYHF_SUCCESS)
|
if (rc == AIRSPYHF_SUCCESS)
|
||||||
{
|
{
|
||||||
qDebug("AirspyHFInput::start: %d sample rates for Airspy HF", nbSampleRates);
|
qDebug("AirspyHFInput::openDevice: %d sample rates for Airspy HF", nbSampleRates);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qCritical("AirspyHFInput::start: could not obtain the number of Airspy HF sample rates");
|
qCritical("AirspyHFInput::openDevice: could not obtain the number of Airspy HF sample rates");
|
||||||
|
closeDevice();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,11 +119,12 @@ bool AirspyHFInput::openDevice()
|
|||||||
|
|
||||||
if (rc == AIRSPYHF_SUCCESS)
|
if (rc == AIRSPYHF_SUCCESS)
|
||||||
{
|
{
|
||||||
qDebug("AirspyHFInput::start: obtained Airspy HF sample rates");
|
qDebug("AirspyHFInput::openDevice: obtained Airspy HF sample rates");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qCritical("AirspyHFInput::start: could not obtain Airspy HF sample rates");
|
qCritical("AirspyHFInput::openDevice: could not obtain Airspy HF sample rates");
|
||||||
|
closeDevice();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +133,7 @@ bool AirspyHFInput::openDevice()
|
|||||||
for (unsigned int i = 0; i < nbSampleRates; i++)
|
for (unsigned int i = 0; i < nbSampleRates; i++)
|
||||||
{
|
{
|
||||||
m_sampleRates.push_back(sampleRates[i]);
|
m_sampleRates.push_back(sampleRates[i]);
|
||||||
qDebug("AirspyHFInput::start: sampleRates[%d] = %u Hz", i, sampleRates[i]);
|
qDebug("AirspyHFInput::openDevice: sampleRates[%d] = %u Hz", i, sampleRates[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] sampleRates;
|
delete[] sampleRates;
|
||||||
@ -408,10 +411,10 @@ bool AirspyHFInput::applySettings(const AirspyHFSettings& settings, bool force)
|
|||||||
deviceCenterFrequency -= settings.m_transverterMode ? settings.m_transverterDeltaFrequency : 0;
|
deviceCenterFrequency -= settings.m_transverterMode ? settings.m_transverterDeltaFrequency : 0;
|
||||||
deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency;
|
deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency;
|
||||||
qint64 f_img = deviceCenterFrequency;
|
qint64 f_img = deviceCenterFrequency;
|
||||||
quint32 devSampleRate = m_sampleRates[sampleRateIndex];
|
|
||||||
|
|
||||||
if (m_dev != 0)
|
if (m_dev != 0)
|
||||||
{
|
{
|
||||||
|
quint32 devSampleRate = m_sampleRates[sampleRateIndex];
|
||||||
setDeviceCenterFrequency(deviceCenterFrequency, settings);
|
setDeviceCenterFrequency(deviceCenterFrequency, settings);
|
||||||
|
|
||||||
qDebug() << "AirspyHFInput::applySettings: center freq: " << settings.m_centerFrequency << " Hz"
|
qDebug() << "AirspyHFInput::applySettings: center freq: " << settings.m_centerFrequency << " Hz"
|
||||||
@ -424,7 +427,7 @@ bool AirspyHFInput::applySettings(const AirspyHFSettings& settings, bool force)
|
|||||||
forwardChange = true;
|
forwardChange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forwardChange)
|
if (forwardChange && (sampleRateIndex >= 0))
|
||||||
{
|
{
|
||||||
int sampleRate = m_sampleRates[sampleRateIndex]/(1<<settings.m_log2Decim);
|
int sampleRate = m_sampleRates[sampleRateIndex]/(1<<settings.m_log2Decim);
|
||||||
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, settings.m_centerFrequency);
|
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, settings.m_centerFrequency);
|
||||||
@ -433,7 +436,6 @@ bool AirspyHFInput::applySettings(const AirspyHFSettings& settings, bool force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
m_settings.m_devSampleRateIndex = sampleRateIndex;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user