mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-04 16:01:14 -05:00
FileSource channel: fixes (2)
This commit is contained in:
parent
27ba28d406
commit
45cf4c86d5
@ -198,18 +198,25 @@ void FileSource::pullAudio(int nbSamples)
|
|||||||
void FileSource::start()
|
void FileSource::start()
|
||||||
{
|
{
|
||||||
qDebug("FileSource::start");
|
qDebug("FileSource::start");
|
||||||
|
|
||||||
if (m_running) {
|
|
||||||
stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_running = true;
|
m_running = true;
|
||||||
|
|
||||||
|
if (getMessageQueueToGUI())
|
||||||
|
{
|
||||||
|
MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(true); // acquisition on
|
||||||
|
getMessageQueueToGUI()->push(report);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSource::stop()
|
void FileSource::stop()
|
||||||
{
|
{
|
||||||
qDebug("FileSource::stop");
|
qDebug("FileSource::stop");
|
||||||
m_running = false;
|
m_running = false;
|
||||||
|
|
||||||
|
if (getMessageQueueToGUI())
|
||||||
|
{
|
||||||
|
MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(false); // acquisition off
|
||||||
|
getMessageQueueToGUI()->push(report);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileSource::handleMessage(const Message& cmd)
|
bool FileSource::handleMessage(const Message& cmd)
|
||||||
@ -361,6 +368,7 @@ void FileSource::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);
|
||||||
#endif
|
#endif
|
||||||
quint64 fileSize = m_ifstream.tellg();
|
quint64 fileSize = m_ifstream.tellg();
|
||||||
|
m_samplesCount = 0;
|
||||||
|
|
||||||
if (fileSize > sizeof(FileRecord::Header))
|
if (fileSize > sizeof(FileRecord::Header))
|
||||||
{
|
{
|
||||||
@ -399,7 +407,8 @@ void FileSource::openFileStream()
|
|||||||
<< " length: " << m_recordLength << " seconds"
|
<< " length: " << m_recordLength << " seconds"
|
||||||
<< " sample rate: " << m_fileSampleRate << " S/s"
|
<< " sample rate: " << m_fileSampleRate << " S/s"
|
||||||
<< " center frequency: " << m_centerFrequency << " Hz"
|
<< " center frequency: " << m_centerFrequency << " Hz"
|
||||||
<< " sample size: " << m_sampleSize << " bits";
|
<< " sample size: " << m_sampleSize << " bits"
|
||||||
|
<< " starting TS: " << m_startingTimeStamp << "s";
|
||||||
|
|
||||||
if (getMessageQueueToGUI()) {
|
if (getMessageQueueToGUI()) {
|
||||||
MsgReportFileSourceStreamData *report = MsgReportFileSourceStreamData::create(m_fileSampleRate,
|
MsgReportFileSourceStreamData *report = MsgReportFileSourceStreamData::create(m_fileSampleRate,
|
||||||
@ -422,6 +431,7 @@ void FileSource::seekFileStream(int seekMillis)
|
|||||||
if ((m_ifstream.is_open()) && !m_running)
|
if ((m_ifstream.is_open()) && !m_running)
|
||||||
{
|
{
|
||||||
quint64 seekPoint = ((m_recordLength * seekMillis) / 1000) * m_fileSampleRate;
|
quint64 seekPoint = ((m_recordLength * seekMillis) / 1000) * m_fileSampleRate;
|
||||||
|
m_samplesCount = seekPoint;
|
||||||
seekPoint *= (m_sampleSize == 24 ? 8 : 4); // + sizeof(FileSink::Header)
|
seekPoint *= (m_sampleSize == 24 ? 8 : 4); // + sizeof(FileSink::Header)
|
||||||
m_ifstream.clear();
|
m_ifstream.clear();
|
||||||
m_ifstream.seekg(seekPoint + sizeof(FileRecord::Header), std::ios::beg);
|
m_ifstream.seekg(seekPoint + sizeof(FileRecord::Header), std::ios::beg);
|
||||||
@ -441,6 +451,7 @@ void FileSource::handleEOF()
|
|||||||
if (m_settings.m_loop)
|
if (m_settings.m_loop)
|
||||||
{
|
{
|
||||||
seekFileStream(0);
|
seekFileStream(0);
|
||||||
|
m_samplesCount = 0;
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -102,6 +102,49 @@ bool FileSourceGUI::handleMessage(const Message& message)
|
|||||||
blockApplySettings(false);
|
blockApplySettings(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (FileSource::MsgReportFileSourceAcquisition::match(message))
|
||||||
|
{
|
||||||
|
m_acquisition = ((FileSource::MsgReportFileSourceAcquisition&)message).getAcquisition();
|
||||||
|
updateWithAcquisition();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (FileSource::MsgReportFileSourceStreamData::match(message))
|
||||||
|
{
|
||||||
|
m_fileSampleRate = ((FileSource::MsgReportFileSourceStreamData&)message).getSampleRate();
|
||||||
|
m_fileSampleSize = ((FileSource::MsgReportFileSourceStreamData&)message).getSampleSize();
|
||||||
|
m_startingTimeStamp = ((FileSource::MsgReportFileSourceStreamData&)message).getStartingTimeStamp();
|
||||||
|
m_recordLength = ((FileSource::MsgReportFileSourceStreamData&)message).getRecordLength();
|
||||||
|
updateWithStreamData();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (FileSource::MsgReportFileSourceStreamTiming::match(message))
|
||||||
|
{
|
||||||
|
m_samplesCount = ((FileSource::MsgReportFileSourceStreamTiming&)message).getSamplesCount();
|
||||||
|
updateWithStreamTime();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (FileSource::MsgPlayPause::match(message))
|
||||||
|
{
|
||||||
|
FileSource::MsgPlayPause& notif = (FileSource::MsgPlayPause&) message;
|
||||||
|
bool checked = notif.getPlayPause();
|
||||||
|
ui->play->setChecked(checked);
|
||||||
|
ui->navTime->setEnabled(!checked);
|
||||||
|
m_enableNavTime = !checked;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (FileSource::MsgReportHeaderCRC::match(message))
|
||||||
|
{
|
||||||
|
FileSource::MsgReportHeaderCRC& notif = (FileSource::MsgReportHeaderCRC&) message;
|
||||||
|
|
||||||
|
if (notif.isOK()) {
|
||||||
|
ui->crcLabel->setStyleSheet("QLabel { background-color : green; }");
|
||||||
|
} else {
|
||||||
|
ui->crcLabel->setStyleSheet("QLabel { background-color : red; }");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -113,6 +156,16 @@ FileSourceGUI::FileSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Bas
|
|||||||
ui(new Ui::FileSourceGUI),
|
ui(new Ui::FileSourceGUI),
|
||||||
m_pluginAPI(pluginAPI),
|
m_pluginAPI(pluginAPI),
|
||||||
m_deviceUISet(deviceUISet),
|
m_deviceUISet(deviceUISet),
|
||||||
|
m_sampleRate(0),
|
||||||
|
m_shiftFrequencyFactor(0.0),
|
||||||
|
m_fileSampleRate(0),
|
||||||
|
m_fileSampleSize(0),
|
||||||
|
m_recordLength(0),
|
||||||
|
m_startingTimeStamp(0),
|
||||||
|
m_samplesCount(0),
|
||||||
|
m_acquisition(false),
|
||||||
|
m_enableNavTime(false),
|
||||||
|
m_doApplySettings(true),
|
||||||
m_tickCount(0)
|
m_tickCount(0)
|
||||||
{
|
{
|
||||||
(void) channelTx;
|
(void) channelTx;
|
||||||
@ -190,6 +243,54 @@ void FileSourceGUI::configureFileName()
|
|||||||
m_fileSource->getInputMessageQueue()->push(message);
|
m_fileSource->getInputMessageQueue()->push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileSourceGUI::updateWithAcquisition()
|
||||||
|
{
|
||||||
|
ui->play->setChecked(m_acquisition);
|
||||||
|
ui->showFileDialog->setEnabled(!m_acquisition);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileSourceGUI::updateWithStreamData()
|
||||||
|
{
|
||||||
|
ui->sampleRateText->setText(tr("%1k").arg((float) m_fileSampleRate / 1000));
|
||||||
|
ui->sampleSizeText->setText(tr("%1b").arg(m_fileSampleSize));
|
||||||
|
QTime recordLength(0, 0, 0, 0);
|
||||||
|
recordLength = recordLength.addSecs(m_recordLength);
|
||||||
|
QString s_time = recordLength.toString("HH:mm:ss");
|
||||||
|
ui->recordLengthText->setText(s_time);
|
||||||
|
updateWithStreamTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileSourceGUI::updateWithStreamTime()
|
||||||
|
{
|
||||||
|
qint64 t_sec = 0;
|
||||||
|
qint64 t_msec = 0;
|
||||||
|
|
||||||
|
if (m_fileSampleRate > 0)
|
||||||
|
{
|
||||||
|
t_sec = m_samplesCount / m_fileSampleRate;
|
||||||
|
t_msec = (m_samplesCount - (t_sec * m_fileSampleRate)) * 1000LL / m_fileSampleRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime t(0, 0, 0, 0);
|
||||||
|
t = t.addSecs(t_sec);
|
||||||
|
t = t.addMSecs(t_msec);
|
||||||
|
QString s_timems = t.toString("HH:mm:ss.zzz");
|
||||||
|
ui->relTimeText->setText(s_timems);
|
||||||
|
|
||||||
|
qint64 startingTimeStampMsec = m_startingTimeStamp * 1000LL;
|
||||||
|
QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (!m_enableNavTime)
|
||||||
|
{
|
||||||
|
float posRatio = (float) t_sec / (float) m_recordLength;
|
||||||
|
ui->navTime->setValue((int) (posRatio * 1000.0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FileSourceGUI::displaySettings()
|
void FileSourceGUI::displaySettings()
|
||||||
{
|
{
|
||||||
m_channelMarker.blockSignals(true);
|
m_channelMarker.blockSignals(true);
|
||||||
@ -362,6 +463,8 @@ void FileSourceGUI::tick()
|
|||||||
{
|
{
|
||||||
if (++m_tickCount == 20) // once per second
|
if (++m_tickCount == 20) // once per second
|
||||||
{
|
{
|
||||||
|
FileSource::MsgConfigureFileSourceStreamTiming* message = FileSource::MsgConfigureFileSourceStreamTiming::create();
|
||||||
|
m_fileSource->getInputMessageQueue()->push(message);
|
||||||
m_tickCount = 0;
|
m_tickCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,12 @@ private:
|
|||||||
int m_sampleRate;
|
int m_sampleRate;
|
||||||
double m_shiftFrequencyFactor; //!< Channel frequency shift factor
|
double m_shiftFrequencyFactor; //!< Channel frequency shift factor
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
|
int m_fileSampleRate;
|
||||||
|
quint32 m_fileSampleSize;
|
||||||
|
quint64 m_recordLength;
|
||||||
|
quint64 m_startingTimeStamp;
|
||||||
|
quint64 m_samplesCount;
|
||||||
|
bool m_acquisition;
|
||||||
bool m_enableNavTime;
|
bool m_enableNavTime;
|
||||||
bool m_doApplySettings;
|
bool m_doApplySettings;
|
||||||
|
|
||||||
@ -82,6 +88,9 @@ private:
|
|||||||
void applySettings(bool force = false);
|
void applySettings(bool force = false);
|
||||||
void applyChannelSettings();
|
void applyChannelSettings();
|
||||||
void configureFileName();
|
void configureFileName();
|
||||||
|
void updateWithAcquisition();
|
||||||
|
void updateWithStreamData();
|
||||||
|
void updateWithStreamTime();
|
||||||
void displaySettings();
|
void displaySettings();
|
||||||
void displayRateAndShift();
|
void displayRateAndShift();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user