mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-03-27 22:59:28 -04:00
FileInput: some code cosmetic changes
This commit is contained in:
parent
c75c35acad
commit
7cddf7ce0b
@ -122,7 +122,8 @@ void FileInput::openFileStream()
|
||||
m_recordLength = 0;
|
||||
}
|
||||
|
||||
if (getMessageQueueToGUI()) {
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgReportHeaderCRC *report = MsgReportHeaderCRC::create(crcOK);
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
@ -139,7 +140,8 @@ void FileInput::openFileStream()
|
||||
<< " center frequency: " << m_centerFrequency << " Hz"
|
||||
<< " sample size: " << m_sampleSize << " bits";
|
||||
|
||||
if (getMessageQueueToGUI()) {
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgReportFileInputStreamData *report = MsgReportFileInputStreamData::create(m_sampleRate,
|
||||
m_sampleSize,
|
||||
m_centerFrequency,
|
||||
@ -184,12 +186,14 @@ bool FileInput::start()
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
qDebug() << "FileInput::start";
|
||||
|
||||
if (m_ifstream.tellg() != (std::streampos)0) {
|
||||
if (m_ifstream.tellg() != (std::streampos)0)
|
||||
{
|
||||
m_ifstream.clear();
|
||||
m_ifstream.seekg(sizeof(FileRecord::Header), std::ios::beg);
|
||||
}
|
||||
|
||||
if(!m_sampleFifo.setSize(m_settings.m_accelerationFactor * m_sampleRate * sizeof(Sample))) {
|
||||
if (!m_sampleFifo.setSize(m_settings.m_accelerationFactor * m_sampleRate * sizeof(Sample)))
|
||||
{
|
||||
qCritical("Could not allocate SampleFifo");
|
||||
return false;
|
||||
}
|
||||
@ -204,7 +208,8 @@ bool FileInput::start()
|
||||
mutexLocker.unlock();
|
||||
qDebug("FileInput::startInput: started");
|
||||
|
||||
if (getMessageQueueToGUI()) {
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(true); // acquisition on
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
@ -226,7 +231,8 @@ void FileInput::stop()
|
||||
|
||||
m_deviceDescription.clear();
|
||||
|
||||
if (getMessageQueueToGUI()) {
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(false); // acquisition off
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
@ -329,7 +335,7 @@ bool FileInput::handleMessage(const Message& message)
|
||||
MsgConfigureFileInputWork& conf = (MsgConfigureFileInputWork&) message;
|
||||
bool working = conf.isWorking();
|
||||
|
||||
if (m_fileInputWorker != 0)
|
||||
if (m_fileInputWorker)
|
||||
{
|
||||
if (working) {
|
||||
startWorker();
|
||||
@ -352,7 +358,7 @@ bool FileInput::handleMessage(const Message& message)
|
||||
{
|
||||
MsgReportFileInputStreamTiming *report;
|
||||
|
||||
if (m_fileInputWorker != 0)
|
||||
if (m_fileInputWorker)
|
||||
{
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
@ -370,8 +376,7 @@ bool FileInput::handleMessage(const Message& message)
|
||||
|
||||
if (cmd.getStartStop())
|
||||
{
|
||||
if (m_deviceAPI->initDeviceEngine())
|
||||
{
|
||||
if (m_deviceAPI->initDeviceEngine()) {
|
||||
m_deviceAPI->startDeviceEngine();
|
||||
}
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ FileInputWorker::FileInputWorker(std::ifstream *samplesStream,
|
||||
QObject(parent),
|
||||
m_running(false),
|
||||
m_ifstream(samplesStream),
|
||||
m_fileBuf(0),
|
||||
m_convertBuf(0),
|
||||
m_fileBuf(nullptr),
|
||||
m_convertBuf(nullptr),
|
||||
m_bufsize(0),
|
||||
m_chunksize(0),
|
||||
m_sampleFifo(sampleFifo),
|
||||
@ -49,7 +49,7 @@ FileInputWorker::FileInputWorker(std::ifstream *samplesStream,
|
||||
m_throttlems(FILESOURCE_THROTTLE_MS),
|
||||
m_throttleToggle(false)
|
||||
{
|
||||
assert(m_ifstream != 0);
|
||||
assert(m_ifstream != nullptr);
|
||||
}
|
||||
|
||||
FileInputWorker::~FileInputWorker()
|
||||
@ -58,11 +58,11 @@ FileInputWorker::~FileInputWorker()
|
||||
stopWork();
|
||||
}
|
||||
|
||||
if (m_fileBuf != 0) {
|
||||
if (m_fileBuf) {
|
||||
free(m_fileBuf);
|
||||
}
|
||||
|
||||
if (m_convertBuf != 0) {
|
||||
if (m_convertBuf) {
|
||||
free(m_convertBuf);
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@ void FileInputWorker::setBuffers(std::size_t chunksize)
|
||||
m_bufsize = chunksize;
|
||||
int nbSamples = m_bufsize/(2 * m_samplebytes);
|
||||
|
||||
if (m_fileBuf == 0)
|
||||
if (!m_fileBuf)
|
||||
{
|
||||
qDebug() << "FileInputThread::setBuffers: Allocate file buffer";
|
||||
m_fileBuf = (quint8*) malloc(m_bufsize);
|
||||
@ -133,10 +133,13 @@ void FileInputWorker::setBuffers(std::size_t chunksize)
|
||||
qDebug() << "FileInputThread::setBuffers: Re-allocate file buffer";
|
||||
quint8 *buf = m_fileBuf;
|
||||
m_fileBuf = (quint8*) realloc((void*) m_fileBuf, m_bufsize);
|
||||
if (!m_fileBuf) free(buf);
|
||||
|
||||
if (!m_fileBuf) {
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_convertBuf == 0)
|
||||
if (!m_convertBuf)
|
||||
{
|
||||
qDebug() << "FileInputThread::setBuffers: Allocate conversion buffer";
|
||||
m_convertBuf = (quint8*) malloc(nbSamples*sizeof(Sample));
|
||||
@ -146,7 +149,10 @@ void FileInputWorker::setBuffers(std::size_t chunksize)
|
||||
qDebug() << "FileInputThread::setBuffers: Re-allocate conversion buffer";
|
||||
quint8 *buf = m_convertBuf;
|
||||
m_convertBuf = (quint8*) realloc((void*) m_convertBuf, nbSamples*sizeof(Sample));
|
||||
if (!m_convertBuf) free(buf);
|
||||
|
||||
if (!m_convertBuf) {
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "FileInputThread::setBuffers: size: " << m_bufsize
|
||||
|
Loading…
Reference in New Issue
Block a user