SigMFFileSink: enable record button only when plugin is running. Reworked squelch recording vs recording enabling logic

pull/788/head
f4exb 2021-02-28 12:53:07 +01:00
rodzic 9d7a6aff7b
commit 08a7e42096
6 zmienionych plików z 79 dodań i 33 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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; }

Wyświetl plik

@ -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;

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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

Wyświetl plik

@ -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