Fixed saving of .wav files when it was disabled

This commit is contained in:
Jordan Sherer 2018-09-12 16:08:25 -04:00
parent f4ed9a9eac
commit bafaf8a5ae
2 changed files with 21 additions and 16 deletions

View File

@ -170,7 +170,7 @@ QVector<QColor> g_ColorTbl;
namespace namespace
{ {
Radio::Frequency constexpr default_frequency {14078500}; Radio::Frequency constexpr default_frequency {14078000};
QRegExp message_alphabet {"[^\\x00-\\x1F]*"}; // base alphabet supported by FT8CALL QRegExp message_alphabet {"[^\\x00-\\x1F]*"}; // base alphabet supported by FT8CALL
@ -1730,9 +1730,12 @@ void MainWindow::readSettings()
m_modeTx=m_settings->value("ModeTx","JT9").toString(); m_modeTx=m_settings->value("ModeTx","JT9").toString();
if(m_modeTx.mid(0,3)=="JT9") ui->pbTxMode->setText("Tx JT9 @"); if(m_modeTx.mid(0,3)=="JT9") ui->pbTxMode->setText("Tx JT9 @");
if(m_modeTx=="JT65") ui->pbTxMode->setText("Tx JT65 #"); if(m_modeTx=="JT65") ui->pbTxMode->setText("Tx JT65 #");
ui->actionNone->setChecked(m_settings->value("SaveNone",true).toBool());
ui->actionSave_decoded->setChecked(m_settings->value("SaveDecoded",false).toBool()); // these save settings should never be enabled unless specifically called out by the user for every session.
ui->actionSave_all->setChecked(m_settings->value("SaveAll",false).toBool()); ui->actionNone->setChecked(true);
ui->actionSave_decoded->setChecked(false);
ui->actionSave_all->setChecked(false);
ui->RxFreqSpinBox->setValue(0); // ensure a change is signaled ui->RxFreqSpinBox->setValue(0); // ensure a change is signaled
ui->RxFreqSpinBox->setValue(m_settings->value("RxFreq",1500).toInt()); ui->RxFreqSpinBox->setValue(m_settings->value("RxFreq",1500).toInt());
m_nSubMode=m_settings->value("SubMode",0).toInt(); m_nSubMode=m_settings->value("SubMode",0).toInt();
@ -2001,11 +2004,15 @@ void MainWindow::dataSink(qint64 frames)
} }
m_fileToSave.clear (); m_fileToSave.clear ();
if(m_saveAll or m_bAltV or (m_bDecoded and m_saveDecoded) or (m_mode!="MSK144" and m_mode!="FT8")) {
m_bAltV=false;
// the following is potential a threading hazard - not a good // the following is potential a threading hazard - not a good
// idea to pass pointer to be processed in another thread // idea to pass pointer to be processed in another thread
m_saveWAVWatcher.setFuture (QtConcurrent::run (std::bind (&MainWindow::save_wave_file, m_saveWAVWatcher.setFuture (QtConcurrent::run (std::bind (&MainWindow::save_wave_file,
this, m_fnameWE, &dec_data.d2[0], m_TRperiod, m_config.my_callsign(), this, m_fnameWE, &dec_data.d2[0], m_TRperiod, m_config.my_callsign(),
m_config.my_grid(), m_mode, m_nSubMode, m_freqNominal, m_hisCall, m_hisGrid))); m_config.my_grid(), m_mode, m_nSubMode, m_freqNominal, m_hisCall, m_hisGrid)));
}
if (m_mode=="WSPR") { if (m_mode=="WSPR") {
QString c2name_string {m_fnameWE + ".c2"}; QString c2name_string {m_fnameWE + ".c2"};
int len1=c2name_string.length(); int len1=c2name_string.length();
@ -2096,6 +2103,7 @@ QString MainWindow::save_wave_file (QString const& name, short const * data, int
{{{'I','C','M','T'}}, comment.toLocal8Bit ()}, {{{'I','C','M','T'}}, comment.toLocal8Bit ()},
}; };
auto file_name = name + ".wav"; auto file_name = name + ".wav";
qDebug() << "saving" << file_name;
BWFFile wav {format, file_name, list_info}; BWFFile wav {format, file_name, list_info};
if (!wav.open (BWFFile::WriteOnly) if (!wav.open (BWFFile::WriteOnly)
|| 0 > wav.write (reinterpret_cast<char const *> (data) || 0 > wav.write (reinterpret_cast<char const *> (data)
@ -2208,7 +2216,7 @@ void MainWindow::fastSink(qint64 frames)
auto const& period_start = now.addSecs (-n); auto const& period_start = now.addSecs (-n);
m_fnameWE = m_config.save_directory ().absoluteFilePath (period_start.toString ("yyMMdd_hhmmss")); m_fnameWE = m_config.save_directory ().absoluteFilePath (period_start.toString ("yyMMdd_hhmmss"));
m_fileToSave.clear (); m_fileToSave.clear ();
if(m_saveAll or m_bAltV or (m_bDecoded and m_saveDecoded) or (m_mode!="MSK144")) { if(m_saveAll or m_bAltV or (m_bDecoded and m_saveDecoded) or (m_mode!="MSK144" and m_mode!="FT8")) {
m_bAltV=false; m_bAltV=false;
// the following is potential a threading hazard - not a good // the following is potential a threading hazard - not a good
// idea to pass pointer to be processed in another thread // idea to pass pointer to be processed in another thread
@ -3119,7 +3127,7 @@ void MainWindow::diskDat() //diskDat()
void MainWindow::on_actionDelete_all_wav_files_in_SaveDir_triggered() void MainWindow::on_actionDelete_all_wav_files_in_SaveDir_triggered()
{ {
auto button = MessageBox::query_message (this, tr ("Confirm Delete"), auto button = MessageBox::query_message (this, tr ("Confirm Delete"),
tr ("Are you sure you want to delete all *.wav and *.c2 files in \"%1\"?") tr ("Are you sure you want to delete all *.wav files in \"%1\"?")
.arg (QDir::toNativeSeparators (m_config.save_directory ().absolutePath ()))); .arg (QDir::toNativeSeparators (m_config.save_directory ().absolutePath ())));
if (MessageBox::Yes == button) { if (MessageBox::Yes == button) {
Q_FOREACH (auto const& file Q_FOREACH (auto const& file

View File

@ -4470,10 +4470,10 @@ list. The list can be maintained in Settings (F2).</string>
</action> </action>
<action name="actionDelete_all_wav_files_in_SaveDir"> <action name="actionDelete_all_wav_files_in_SaveDir">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Delete all *.wav &amp;&amp; *.c2 files in SaveDir</string> <string>Delete all *.wav files in SaveDir</string>
</property> </property>
</action> </action>
<action name="actionQuickDecode"> <action name="actionQuickDecode">
@ -4500,9 +4500,6 @@ list. The list can be maintained in Settings (F2).</string>
<property name="text"> <property name="text">
<string>None</string> <string>None</string>
</property> </property>
<property name="visible">
<bool>false</bool>
</property>
</action> </action>
<action name="actionSave_all"> <action name="actionSave_all">
<property name="checkable"> <property name="checkable">