diff --git a/plugins/channelrx/sigmffilesink/sigmffilesink.cpp b/plugins/channelrx/sigmffilesink/sigmffilesink.cpp index 1d46b384a..6ad1e1eb7 100644 --- a/plugins/channelrx/sigmffilesink/sigmffilesink.cpp +++ b/plugins/channelrx/sigmffilesink/sigmffilesink.cpp @@ -43,6 +43,7 @@ #include "sigmffilesink.h" MESSAGE_CLASS_DEFINITION(SigMFFileSink::MsgConfigureSigMFFileSink, Message) +MESSAGE_CLASS_DEFINITION(SigMFFileSink::MsgReportStartStop, Message) const char* const SigMFFileSink::m_channelIdURI = "sdrangel.channel.sigmffilesink"; const char* const SigMFFileSink::m_channelId = "SigMFFileSink"; @@ -116,6 +117,12 @@ void SigMFFileSink::start() SigMFFileSinkBaseband::MsgConfigureSigMFFileSinkBaseband *msg = SigMFFileSinkBaseband::MsgConfigureSigMFFileSinkBaseband::create(m_settings, true); m_basebandSink->getInputMessageQueue()->push(msg); + + if (getMessageQueueToGUI()) + { + MsgReportStartStop *msg = MsgReportStartStop::create(true); + getMessageQueueToGUI()->push(msg); + } } void SigMFFileSink::stop() @@ -124,6 +131,12 @@ void SigMFFileSink::stop() m_basebandSink->stopWork(); m_thread.exit(); m_thread.wait(); + + if (getMessageQueueToGUI()) + { + MsgReportStartStop *msg = MsgReportStartStop::create(false); + getMessageQueueToGUI()->push(msg); + } } bool SigMFFileSink::handleMessage(const Message& cmd) diff --git a/plugins/channelrx/sigmffilesink/sigmffilesink.h b/plugins/channelrx/sigmffilesink/sigmffilesink.h index c15a6b14b..2329290ad 100644 --- a/plugins/channelrx/sigmffilesink/sigmffilesink.h +++ b/plugins/channelrx/sigmffilesink/sigmffilesink.h @@ -62,6 +62,25 @@ public: { } }; + class MsgReportStartStop : public Message { + MESSAGE_CLASS_DECLARATION + + public: + bool getStartStop() const { return m_startStop; } + + static MsgReportStartStop* create(bool startStop) { + return new MsgReportStartStop(startStop); + } + + protected: + bool m_startStop; + + MsgReportStartStop(bool startStop) : + Message(), + m_startStop(startStop) + { } + }; + SigMFFileSink(DeviceAPI *deviceAPI); virtual ~SigMFFileSink(); virtual void destroy() { delete this; } diff --git a/plugins/channelrx/sigmffilesink/sigmffilesinkbaseband.cpp b/plugins/channelrx/sigmffilesink/sigmffilesinkbaseband.cpp index fbd54ea74..24fe9735c 100644 --- a/plugins/channelrx/sigmffilesink/sigmffilesinkbaseband.cpp +++ b/plugins/channelrx/sigmffilesink/sigmffilesinkbaseband.cpp @@ -74,6 +74,7 @@ void SigMFFileSinkBaseband::startWork() void SigMFFileSinkBaseband::stopWork() { QMutexLocker mutexLocker(&m_mutex); + m_sink.stopRecording(); disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); QObject::disconnect( &m_sampleFifo, @@ -166,13 +167,10 @@ bool SigMFFileSinkBaseband::handleMessage(const Message& cmd) MsgConfigureSigMFFileSinkWork& conf = (MsgConfigureSigMFFileSinkWork&) cmd; qDebug() << "SigMFFileSinkBaseband::handleMessage: MsgConfigureSigMFFileSinkWork: " << conf.isWorking(); - if (!m_settings.m_squelchRecordingEnable) - { - if (conf.isWorking()) { - m_sink.startRecording(); - } else { - m_sink.stopRecording(); - } + if (conf.isWorking()) { + m_sink.startRecording(); + } else { + m_sink.stopRecording(); } return true; diff --git a/plugins/channelrx/sigmffilesink/sigmffilesinkgui.cpp b/plugins/channelrx/sigmffilesink/sigmffilesinkgui.cpp index 44cf2fc95..ae6ab0506 100644 --- a/plugins/channelrx/sigmffilesink/sigmffilesinkgui.cpp +++ b/plugins/channelrx/sigmffilesink/sigmffilesinkgui.cpp @@ -121,18 +121,34 @@ bool SigMFFileSinkGUI::handleMessage(const Message& message) else if (SigMFFileSinkMessages::MsgReportRecording::match(message)) { const SigMFFileSinkMessages::MsgReportSquelch& report = (SigMFFileSinkMessages::MsgReportSquelch&) message; + qDebug("SigMFFileSinkGUI::handleMessage: FileSinkMessages::MsgReportRecording: %s", report.getOpen() ? "on" : "off"); + + blockSignals(true); if (report.getOpen()) { ui->record->setStyleSheet("QToolButton { background-color : red; }"); - ui->squelchedRecording->setEnabled(false); + ui->record->setChecked(true); } else { ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); - ui->squelchedRecording->setEnabled(true); + ui->record->setChecked(false); } + blockSignals(false); + return true; + } + else if (SigMFFileSink::MsgReportStartStop::match(message)) + { + const SigMFFileSink::MsgReportStartStop& cfg = (SigMFFileSink::MsgReportStartStop&) message; + m_running = cfg.getStartStop(); + blockSignals(true); + ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); + ui->record->setChecked(false); + ui->record->setEnabled(m_running && !m_settings.m_squelchRecordingEnable); + blockSignals(false); + return true; } else @@ -147,6 +163,7 @@ SigMFFileSinkGUI::SigMFFileSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISe m_pluginAPI(pluginAPI), m_deviceUISet(deviceUISet), m_channelMarker(this), + m_running(false), m_fixedShiftIndex(0), m_basebandSampleRate(0), m_fixedPosition(false), @@ -225,6 +242,8 @@ void SigMFFileSinkGUI::displaySettings() blockApplySettings(true); + ui->record->setEnabled(!m_settings.m_squelchRecordingEnable); + ui->squelchedRecording->setChecked(m_settings.m_squelchRecordingEnable); ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); ui->fileNameText->setText(m_settings.m_fileRecordName); ui->decimationFactor->setCurrentIndex(m_settings.m_log2Decim); @@ -236,10 +255,14 @@ void SigMFFileSinkGUI::displaySettings() ui->postSquelchTime->setValue(m_settings.m_squelchPostRecordTime); ui->postSquelchTimeText->setText(tr("%1").arg(m_settings.m_squelchPostRecordTime)); ui->squelchedRecording->setChecked(m_settings.m_squelchRecordingEnable); - ui->record->setEnabled(!m_settings.m_squelchRecordingEnable); - if (!m_settings.m_spectrumSquelchMode) { + if (!m_settings.m_spectrumSquelchMode) + { ui->squelchLevel->setStyleSheet("QDial { background:rgb(79,79,79); }"); + ui->record->setEnabled(true); + ui->squelchedRecording->blockSignals(true); + ui->squelchedRecording->setChecked(false); + ui->squelchedRecording->blockSignals(false); } displayStreamIndex(); @@ -462,14 +485,6 @@ void SigMFFileSinkGUI::on_squelchedRecording_toggled(bool checked) void SigMFFileSinkGUI::on_record_toggled(bool checked) { - ui->squelchedRecording->setEnabled(!checked); - - if (checked) { - ui->record->setStyleSheet("QToolButton { background-color : red; }"); - } else { - ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); - } - m_sigMFFileSink->record(checked); } diff --git a/plugins/channelrx/sigmffilesink/sigmffilesinkgui.h b/plugins/channelrx/sigmffilesink/sigmffilesinkgui.h index 84ac051e2..1497d10ac 100644 --- a/plugins/channelrx/sigmffilesink/sigmffilesinkgui.h +++ b/plugins/channelrx/sigmffilesink/sigmffilesinkgui.h @@ -59,6 +59,7 @@ private: DeviceUISet* m_deviceUISet; ChannelMarker m_channelMarker; SigMFFileSinkSettings m_settings; + bool m_running; int m_fixedShiftIndex; int m_basebandSampleRate; double m_shiftFrequencyFactor; //!< Channel frequency shift factor diff --git a/plugins/channelrx/sigmffilesink/sigmffilesinksink.cpp b/plugins/channelrx/sigmffilesink/sigmffilesinksink.cpp index 283b9872e..ea086654e 100644 --- a/plugins/channelrx/sigmffilesink/sigmffilesinksink.cpp +++ b/plugins/channelrx/sigmffilesink/sigmffilesinksink.cpp @@ -52,6 +52,12 @@ void SigMFFileSinkSink::startRecording() m_fileSink.startRecording(); m_record = true; + if (m_msgQueueToGUI) + { + SigMFFileSinkMessages::MsgReportRecording *msg = SigMFFileSinkMessages::MsgReportRecording::create(true); + m_msgQueueToGUI->push(msg); + } + // copy pre record samples SampleVector::iterator p1Begin, p1End, p2Begin, p2End; m_preRecordBuffer.readBegin(m_preRecordFill, &p1Begin, &p1End, &p2Begin, &p2End); @@ -77,6 +83,13 @@ void SigMFFileSinkSink::stopRecording() { m_preRecordBuffer.reset(); m_fileSink.stopRecording(); + + if (m_msgQueueToGUI) + { + SigMFFileSinkMessages::MsgReportRecording *msg = SigMFFileSinkMessages::MsgReportRecording::create(false); + m_msgQueueToGUI->push(msg); + } + m_record = false; } } @@ -125,12 +138,6 @@ void SigMFFileSinkSink::feed(const SampleVector::const_iterator& begin, const Sa } else { - if (m_msgQueueToGUI) - { - SigMFFileSinkMessages::MsgReportRecording *msg = SigMFFileSinkMessages::MsgReportRecording::create(false); - m_msgQueueToGUI->push(msg); - } - m_fileSink.feed(beginw, endw + m_postSquelchCounter, true); nbToWrite = m_postSquelchCounter; m_postSquelchCounter = 0; @@ -295,15 +302,8 @@ void SigMFFileSinkSink::squelchRecording(bool squelchOpen) if (squelchOpen) { - if (!m_record) - { + if (!m_record) { startRecording(); - - if (m_msgQueueToGUI) - { - SigMFFileSinkMessages::MsgReportRecording *msg = SigMFFileSinkMessages::MsgReportRecording::create(true); - m_msgQueueToGUI->push(msg); - } } } else