1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-25 12:12:02 -05:00

File Input: fixed wrong times display on file seek when sample count exceeds int limit (use of int64 and uint64)

This commit is contained in:
f4exb 2018-10-12 17:05:03 +02:00
parent a7b954dbf8
commit 678af4e186
9 changed files with 41 additions and 42 deletions

View File

@ -35,7 +35,7 @@ static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *lo
*/
QCoreApplication::setOrganizationName("f4exb");
QCoreApplication::setApplicationName("SDRangel");
QCoreApplication::setApplicationVersion("4.2.1");
QCoreApplication::setApplicationVersion("4.2.2");
#if 1
qApp->setStyle(QStyleFactory::create("fusion"));

View File

@ -57,7 +57,7 @@ static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *lo
QCoreApplication::setOrganizationName("f4exb");
QCoreApplication::setApplicationName("SDRangelBench");
QCoreApplication::setApplicationVersion("4.2.1");
QCoreApplication::setApplicationVersion("4.2.2");
int catchSignals[] = {SIGQUIT, SIGINT, SIGTERM, SIGHUP};
std::vector<int> vsig(catchSignals, catchSignals + sizeof(catchSignals) / sizeof(int));

View File

@ -56,7 +56,7 @@ static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *lo
QCoreApplication::setOrganizationName("f4exb");
QCoreApplication::setApplicationName("SDRangelSrv");
QCoreApplication::setApplicationVersion("4.2.1");
QCoreApplication::setApplicationVersion("4.2.2");
int catchSignals[] = {SIGQUIT, SIGINT, SIGTERM, SIGHUP};
std::vector<int> vsig(catchSignals, catchSignals + sizeof(catchSignals) / sizeof(int));

View File

@ -286,10 +286,6 @@ void FileSourceGui::on_navTimeSlider_valueChanged(int value)
{
if (m_enableNavTime && ((value >= 0) && (value <= 100)))
{
int t_sec = (m_recordLength * value) / 100;
QTime t(0, 0, 0, 0);
t = t.addSecs(t_sec);
FileSourceInput::MsgConfigureFileSourceSeek* message = FileSourceInput::MsgConfigureFileSourceSeek::create(value);
m_sampleSource->getInputMessageQueue()->push(message);
}
@ -338,12 +334,12 @@ void FileSourceGui::updateWithStreamData()
void FileSourceGui::updateWithStreamTime()
{
int t_sec = 0;
int t_msec = 0;
qint64 t_sec = 0;
qint64 t_msec = 0;
if (m_sampleRate > 0){
t_sec = m_samplesCount / m_sampleRate;
t_msec = (m_samplesCount - (t_sec * m_sampleRate)) * 1000 / m_sampleRate;
t_msec = (m_samplesCount - (t_sec * m_sampleRate)) * 1000LL / m_sampleRate;
}
QTime t(0, 0, 0, 0);
@ -352,10 +348,10 @@ void FileSourceGui::updateWithStreamTime()
QString s_timems = t.toString("HH:mm:ss.zzz");
ui->relTimeText->setText(s_timems);
quint64 startingTimeStampMsec = (quint64) m_startingTimeStamp * 1000LL;
qint64 startingTimeStampMsec = m_startingTimeStamp * 1000LL;
QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
dt = dt.addSecs((quint64) t_sec);
dt = dt.addMSecs((quint64) t_msec);
dt = dt.addSecs(t_sec);
dt = dt.addMSecs(t_msec);
QString s_date = dt.toString("yyyy-MM-dd HH:mm:ss.zzz");
ui->absTimeText->setText(s_date);

View File

@ -65,9 +65,9 @@ private:
int m_sampleRate;
quint32 m_sampleSize;
quint64 m_centerFrequency;
quint32 m_recordLength;
std::time_t m_startingTimeStamp;
int m_samplesCount;
quint64 m_recordLength;
quint64 m_startingTimeStamp;
quint64 m_samplesCount;
std::size_t m_tickCount;
bool m_enableNavTime;
int m_deviceSampleRate;

View File

@ -144,9 +144,9 @@ void FileSourceInput::seekFileStream(int seekPercentage)
if ((m_ifstream.is_open()) && m_fileSourceThread && !m_fileSourceThread->isRunning())
{
int seekPoint = ((m_recordLength * seekPercentage) / 100) * m_sampleRate;
quint64 seekPoint = ((m_recordLength * seekPercentage) / 100) * m_sampleRate;
m_fileSourceThread->setSamplesCount(seekPoint);
seekPoint *= 4; // + sizeof(FileSink::Header)
seekPoint *= (m_sampleSize == 24 ? 8 : 4); // + sizeof(FileSink::Header)
m_ifstream.clear();
m_ifstream.seekg(seekPoint + sizeof(FileRecord::Header), std::ios::beg);
}
@ -276,7 +276,7 @@ void FileSourceInput::setCenterFrequency(qint64 centerFrequency)
}
}
std::time_t FileSourceInput::getStartingTimeStamp() const
quint64 FileSourceInput::getStartingTimeStamp() const
{
return m_startingTimeStamp;
}

View File

@ -175,14 +175,14 @@ public:
int getSampleRate() const { return m_sampleRate; }
quint32 getSampleSize() const { return m_sampleSize; }
quint64 getCenterFrequency() const { return m_centerFrequency; }
std::time_t getStartingTimeStamp() const { return m_startingTimeStamp; }
quint32 getRecordLength() const { return m_recordLength; }
quint64 getStartingTimeStamp() const { return m_startingTimeStamp; }
quint64 getRecordLength() const { return m_recordLength; }
static MsgReportFileSourceStreamData* create(int sampleRate,
quint32 sampleSize,
quint64 centerFrequency,
std::time_t startingTimeStamp,
quint32 recordLength)
quint64 startingTimeStamp,
quint64 recordLength)
{
return new MsgReportFileSourceStreamData(sampleRate, sampleSize, centerFrequency, startingTimeStamp, recordLength);
}
@ -191,14 +191,14 @@ public:
int m_sampleRate;
quint32 m_sampleSize;
quint64 m_centerFrequency;
std::time_t m_startingTimeStamp;
quint32 m_recordLength;
quint64 m_startingTimeStamp;
quint64 m_recordLength;
MsgReportFileSourceStreamData(int sampleRate,
quint32 sampleSize,
quint64 centerFrequency,
std::time_t startingTimeStamp,
quint32 recordLength) :
quint64 startingTimeStamp,
quint64 recordLength) :
Message(),
m_sampleRate(sampleRate),
m_sampleSize(sampleSize),
@ -212,17 +212,17 @@ public:
MESSAGE_CLASS_DECLARATION
public:
std::size_t getSamplesCount() const { return m_samplesCount; }
quint64 getSamplesCount() const { return m_samplesCount; }
static MsgReportFileSourceStreamTiming* create(std::size_t samplesCount)
static MsgReportFileSourceStreamTiming* create(quint64 samplesCount)
{
return new MsgReportFileSourceStreamTiming(samplesCount);
}
protected:
std::size_t m_samplesCount;
quint64 m_samplesCount;
MsgReportFileSourceStreamTiming(std::size_t samplesCount) :
MsgReportFileSourceStreamTiming(quint64 samplesCount) :
Message(),
m_samplesCount(samplesCount)
{ }
@ -263,7 +263,7 @@ public:
virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const;
virtual void setCenterFrequency(qint64 centerFrequency);
std::time_t getStartingTimeStamp() const;
quint64 getStartingTimeStamp() const;
virtual bool handleMessage(const Message& message);
@ -295,8 +295,8 @@ public:
int m_sampleRate;
quint32 m_sampleSize;
quint64 m_centerFrequency;
quint32 m_recordLength; //!< record length in seconds computed from file size
std::time_t m_startingTimeStamp;
quint64 m_recordLength; //!< record length in seconds computed from file size
quint64 m_startingTimeStamp;
const QTimer& m_masterTimer;
void openFileStream();

View File

@ -29,7 +29,7 @@
const PluginDescriptor FileSourcePlugin::m_pluginDescriptor = {
QString("File source input"),
QString("4.2.1"),
QString("4.2.2"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,

View File

@ -44,8 +44,11 @@ public:
void setSampleRateAndSize(int samplerate, quint32 samplesize);
void setBuffers(std::size_t chunksize);
bool isRunning() const { return m_running; }
std::size_t getSamplesCount() const { return m_samplesCount; }
void setSamplesCount(int samplesCount) { m_samplesCount = samplesCount; }
quint64 getSamplesCount() const {
qDebug("FileSourceThread::getSamplesCount: m_samplesCount: %llu", m_samplesCount);
return m_samplesCount;
}
void setSamplesCount(quint64 samplesCount) { m_samplesCount = samplesCount; }
void connectTimer(const QTimer& timer);
@ -58,14 +61,14 @@ private:
quint8 *m_fileBuf;
quint8 *m_convertBuf;
std::size_t m_bufsize;
std::size_t m_chunksize;
qint64 m_chunksize;
SampleSinkFifo* m_sampleFifo;
std::size_t m_samplesCount;
quint64 m_samplesCount;
int m_samplerate; //!< File I/Q stream original sample rate
quint32 m_samplesize; //!< File effective sample size in bits (I or Q). Ex: 16, 24.
quint32 m_samplebytes; //!< Number of bytes used to store a I or Q sample. Ex: 2. 4.
int m_throttlems;
quint64 m_samplesize; //!< File effective sample size in bits (I or Q). Ex: 16, 24.
quint64 m_samplebytes; //!< Number of bytes used to store a I or Q sample. Ex: 2. 4.
qint64 m_throttlems;
QElapsedTimer m_elapsedTimer;
bool m_throttleToggle;