From a6557cd4f9b1e00cfd27a433040f6ad496aa0a7e Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 14 Oct 2018 02:38:24 +0200 Subject: [PATCH] File Input: use millis instead of percent for navigation slider --- plugins/samplesource/filesource/filesourcegui.cpp | 4 ++-- plugins/samplesource/filesource/filesourcegui.ui | 2 +- .../samplesource/filesource/filesourceinput.cpp | 8 ++++---- plugins/samplesource/filesource/filesourceinput.h | 14 +++++++------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/samplesource/filesource/filesourcegui.cpp b/plugins/samplesource/filesource/filesourcegui.cpp index 45e7b8743..5d7524b2e 100644 --- a/plugins/samplesource/filesource/filesourcegui.cpp +++ b/plugins/samplesource/filesource/filesourcegui.cpp @@ -303,7 +303,7 @@ void FileSourceGui::on_play_toggled(bool checked) void FileSourceGui::on_navTimeSlider_valueChanged(int value) { - if (m_enableNavTime && ((value >= 0) && (value <= 100))) + if (m_enableNavTime && ((value >= 0) && (value <= 1000))) { FileSourceInput::MsgConfigureFileSourceSeek* message = FileSourceInput::MsgConfigureFileSourceSeek::create(value); m_sampleSource->getInputMessageQueue()->push(message); @@ -387,7 +387,7 @@ void FileSourceGui::updateWithStreamTime() if (!m_enableNavTime) { float posRatio = (float) t_sec / (float) m_recordLength; - ui->navTimeSlider->setValue((int) (posRatio * 100.0)); + ui->navTimeSlider->setValue((int) (posRatio * 1000.0)); } } diff --git a/plugins/samplesource/filesource/filesourcegui.ui b/plugins/samplesource/filesource/filesourcegui.ui index 221fb8771..f40501a14 100644 --- a/plugins/samplesource/filesource/filesourcegui.ui +++ b/plugins/samplesource/filesource/filesourcegui.ui @@ -558,7 +558,7 @@ Time navigator - 100 + 1000 1 diff --git a/plugins/samplesource/filesource/filesourceinput.cpp b/plugins/samplesource/filesource/filesourceinput.cpp index af33296f3..4f8ed2175 100644 --- a/plugins/samplesource/filesource/filesourceinput.cpp +++ b/plugins/samplesource/filesource/filesourceinput.cpp @@ -138,13 +138,13 @@ void FileSourceInput::openFileStream() } } -void FileSourceInput::seekFileStream(int seekPercentage) +void FileSourceInput::seekFileStream(int seekMillis) { QMutexLocker mutexLocker(&m_mutex); if ((m_ifstream.is_open()) && m_fileSourceThread && !m_fileSourceThread->isRunning()) { - quint64 seekPoint = ((m_recordLength * seekPercentage) / 100) * m_sampleRate; + quint64 seekPoint = ((m_recordLength * seekMillis) / 1000) * m_sampleRate; m_fileSourceThread->setSamplesCount(seekPoint); seekPoint *= (m_sampleSize == 24 ? 8 : 4); // + sizeof(FileSink::Header) m_ifstream.clear(); @@ -322,8 +322,8 @@ bool FileSourceInput::handleMessage(const Message& message) else if (MsgConfigureFileSourceSeek::match(message)) { MsgConfigureFileSourceSeek& conf = (MsgConfigureFileSourceSeek&) message; - int seekPercentage = conf.getPercentage(); - seekFileStream(seekPercentage); + int seekMillis = conf.getMillis(); + seekFileStream(seekMillis); return true; } diff --git a/plugins/samplesource/filesource/filesourceinput.h b/plugins/samplesource/filesource/filesourceinput.h index 66c1c501c..b5683d65a 100644 --- a/plugins/samplesource/filesource/filesourceinput.h +++ b/plugins/samplesource/filesource/filesourceinput.h @@ -113,19 +113,19 @@ public: MESSAGE_CLASS_DECLARATION public: - int getPercentage() const { return m_seekPercentage; } + int getMillis() const { return m_seekMillis; } - static MsgConfigureFileSourceSeek* create(int seekPercentage) + static MsgConfigureFileSourceSeek* create(int seekMillis) { - return new MsgConfigureFileSourceSeek(seekPercentage); + return new MsgConfigureFileSourceSeek(seekMillis); } protected: - int m_seekPercentage; //!< percentage of seek position from the beginning 0..100 + int m_seekMillis; //!< millis of seek position from the beginning 0..1000 - MsgConfigureFileSourceSeek(int seekPercentage) : + MsgConfigureFileSourceSeek(int seekMillis) : Message(), - m_seekPercentage(seekPercentage) + m_seekMillis(seekMillis) { } }; @@ -319,7 +319,7 @@ public: const QTimer& m_masterTimer; void openFileStream(); - void seekFileStream(int seekPercentage); + void seekFileStream(int seekMillis); bool applySettings(const FileSourceSettings& settings, bool force = false); void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response); };