mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-08-11 18:22:25 -04:00
FileSource: process record header if file is long enough. Else close file so that start is aborted with error
This commit is contained in:
parent
f4976485fc
commit
4a1376e474
@ -81,18 +81,23 @@ void FileSourceInput::openFileStream()
|
|||||||
|
|
||||||
m_ifstream.open(m_fileName.toStdString().c_str(), std::ios::binary | std::ios::ate);
|
m_ifstream.open(m_fileName.toStdString().c_str(), std::ios::binary | std::ios::ate);
|
||||||
quint64 fileSize = m_ifstream.tellg();
|
quint64 fileSize = m_ifstream.tellg();
|
||||||
m_ifstream.seekg(0,std::ios_base::beg);
|
|
||||||
FileRecord::Header header;
|
|
||||||
FileRecord::readHeader(m_ifstream, header);
|
|
||||||
|
|
||||||
m_sampleRate = header.sampleRate;
|
if (fileSize > sizeof(FileRecord::Header))
|
||||||
m_centerFrequency = header.centerFrequency;
|
{
|
||||||
m_startingTimeStamp = header.startTimeStamp;
|
// TODO: add CRC
|
||||||
m_sampleSize = header.sampleSize;
|
m_ifstream.seekg(0,std::ios_base::beg);
|
||||||
|
FileRecord::Header header;
|
||||||
|
FileRecord::readHeader(m_ifstream, header);
|
||||||
|
|
||||||
if (fileSize > sizeof(FileRecord::Header)) {
|
m_sampleRate = header.sampleRate;
|
||||||
m_recordLength = (fileSize - sizeof(FileRecord::Header)) / (4 * m_sampleRate);
|
m_centerFrequency = header.centerFrequency;
|
||||||
} else {
|
m_startingTimeStamp = header.startTimeStamp;
|
||||||
|
m_sampleSize = header.sampleSize;
|
||||||
|
|
||||||
|
m_recordLength = (fileSize - sizeof(FileRecord::Header)) / (4 * m_sampleRate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_recordLength = 0;
|
m_recordLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +113,10 @@ void FileSourceInput::openFileStream()
|
|||||||
m_recordLength); // file stream data
|
m_recordLength); // file stream data
|
||||||
getMessageQueueToGUI()->push(report);
|
getMessageQueueToGUI()->push(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_recordLength == 0) {
|
||||||
|
m_ifstream.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSourceInput::seekFileStream(int seekPercentage)
|
void FileSourceInput::seekFileStream(int seekPercentage)
|
||||||
@ -132,6 +141,12 @@ void FileSourceInput::init()
|
|||||||
|
|
||||||
bool FileSourceInput::start()
|
bool FileSourceInput::start()
|
||||||
{
|
{
|
||||||
|
if (!m_ifstream.is_open())
|
||||||
|
{
|
||||||
|
qWarning("FileSourceInput::start: file not open. not starting");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
qDebug() << "FileSourceInput::start";
|
qDebug() << "FileSourceInput::start";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user