From fbb816ebdfac2d9a65c7610607416dde982071fc Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 19 Oct 2016 22:32:14 +0200 Subject: [PATCH] Tx ph.1: Added FileSink (2) compiles. Added plugin/samplesink in all builds --- plugins/CMakeLists.txt | 1 + plugins/samplesink/CMakeLists.txt | 4 ++ plugins/samplesink/filesink/filesinkgui.cpp | 13 ++----- plugins/samplesink/filesink/filesinkgui.h | 4 +- .../samplesink/filesink/filesinkoutput.cpp | 38 +++++++------------ plugins/samplesink/filesink/filesinkoutput.h | 22 +---------- .../samplesink/filesink/filesinkthread.cpp | 6 ++- plugins/samplesink/filesink/filesinkthread.h | 3 ++ sdrangel.android.pro | 1 + sdrangel.macos.pro | 1 + sdrangel.windows.pro | 1 + windows.install.bat | 2 + windows64.install.bat | 2 + 13 files changed, 40 insertions(+), 58 deletions(-) create mode 100644 plugins/samplesink/CMakeLists.txt diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index c15e7f7ee..f7bd86fd4 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -2,3 +2,4 @@ project(plugins) add_subdirectory(channelrx) add_subdirectory(samplesource) +add_subdirectory(samplesink) diff --git a/plugins/samplesink/CMakeLists.txt b/plugins/samplesink/CMakeLists.txt new file mode 100644 index 000000000..7c1f5cca2 --- /dev/null +++ b/plugins/samplesink/CMakeLists.txt @@ -0,0 +1,4 @@ +project(samplesink) + +add_subdirectory(filesink) + diff --git a/plugins/samplesink/filesink/filesinkgui.cpp b/plugins/samplesink/filesink/filesinkgui.cpp index bf07e5411..6a0fa5966 100644 --- a/plugins/samplesink/filesink/filesinkgui.cpp +++ b/plugins/samplesink/filesink/filesinkgui.cpp @@ -47,7 +47,6 @@ FileSinkGui::FileSinkGui(DeviceSinkAPI *deviceAPI, QWidget* parent) : m_startingTimeStamp(0), m_samplesCount(0), m_tickCount(0), - m_enableNavTime(false), m_lastEngineState((DSPDeviceSinkEngine::State)-1) { ui->setupUi(this); @@ -234,16 +233,16 @@ void FileSinkGui::updateStatus() { switch(state) { - case DSPDeviceSourceEngine::StNotStarted: + case DSPDeviceSinkEngine::StNotStarted: ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); break; - case DSPDeviceSourceEngine::StIdle: + case DSPDeviceSinkEngine::StIdle: ui->startStop->setStyleSheet("QToolButton { background-color : blue; }"); break; - case DSPDeviceSourceEngine::StRunning: + case DSPDeviceSinkEngine::StRunning: ui->startStop->setStyleSheet("QToolButton { background-color : green; }"); break; - case DSPDeviceSourceEngine::StError: + case DSPDeviceSinkEngine::StError: ui->startStop->setStyleSheet("QToolButton { background-color : red; }"); QMessageBox::information(this, tr("Message"), m_deviceAPI->errorMessage()); break; @@ -283,16 +282,12 @@ void FileSinkGui::configureFileName() void FileSinkGui::updateWithGeneration() { - ui->play->setEnabled(m_generation); - ui->play->setChecked(m_generation); ui->showFileDialog->setEnabled(!m_generation); } void FileSinkGui::updateWithStreamData() { ui->centerFrequency->setValue(m_centerFrequency/1000); - ui->sampleRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000)); - ui->play->setEnabled(m_generation); } void FileSinkGui::updateWithStreamTime() diff --git a/plugins/samplesink/filesink/filesinkgui.h b/plugins/samplesink/filesink/filesinkgui.h index 109ae4a52..e020199a2 100644 --- a/plugins/samplesink/filesink/filesinkgui.h +++ b/plugins/samplesink/filesink/filesinkgui.h @@ -27,7 +27,7 @@ class DeviceSinkAPI; class DeviceSampleSink; namespace Ui { - class FileSourceGui; + class FileSinkGui; } class FileSinkGui : public QWidget, public PluginGUI { @@ -49,7 +49,7 @@ public: virtual bool handleMessage(const Message& message); private: - Ui::FileSourceGui* ui; + Ui::FileSinkGui* ui; DeviceSinkAPI* m_deviceAPI; FileSinkOutput::Settings m_settings; diff --git a/plugins/samplesink/filesink/filesinkoutput.cpp b/plugins/samplesink/filesink/filesinkoutput.cpp index a150a241a..34605e197 100644 --- a/plugins/samplesink/filesink/filesinkoutput.cpp +++ b/plugins/samplesink/filesink/filesinkoutput.cpp @@ -30,7 +30,6 @@ MESSAGE_CLASS_DEFINITION(FileSinkOutput::MsgConfigureFileSink, Message) MESSAGE_CLASS_DEFINITION(FileSinkOutput::MsgConfigureFileSinkName, Message) MESSAGE_CLASS_DEFINITION(FileSinkOutput::MsgConfigureFileSinkWork, Message) -MESSAGE_CLASS_DEFINITION(FileSinkOutput::MsgConfigureFileSinkSeek, Message) MESSAGE_CLASS_DEFINITION(FileSinkOutput::MsgConfigureFileSinkStreamTiming, Message) MESSAGE_CLASS_DEFINITION(FileSinkOutput::MsgReportFileSinkGeneration, Message) MESSAGE_CLASS_DEFINITION(FileSinkOutput::MsgReportFileSinkStreamData, Message) @@ -74,12 +73,11 @@ bool FileSinkOutput::Settings::deserialize(const QByteArray& data) FileSinkOutput::FileSinkOutput(const QTimer& masterTimer) : m_settings(), - m_fileSourceThread(0), + m_fileSinkThread(0), m_deviceDescription(), m_fileName("..."), m_sampleRate(0), m_centerFrequency(0), - m_recordLength(0), m_startingTimeStamp(0), m_masterTimer(masterTimer) { @@ -126,15 +124,15 @@ bool FileSinkOutput::start(int device) //openFileStream(); - if((m_fileSourceThread = new FileSinkThread(&m_ifstream, &m_sampleFifo)) == 0) { + if((m_fileSinkThread = new FileSinkThread(&m_ofstream, &m_sampleSourceFifo)) == 0) { qFatal("out of memory"); stop(); return false; } - m_fileSourceThread->setSamplerate(m_sampleRate); - m_fileSourceThread->connectTimer(m_masterTimer); - m_fileSourceThread->startWork(); + m_fileSinkThread->setSamplerate(m_sampleRate); + m_fileSinkThread->connectTimer(m_masterTimer); + m_fileSinkThread->startWork(); m_deviceDescription = "FileSink"; mutexLocker.unlock(); @@ -152,11 +150,11 @@ void FileSinkOutput::stop() qDebug() << "FileSourceInput::stop"; QMutexLocker mutexLocker(&m_mutex); - if(m_fileSourceThread != 0) + if(m_fileSinkThread != 0) { - m_fileSourceThread->stopWork(); - delete m_fileSourceThread; - m_fileSourceThread = 0; + m_fileSinkThread->stopWork(); + delete m_fileSinkThread; + m_fileSinkThread = 0; } m_deviceDescription.clear(); @@ -199,11 +197,11 @@ bool FileSinkOutput::handleMessage(const Message& message) MsgConfigureFileSinkWork& conf = (MsgConfigureFileSinkWork&) message; bool working = conf.isWorking(); - if (m_fileSourceThread != 0) + if (m_fileSinkThread != 0) { if (working) { - m_fileSourceThread->startWork(); + m_fileSinkThread->startWork(); /* MsgReportFileSourceStreamTiming *report = MsgReportFileSourceStreamTiming::create(m_fileSourceThread->getSamplesCount()); @@ -211,27 +209,19 @@ bool FileSinkOutput::handleMessage(const Message& message) } else { - m_fileSourceThread->stopWork(); + m_fileSinkThread->stopWork(); } } return true; } - else if (MsgConfigureFileSinkSeek::match(message)) - { - MsgConfigureFileSinkSeek& conf = (MsgConfigureFileSinkSeek&) message; - int seekPercentage = conf.getPercentage(); - seekFileStream(seekPercentage); - - return true; - } else if (MsgConfigureFileSinkStreamTiming::match(message)) { MsgReportFileSinkStreamTiming *report; - if (m_fileSourceThread != 0) + if (m_fileSinkThread != 0) { - report = MsgReportFileSinkStreamTiming::create(m_fileSourceThread->getSamplesCount()); + report = MsgReportFileSinkStreamTiming::create(m_fileSinkThread->getSamplesCount()); getOutputMessageQueueToGUI()->push(report); } diff --git a/plugins/samplesink/filesink/filesinkoutput.h b/plugins/samplesink/filesink/filesinkoutput.h index 24d33b3a2..af8f0ca7f 100644 --- a/plugins/samplesink/filesink/filesinkoutput.h +++ b/plugins/samplesink/filesink/filesinkoutput.h @@ -114,26 +114,6 @@ public: { } }; - class MsgConfigureFileSinkSeek : public Message { - MESSAGE_CLASS_DECLARATION - - public: - int getPercentage() const { return m_seekPercentage; } - - static MsgConfigureFileSinkSeek* create(int seekPercentage) - { - return new MsgConfigureFileSinkSeek(seekPercentage); - } - - protected: - int m_seekPercentage; //!< percentage of seek position from the beginning 0..100 - - MsgConfigureFileSinkSeek(int seekPercentage) : - Message(), - m_seekPercentage(seekPercentage) - { } - }; - class MsgReportFileSinkGeneration : public Message { MESSAGE_CLASS_DECLARATION @@ -222,7 +202,7 @@ private: QMutex m_mutex; Settings m_settings; std::ofstream m_ofstream; - FileSinkThread* m_fileSourceThread; + FileSinkThread* m_fileSinkThread; QString m_deviceDescription; QString m_fileName; int m_sampleRate; diff --git a/plugins/samplesink/filesink/filesinkthread.cpp b/plugins/samplesink/filesink/filesinkthread.cpp index b3eb65eac..4742f83e7 100644 --- a/plugins/samplesink/filesink/filesinkthread.cpp +++ b/plugins/samplesink/filesink/filesinkthread.cpp @@ -22,7 +22,7 @@ #include "dsp/samplesourcefifo.h" #include "filesinkthread.h" -FileSinkThread::FileSinkThread(std::ofstream *samplesStream, SampleSinkFifo* sampleFifo, QObject* parent) : +FileSinkThread::FileSinkThread(std::ofstream *samplesStream, SampleSourceFifo* sampleFifo, QObject* parent) : QThread(parent), m_running(false), m_ofstream(samplesStream), @@ -30,6 +30,7 @@ FileSinkThread::FileSinkThread(std::ofstream *samplesStream, SampleSinkFifo* sam m_bufsize(0), m_samplesChunkSize(0), m_sampleFifo(sampleFifo), + m_samplesCount(0), m_samplerate(0), m_throttlems(FILESINK_THROTTLE_MS), m_throttleToggle(false) @@ -129,6 +130,7 @@ void FileSinkThread::tick() SampleVector::iterator beginRead; m_sampleFifo->read(beginRead, m_samplesChunkSize); - m_ofstream->write(reinterpret_cast(*beginRead), m_samplesChunkSize*4); + m_ofstream->write(reinterpret_cast(&(*beginRead)), m_samplesChunkSize*4); + m_samplesCount += m_samplesChunkSize; } } diff --git a/plugins/samplesink/filesink/filesinkthread.h b/plugins/samplesink/filesink/filesinkthread.h index b12533eaf..86bfffd67 100644 --- a/plugins/samplesink/filesink/filesinkthread.h +++ b/plugins/samplesink/filesink/filesinkthread.h @@ -44,6 +44,8 @@ public: void setSamplerate(int samplerate); void setBuffer(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; } void connectTimer(const QTimer& timer); @@ -57,6 +59,7 @@ private: std::size_t m_bufsize; std::size_t m_samplesChunkSize; SampleSourceFifo* m_sampleFifo; + std::size_t m_samplesCount; int m_samplerate; int m_throttlems; diff --git a/sdrangel.android.pro b/sdrangel.android.pro index d188c3b36..2569fe25c 100644 --- a/sdrangel.android.pro +++ b/sdrangel.android.pro @@ -15,6 +15,7 @@ SUBDIRS += plugins/samplesource/sdrdaemon #SUBDIRS += plugins/samplesource/rtlsdr #SUBDIRS += plugins/samplesource/hackrf #SUBDIRS += plugins/samplesource/airspy +SUBDIRS += plugins/samplesink/filesink SUBDIRS += plugins/channel/chanalyzer SUBDIRS += plugins/channel/demodam SUBDIRS += plugins/channel/demodbfm diff --git a/sdrangel.macos.pro b/sdrangel.macos.pro index 8ed472bc8..c0baac5a7 100644 --- a/sdrangel.macos.pro +++ b/sdrangel.macos.pro @@ -15,6 +15,7 @@ SUBDIRS += plugins/samplesource/sdrdaemon SUBDIRS += plugins/samplesource/rtlsdr SUBDIRS += plugins/samplesource/hackrf SUBDIRS += plugins/samplesource/airspy +SUBDIRS += plugins/samplesink/filesink SUBDIRS += plugins/channelrx/chanalyzer SUBDIRS += plugins/channelrx/demodam SUBDIRS += plugins/channelrx/demodbfm diff --git a/sdrangel.windows.pro b/sdrangel.windows.pro index d75209cba..7eb68737f 100644 --- a/sdrangel.windows.pro +++ b/sdrangel.windows.pro @@ -25,6 +25,7 @@ SUBDIRS += plugins/samplesource/rtlsdr SUBDIRS += plugins/samplesource/hackrf SUBDIRS += plugins/samplesource/airspy SUBDIRS += plugins/samplesource/bladerf +SUBDIRS += plugins/samplesink/filesink SUBDIRS += plugins/channelrx/chanalyzer SUBDIRS += plugins/channelrx/demodam SUBDIRS += plugins/channelrx/demodbfm diff --git a/windows.install.bat b/windows.install.bat index c9a461673..69995190a 100644 --- a/windows.install.bat +++ b/windows.install.bat @@ -14,6 +14,7 @@ copy %libusbdir%\dll\libusb-1.0.dll %2 mkdir %2\plugins mkdir %2\plugins\channelrx mkdir %2\plugins\samplesource +mkdir %2\plugins\samplesink copy plugins\channelrx\chanalyzer\%1\chanalyzer.dll %2\plugins\channelrx copy plugins\channelrx\demodam\%1\demodam.dll %2\plugins\channelrx copy plugins\channelrx\demodbfm\%1\demodbfm.dll %2\plugins\channelrx @@ -29,3 +30,4 @@ copy plugins\samplesource\rtlsdr\%1\inputrtlsdr.dll %2\plugins\samplesource copy plugins\samplesource\hackrf\%1\inputhackrf.dll %2\plugins\samplesource copy plugins\samplesource\airspy\%1\inputairspy.dll %2\plugins\samplesource copy plugins\samplesource\bladerf\%1\inputbladerf.dll %2\plugins\samplesource +copy plugins\samplesink\filesink\%1\outputfilesink.dll %2\plugins\samplesink diff --git a/windows64.install.bat b/windows64.install.bat index f66f5bc25..dc5b12cf2 100644 --- a/windows64.install.bat +++ b/windows64.install.bat @@ -27,6 +27,7 @@ copy %libusbdir%\dll\libusb-1.0.dll %2 mkdir %2\plugins mkdir %2\plugins\channelrx mkdir %2\plugins\samplesource +mkdir %2\plugins\samplesink copy plugins\channelrx\chanalyzer\%1\chanalyzer.dll %2\plugins\channelrx copy plugins\channelrx\demodam\%1\demodam.dll %2\plugins\channelrx copy plugins\channelrx\demodbfm\%1\demodbfm.dll %2\plugins\channelrx @@ -44,3 +45,4 @@ copy plugins\samplesource\rtlsdr\%1\inputrtlsdr.dll %2\plugins\samplesource copy plugins\samplesource\hackrf\%1\inputhackrf.dll %2\plugins\samplesource copy plugins\samplesource\airspy\%1\inputairspy.dll %2\plugins\samplesource copy plugins\samplesource\bladerf\%1\inputbladerf.dll %2\plugins\samplesource +copy plugins\samplesink\filesink\%1\outputfilesink.dll %2\plugins\samplesink