1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 06:04:39 -04:00

File source plugin: added seek bar to move the current pointer in the file

This commit is contained in:
f4exb
2016-02-25 14:07:39 +01:00
parent a8fc503366
commit 5ecf7ea00c
6 changed files with 77 additions and 31 deletions
@@ -30,6 +30,7 @@
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSource, Message)
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceName, Message)
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceWork, Message)
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceSeek, Message)
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceStreamTiming, Message)
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceAcquisition, Message)
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamData, Message)
@@ -124,6 +125,20 @@ void FileSourceInput::openFileStream()
getOutputMessageQueueToGUI()->push(report);
}
void FileSourceInput::seekFileStream(int seekPercentage)
{
QMutexLocker mutexLocker(&m_mutex);
if ((m_ifstream.is_open()) && !m_fileSourceThread->isRunning())
{
int seekPoint = ((m_recordLength * seekPercentage) / 100) * m_sampleRate;
m_fileSourceThread->setSamplesCount(seekPoint);
seekPoint *= 4; // + sizeof(FileSink::Header)
m_ifstream.clear();
m_ifstream.seekg(seekPoint, std::ios::beg);
}
}
bool FileSourceInput::init(const Message& message)
{
return false;
@@ -224,9 +239,10 @@ bool FileSourceInput::handleMessage(const Message& message)
if (working)
{
m_fileSourceThread->startWork();
/*
MsgReportFileSourceStreamTiming *report =
MsgReportFileSourceStreamTiming::create(m_fileSourceThread->getSamplesCount());
getOutputMessageQueueToGUI()->push(report);
getOutputMessageQueueToGUI()->push(report);*/
}
else
{
@@ -236,6 +252,14 @@ bool FileSourceInput::handleMessage(const Message& message)
return true;
}
else if (MsgConfigureFileSourceSeek::match(message))
{
MsgConfigureFileSourceSeek& conf = (MsgConfigureFileSourceSeek&) message;
int seekPercentage = conf.getPercentage();
seekFileStream(seekPercentage);
return true;
}
else if (MsgConfigureFileSourceStreamTiming::match(message))
{
MsgReportFileSourceStreamTiming *report;