1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

FileSink: enable record button only when plugin is running (2). Fixes #782

This commit is contained in:
f4exb 2021-02-27 23:06:58 +01:00
parent e50e228984
commit 9d7a6aff7b
3 changed files with 32 additions and 37 deletions

View File

@ -74,6 +74,7 @@ void FileSinkBaseband::startWork()
void FileSinkBaseband::stopWork() void FileSinkBaseband::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 FileSinkBaseband::handleMessage(const Message& cmd)
MsgConfigureFileSinkWork& conf = (MsgConfigureFileSinkWork&) cmd; MsgConfigureFileSinkWork& conf = (MsgConfigureFileSinkWork&) cmd;
qDebug() << "FileSinkBaseband::handleMessage: MsgConfigureFileSinkWork: " << conf.isWorking(); qDebug() << "FileSinkBaseband::handleMessage: MsgConfigureFileSinkWork: " << 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;

View File

@ -104,11 +104,11 @@ bool FileSinkGUI::handleMessage(const Message& message)
{ {
const FileSink::MsgReportStartStop& cfg = (FileSink::MsgReportStartStop&) message; const FileSink::MsgReportStartStop& cfg = (FileSink::MsgReportStartStop&) message;
m_running = cfg.getStartStop(); 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); ui->record->setEnabled(m_running && !m_settings.m_squelchRecordingEnable);
blockSignals(false);
if (!m_running) {
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
}
return true; return true;
} }
@ -134,16 +134,22 @@ bool FileSinkGUI::handleMessage(const Message& message)
else if (FileSinkMessages::MsgReportRecording::match(message)) else if (FileSinkMessages::MsgReportRecording::match(message))
{ {
const FileSinkMessages::MsgReportSquelch& report = (FileSinkMessages::MsgReportSquelch&) message; const FileSinkMessages::MsgReportSquelch& report = (FileSinkMessages::MsgReportSquelch&) message;
qDebug("FileSinkGUI::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->record->setChecked(true);
} }
else else
{ {
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
ui->record->setChecked(false);
} }
blockSignals(false);
return true; return true;
} }
else if (FileSinkMessages::MsgReportRecordFileName::match(message)) else if (FileSinkMessages::MsgReportRecordFileName::match(message))
@ -191,7 +197,6 @@ FileSinkGUI::FileSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
ui->deltaFrequency->setValueRange(false, 8, -99999999, 99999999); ui->deltaFrequency->setValueRange(false, 8, -99999999, 99999999);
ui->position->setEnabled(m_fixedPosition); ui->position->setEnabled(m_fixedPosition);
ui->glSpectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum); ui->glSpectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum);
ui->record->setEnabled(false);
m_channelMarker.blockSignals(true); m_channelMarker.blockSignals(true);
m_channelMarker.setColor(m_settings.m_rgbColor); m_channelMarker.setColor(m_settings.m_rgbColor);
@ -250,6 +255,8 @@ void FileSinkGUI::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);
@ -260,7 +267,6 @@ void FileSinkGUI::displaySettings()
ui->preRecordTimeText->setText(tr("%1").arg(m_settings.m_preRecordTime)); ui->preRecordTimeText->setText(tr("%1").arg(m_settings.m_preRecordTime));
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->record->setEnabled(m_running && !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); }");
@ -444,11 +450,11 @@ void FileSinkGUI::on_spectrumSquelch_toggled(bool checked)
if (!m_settings.m_spectrumSquelchMode) if (!m_settings.m_spectrumSquelchMode)
{ {
m_settings.m_squelchRecordingEnable = false; m_settings.m_squelchRecordingEnable = false;
ui->record->setEnabled(true);
ui->squelchLevel->setStyleSheet("QDial { background:rgb(79,79,79); }"); ui->squelchLevel->setStyleSheet("QDial { background:rgb(79,79,79); }");
ui->squelchedRecording->blockSignals(true); ui->squelchedRecording->blockSignals(true);
ui->squelchedRecording->setChecked(false); ui->squelchedRecording->setChecked(false);
ui->squelchedRecording->blockSignals(false); ui->squelchedRecording->blockSignals(false);
ui->record->setEnabled(true);
} }
applySettings(); applySettings();
@ -477,19 +483,13 @@ void FileSinkGUI::on_postSquelchTime_valueChanged(int value)
void FileSinkGUI::on_squelchedRecording_toggled(bool checked) void FileSinkGUI::on_squelchedRecording_toggled(bool checked)
{ {
ui->record->setEnabled(m_running && !checked); ui->record->setEnabled(!checked);
m_settings.m_squelchRecordingEnable = checked; m_settings.m_squelchRecordingEnable = checked;
applySettings(); applySettings();
} }
void FileSinkGUI::on_record_toggled(bool checked) void FileSinkGUI::on_record_toggled(bool checked)
{ {
if (checked) {
ui->record->setStyleSheet("QToolButton { background-color : red; }");
} else {
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
}
m_fileSink->record(checked); m_fileSink->record(checked);
} }

View File

@ -65,9 +65,11 @@ void FileSinkSink::startRecording()
if (m_msgQueueToGUI) if (m_msgQueueToGUI)
{ {
FileSinkMessages::MsgReportRecordFileName *msg FileSinkMessages::MsgReportRecordFileName *msg1
= FileSinkMessages::MsgReportRecordFileName::create(m_fileSink.getCurrentFileName()); = FileSinkMessages::MsgReportRecordFileName::create(m_fileSink.getCurrentFileName());
m_msgQueueToGUI->push(msg); m_msgQueueToGUI->push(msg1);
FileSinkMessages::MsgReportRecording *msg2 = FileSinkMessages::MsgReportRecording::create(true);
m_msgQueueToGUI->push(msg2);
} }
// copy pre record samples // copy pre record samples
@ -94,6 +96,7 @@ void FileSinkSink::stopRecording()
if (m_record) if (m_record)
{ {
m_preRecordBuffer.reset(); m_preRecordBuffer.reset();
if (!m_fileSink.stopRecording()) if (!m_fileSink.stopRecording())
{ {
// qWarning already output stopRecording, just need to send to GUI // qWarning already output stopRecording, just need to send to GUI
@ -104,6 +107,13 @@ void FileSinkSink::stopRecording()
m_msgQueueToGUI->push(msg); m_msgQueueToGUI->push(msg);
} }
} }
if (m_msgQueueToGUI)
{
FileSinkMessages::MsgReportRecording *msg = FileSinkMessages::MsgReportRecording::create(false);
m_msgQueueToGUI->push(msg);
}
m_record = false; m_record = false;
} }
} }
@ -152,12 +162,6 @@ void FileSinkSink::feed(const SampleVector::const_iterator& begin, const SampleV
} }
else else
{ {
if (m_msgQueueToGUI)
{
FileSinkMessages::MsgReportRecording *msg = FileSinkMessages::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;
@ -322,15 +326,8 @@ void FileSinkSink::squelchRecording(bool squelchOpen)
if (squelchOpen) if (squelchOpen)
{ {
if (!m_record) if (!m_record) {
{
startRecording(); startRecording();
if (m_msgQueueToGUI)
{
FileSinkMessages::MsgReportRecording *msg = FileSinkMessages::MsgReportRecording::create(true);
m_msgQueueToGUI->push(msg);
}
} }
} }
else else