mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 10:05:46 -05:00
SigMFFileSink: enable record button only when plugin is running. Reworked squelch recording vs recording enabling logic
This commit is contained in:
parent
9d7a6aff7b
commit
08a7e42096
@ -43,6 +43,7 @@
|
|||||||
#include "sigmffilesink.h"
|
#include "sigmffilesink.h"
|
||||||
|
|
||||||
MESSAGE_CLASS_DEFINITION(SigMFFileSink::MsgConfigureSigMFFileSink, Message)
|
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_channelIdURI = "sdrangel.channel.sigmffilesink";
|
||||||
const char* const SigMFFileSink::m_channelId = "SigMFFileSink";
|
const char* const SigMFFileSink::m_channelId = "SigMFFileSink";
|
||||||
@ -116,6 +117,12 @@ void SigMFFileSink::start()
|
|||||||
|
|
||||||
SigMFFileSinkBaseband::MsgConfigureSigMFFileSinkBaseband *msg = SigMFFileSinkBaseband::MsgConfigureSigMFFileSinkBaseband::create(m_settings, true);
|
SigMFFileSinkBaseband::MsgConfigureSigMFFileSinkBaseband *msg = SigMFFileSinkBaseband::MsgConfigureSigMFFileSinkBaseband::create(m_settings, true);
|
||||||
m_basebandSink->getInputMessageQueue()->push(msg);
|
m_basebandSink->getInputMessageQueue()->push(msg);
|
||||||
|
|
||||||
|
if (getMessageQueueToGUI())
|
||||||
|
{
|
||||||
|
MsgReportStartStop *msg = MsgReportStartStop::create(true);
|
||||||
|
getMessageQueueToGUI()->push(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SigMFFileSink::stop()
|
void SigMFFileSink::stop()
|
||||||
@ -124,6 +131,12 @@ void SigMFFileSink::stop()
|
|||||||
m_basebandSink->stopWork();
|
m_basebandSink->stopWork();
|
||||||
m_thread.exit();
|
m_thread.exit();
|
||||||
m_thread.wait();
|
m_thread.wait();
|
||||||
|
|
||||||
|
if (getMessageQueueToGUI())
|
||||||
|
{
|
||||||
|
MsgReportStartStop *msg = MsgReportStartStop::create(false);
|
||||||
|
getMessageQueueToGUI()->push(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SigMFFileSink::handleMessage(const Message& cmd)
|
bool SigMFFileSink::handleMessage(const Message& cmd)
|
||||||
|
@ -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);
|
SigMFFileSink(DeviceAPI *deviceAPI);
|
||||||
virtual ~SigMFFileSink();
|
virtual ~SigMFFileSink();
|
||||||
virtual void destroy() { delete this; }
|
virtual void destroy() { delete this; }
|
||||||
|
@ -74,6 +74,7 @@ void SigMFFileSinkBaseband::startWork()
|
|||||||
void SigMFFileSinkBaseband::stopWork()
|
void SigMFFileSinkBaseband::stopWork()
|
||||||
{
|
{
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
m_sink.stopRecording();
|
||||||
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
||||||
QObject::disconnect(
|
QObject::disconnect(
|
||||||
&m_sampleFifo,
|
&m_sampleFifo,
|
||||||
@ -166,13 +167,10 @@ bool SigMFFileSinkBaseband::handleMessage(const Message& cmd)
|
|||||||
MsgConfigureSigMFFileSinkWork& conf = (MsgConfigureSigMFFileSinkWork&) cmd;
|
MsgConfigureSigMFFileSinkWork& conf = (MsgConfigureSigMFFileSinkWork&) cmd;
|
||||||
qDebug() << "SigMFFileSinkBaseband::handleMessage: MsgConfigureSigMFFileSinkWork: " << conf.isWorking();
|
qDebug() << "SigMFFileSinkBaseband::handleMessage: MsgConfigureSigMFFileSinkWork: " << conf.isWorking();
|
||||||
|
|
||||||
if (!m_settings.m_squelchRecordingEnable)
|
if (conf.isWorking()) {
|
||||||
{
|
m_sink.startRecording();
|
||||||
if (conf.isWorking()) {
|
} else {
|
||||||
m_sink.startRecording();
|
m_sink.stopRecording();
|
||||||
} else {
|
|
||||||
m_sink.stopRecording();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -121,18 +121,34 @@ bool SigMFFileSinkGUI::handleMessage(const Message& message)
|
|||||||
else if (SigMFFileSinkMessages::MsgReportRecording::match(message))
|
else if (SigMFFileSinkMessages::MsgReportRecording::match(message))
|
||||||
{
|
{
|
||||||
const SigMFFileSinkMessages::MsgReportSquelch& report = (SigMFFileSinkMessages::MsgReportSquelch&) message;
|
const SigMFFileSinkMessages::MsgReportSquelch& report = (SigMFFileSinkMessages::MsgReportSquelch&) message;
|
||||||
|
qDebug("SigMFFileSinkGUI::handleMessage: FileSinkMessages::MsgReportRecording: %s", report.getOpen() ? "on" : "off");
|
||||||
|
|
||||||
|
blockSignals(true);
|
||||||
|
|
||||||
if (report.getOpen())
|
if (report.getOpen())
|
||||||
{
|
{
|
||||||
ui->record->setStyleSheet("QToolButton { background-color : red; }");
|
ui->record->setStyleSheet("QToolButton { background-color : red; }");
|
||||||
ui->squelchedRecording->setEnabled(false);
|
ui->record->setChecked(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -147,6 +163,7 @@ SigMFFileSinkGUI::SigMFFileSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISe
|
|||||||
m_pluginAPI(pluginAPI),
|
m_pluginAPI(pluginAPI),
|
||||||
m_deviceUISet(deviceUISet),
|
m_deviceUISet(deviceUISet),
|
||||||
m_channelMarker(this),
|
m_channelMarker(this),
|
||||||
|
m_running(false),
|
||||||
m_fixedShiftIndex(0),
|
m_fixedShiftIndex(0),
|
||||||
m_basebandSampleRate(0),
|
m_basebandSampleRate(0),
|
||||||
m_fixedPosition(false),
|
m_fixedPosition(false),
|
||||||
@ -225,6 +242,8 @@ void SigMFFileSinkGUI::displaySettings()
|
|||||||
|
|
||||||
blockApplySettings(true);
|
blockApplySettings(true);
|
||||||
|
|
||||||
|
ui->record->setEnabled(!m_settings.m_squelchRecordingEnable);
|
||||||
|
ui->squelchedRecording->setChecked(m_settings.m_squelchRecordingEnable);
|
||||||
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
||||||
ui->fileNameText->setText(m_settings.m_fileRecordName);
|
ui->fileNameText->setText(m_settings.m_fileRecordName);
|
||||||
ui->decimationFactor->setCurrentIndex(m_settings.m_log2Decim);
|
ui->decimationFactor->setCurrentIndex(m_settings.m_log2Decim);
|
||||||
@ -236,10 +255,14 @@ void SigMFFileSinkGUI::displaySettings()
|
|||||||
ui->postSquelchTime->setValue(m_settings.m_squelchPostRecordTime);
|
ui->postSquelchTime->setValue(m_settings.m_squelchPostRecordTime);
|
||||||
ui->postSquelchTimeText->setText(tr("%1").arg(m_settings.m_squelchPostRecordTime));
|
ui->postSquelchTimeText->setText(tr("%1").arg(m_settings.m_squelchPostRecordTime));
|
||||||
ui->squelchedRecording->setChecked(m_settings.m_squelchRecordingEnable);
|
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->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();
|
displayStreamIndex();
|
||||||
@ -462,14 +485,6 @@ void SigMFFileSinkGUI::on_squelchedRecording_toggled(bool checked)
|
|||||||
|
|
||||||
void SigMFFileSinkGUI::on_record_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);
|
m_sigMFFileSink->record(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ private:
|
|||||||
DeviceUISet* m_deviceUISet;
|
DeviceUISet* m_deviceUISet;
|
||||||
ChannelMarker m_channelMarker;
|
ChannelMarker m_channelMarker;
|
||||||
SigMFFileSinkSettings m_settings;
|
SigMFFileSinkSettings m_settings;
|
||||||
|
bool m_running;
|
||||||
int m_fixedShiftIndex;
|
int m_fixedShiftIndex;
|
||||||
int m_basebandSampleRate;
|
int m_basebandSampleRate;
|
||||||
double m_shiftFrequencyFactor; //!< Channel frequency shift factor
|
double m_shiftFrequencyFactor; //!< Channel frequency shift factor
|
||||||
|
@ -52,6 +52,12 @@ void SigMFFileSinkSink::startRecording()
|
|||||||
m_fileSink.startRecording();
|
m_fileSink.startRecording();
|
||||||
m_record = true;
|
m_record = true;
|
||||||
|
|
||||||
|
if (m_msgQueueToGUI)
|
||||||
|
{
|
||||||
|
SigMFFileSinkMessages::MsgReportRecording *msg = SigMFFileSinkMessages::MsgReportRecording::create(true);
|
||||||
|
m_msgQueueToGUI->push(msg);
|
||||||
|
}
|
||||||
|
|
||||||
// copy pre record samples
|
// copy pre record samples
|
||||||
SampleVector::iterator p1Begin, p1End, p2Begin, p2End;
|
SampleVector::iterator p1Begin, p1End, p2Begin, p2End;
|
||||||
m_preRecordBuffer.readBegin(m_preRecordFill, &p1Begin, &p1End, &p2Begin, &p2End);
|
m_preRecordBuffer.readBegin(m_preRecordFill, &p1Begin, &p1End, &p2Begin, &p2End);
|
||||||
@ -77,6 +83,13 @@ void SigMFFileSinkSink::stopRecording()
|
|||||||
{
|
{
|
||||||
m_preRecordBuffer.reset();
|
m_preRecordBuffer.reset();
|
||||||
m_fileSink.stopRecording();
|
m_fileSink.stopRecording();
|
||||||
|
|
||||||
|
if (m_msgQueueToGUI)
|
||||||
|
{
|
||||||
|
SigMFFileSinkMessages::MsgReportRecording *msg = SigMFFileSinkMessages::MsgReportRecording::create(false);
|
||||||
|
m_msgQueueToGUI->push(msg);
|
||||||
|
}
|
||||||
|
|
||||||
m_record = false;
|
m_record = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,12 +138,6 @@ void SigMFFileSinkSink::feed(const SampleVector::const_iterator& begin, const Sa
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_msgQueueToGUI)
|
|
||||||
{
|
|
||||||
SigMFFileSinkMessages::MsgReportRecording *msg = SigMFFileSinkMessages::MsgReportRecording::create(false);
|
|
||||||
m_msgQueueToGUI->push(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_fileSink.feed(beginw, endw + m_postSquelchCounter, true);
|
m_fileSink.feed(beginw, endw + m_postSquelchCounter, true);
|
||||||
nbToWrite = m_postSquelchCounter;
|
nbToWrite = m_postSquelchCounter;
|
||||||
m_postSquelchCounter = 0;
|
m_postSquelchCounter = 0;
|
||||||
@ -295,15 +302,8 @@ void SigMFFileSinkSink::squelchRecording(bool squelchOpen)
|
|||||||
|
|
||||||
if (squelchOpen)
|
if (squelchOpen)
|
||||||
{
|
{
|
||||||
if (!m_record)
|
if (!m_record) {
|
||||||
{
|
|
||||||
startRecording();
|
startRecording();
|
||||||
|
|
||||||
if (m_msgQueueToGUI)
|
|
||||||
{
|
|
||||||
SigMFFileSinkMessages::MsgReportRecording *msg = SigMFFileSinkMessages::MsgReportRecording::create(true);
|
|
||||||
m_msgQueueToGUI->push(msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user