mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-04 16:01:14 -05:00
Check sample rate is non-zero to avoid divide by zero
This commit is contained in:
parent
156d7b543a
commit
802749afd3
@ -110,16 +110,21 @@ void FileInput::openFileStream()
|
|||||||
m_sampleSize = header.sampleSize;
|
m_sampleSize = header.sampleSize;
|
||||||
QString crcHex = QString("%1").arg(header.crc32 , 0, 16);
|
QString crcHex = QString("%1").arg(header.crc32 , 0, 16);
|
||||||
|
|
||||||
if (crcOK)
|
if (crcOK && (m_sampleRate > 0) && (m_sampleSize > 0))
|
||||||
{
|
{
|
||||||
qDebug("FileInput::openFileStream: CRC32 OK for header: %s", qPrintable(crcHex));
|
qDebug("FileInput::openFileStream: CRC32 OK for header: %s", qPrintable(crcHex));
|
||||||
m_recordLengthMuSec = ((fileSize - sizeof(FileRecord::Header)) * 1000000UL) / ((m_sampleSize == 24 ? 8 : 4) * m_sampleRate);
|
m_recordLengthMuSec = ((fileSize - sizeof(FileRecord::Header)) * 1000000UL) / ((m_sampleSize == 24 ? 8 : 4) * m_sampleRate);
|
||||||
}
|
}
|
||||||
else
|
else if (!crcOK)
|
||||||
{
|
{
|
||||||
qCritical("FileInput::openFileStream: bad CRC32 for header: %s", qPrintable(crcHex));
|
qCritical("FileInput::openFileStream: bad CRC32 for header: %s", qPrintable(crcHex));
|
||||||
m_recordLengthMuSec = 0;
|
m_recordLengthMuSec = 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qCritical("FileInput::openFileStream: invalid header");
|
||||||
|
m_recordLengthMuSec = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (getMessageQueueToGUI())
|
if (getMessageQueueToGUI())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user