From 9526d82ab8a6423af5a70cb81f725c1b3b3899cc Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 9 Jul 2019 02:07:13 +0200 Subject: [PATCH] FileSource channel: fixed 16 bits sample size processing and play loop --- plugins/channeltx/filesource/filesource.cpp | 80 ++++++++----------- .../channeltx/filesource/filesourcegui.cpp | 5 +- 2 files changed, 37 insertions(+), 48 deletions(-) diff --git a/plugins/channeltx/filesource/filesource.cpp b/plugins/channeltx/filesource/filesource.cpp index a638e7468..ea8ecc616 100644 --- a/plugins/channeltx/filesource/filesource.cpp +++ b/plugins/channeltx/filesource/filesource.cpp @@ -117,31 +117,24 @@ void FileSource::pull(Sample& sample) if (m_sampleSize == 16) { - if (SDR_RX_SAMP_SZ == 16) - { - m_ifstream.read(reinterpret_cast(&sample), sizeof(Sample)); + Sample16 sample16; + m_ifstream.read(reinterpret_cast(&sample16), sizeof(Sample16)); - if (m_ifstream.eof()) { - handleEOF(); - } else { - m_samplesCount++; - } + if (m_ifstream.eof()) { + handleEOF(); + } else { + m_samplesCount++; + } + + if (SDR_TX_SAMP_SZ == 16) + { + sample.setReal(sample16.real); + sample.setImag(sample16.imag); } - else if (SDR_RX_SAMP_SZ == 24) + else if (SDR_TX_SAMP_SZ == 24) { - Sample16 sample16; - m_ifstream.read(reinterpret_cast(&sample16), sizeof(Sample16)); - - if (m_ifstream.eof()) - { - handleEOF(); - } - else - { - sample.setReal(sample16.real << 8); - sample.setImag(sample16.imag << 8); - m_samplesCount++; - } + sample.setReal(sample16.real << 8); + sample.setImag(sample16.imag << 8); } else { @@ -151,31 +144,24 @@ void FileSource::pull(Sample& sample) } else if (m_sampleSize == 24) { - if (SDR_RX_SAMP_SZ == 24) - { - m_ifstream.read(reinterpret_cast(&sample), sizeof(Sample)); + Sample24 sample24; + m_ifstream.read(reinterpret_cast(&sample24), sizeof(Sample24)); - if (m_ifstream.eof()) { - handleEOF(); - } else { - m_samplesCount++; - } + if (m_ifstream.eof()) { + handleEOF(); + } else { + m_samplesCount++; + } + + if (SDR_TX_SAMP_SZ == 24) + { + sample.setReal(sample24.real); + sample.setImag(sample24.imag); } - else if (SDR_RX_SAMP_SZ == 16) + else if (SDR_TX_SAMP_SZ == 16) { - Sample24 sample24; - m_ifstream.read(reinterpret_cast(&sample24), sizeof(Sample24)); - - if (m_ifstream.eof()) - { - handleEOF(); - } - else - { - sample.setReal(sample24.real >> 8); - sample.setImag(sample24.imag >> 8); - m_samplesCount++; - } + sample.setReal(sample24.real >> 8); + sample.setImag(sample24.imag >> 8); } else { @@ -440,8 +426,6 @@ void FileSource::seekFileStream(int seekMillis) void FileSource::handleEOF() { - stop(); - if (getMessageQueueToGUI()) { MsgReportFileSourceStreamTiming *report = MsgReportFileSourceStreamTiming::create(getSamplesCount()); @@ -450,12 +434,14 @@ void FileSource::handleEOF() if (m_settings.m_loop) { + stop(); seekFileStream(0); - m_samplesCount = 0; start(); } else { + stop(); + if (getMessageQueueToGUI()) { MsgPlayPause *report = MsgPlayPause::create(false); diff --git a/plugins/channeltx/filesource/filesourcegui.cpp b/plugins/channeltx/filesource/filesourcegui.cpp index 1cd0f6fbb..afd6a3d08 100644 --- a/plugins/channeltx/filesource/filesourcegui.cpp +++ b/plugins/channeltx/filesource/filesourcegui.cpp @@ -182,7 +182,8 @@ FileSourceGUI::FileSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Bas m_channelMarker.blockSignals(true); m_channelMarker.setColor(m_settings.m_rgbColor); m_channelMarker.setCenterFrequency(0); - m_channelMarker.setTitle("Remote source"); + m_channelMarker.setTitle("File source"); + m_channelMarker.setMovable(false); // do not let user move the center arbitrarily m_channelMarker.setSourceOrSinkStream(false); m_channelMarker.blockSignals(false); m_channelMarker.setVisible(true); // activate signal on the last setting only @@ -245,7 +246,9 @@ void FileSourceGUI::configureFileName() void FileSourceGUI::updateWithAcquisition() { + ui->play->blockSignals(true); ui->play->setChecked(m_acquisition); + ui->play->blockSignals(false); ui->showFileDialog->setEnabled(!m_acquisition); }