Added #583: add periodic file generation, plus other options:

- Added a Recording menu,
git commit -m Added
This commit is contained in:
vsonnier
2018-01-13 11:50:08 +01:00
parent 4d0f3a794d
commit 26deefd606
14 changed files with 441 additions and 91 deletions
+7 -15
View File
@@ -2,7 +2,6 @@
// SPDX-License-Identifier: GPL-2.0+
#include <memory>
#include <ctime>
#include <iomanip>
#include "DemodulatorInstance.h"
@@ -628,9 +627,6 @@ void DemodulatorInstance::startRecording() {
AudioSinkFileThread *newSinkThread = new AudioSinkFileThread();
AudioFileWAV *afHandler = new AudioFileWAV();
time_t t = std::time(nullptr);
tm ltm = *std::localtime(&t);
std::stringstream fileName;
std::wstring userLabel = getDemodulatorUserLabel();
@@ -643,17 +639,13 @@ void DemodulatorInstance::startRecording() {
} else {
fileName << getLabel();
}
// GCC 5+
// fileName << "_" << std::put_time(&ltm, "%d-%m-%Y_%H-%M-%S");
char timeStr[512];
//International format: Year.Month.Day, also lexicographically sortable
strftime(timeStr, sizeof(timeStr), "%Y-%m-%d_%H-%M-%S", &ltm);
fileName << "_" << timeStr;
afHandler->setOutputFileName(fileName.str());
newSinkThread->setAudioFileNameBase(fileName.str());
//attach options:
newSinkThread->setSquelchOption(wxGetApp().getConfig()->getRecordingSquelchOption());
newSinkThread->setFileTimeLimit(wxGetApp().getConfig()->getRecordingFileTimeLimit());
newSinkThread->setAudioFileHandler(afHandler);
audioSinkThread = newSinkThread;
+28 -27
View File
@@ -232,32 +232,39 @@ void DemodulatorThread::run() {
localAudioSinkOutputQueue = audioSinkOutputQueue;
}
if (audioOutputQueue != nullptr && ati && ati->data.size() && !squelched) {
ati->peak = 0;
//compute audio peak:
if (audioOutputQueue != nullptr && ati) {
for (auto data_i : ati->data) {
float p = fabs(data_i);
if (p > ati->peak) {
ati->peak = p;
}
}
} else if (ati) {
//squelch situation, but recording is on-going, so record "silence" to AudioSink:
if (localAudioSinkOutputQueue != nullptr) {
ati->peak = 0;
//Zero the ati samples
ati->peak = 0;
ati->data.assign(ati->data.size(), 0.0f);
if (!localAudioSinkOutputQueue->try_push(ati)) {
std::cout << "DemodulatorThread::run() cannot push ati into audioSinkOutputQueue, is full !" << std::endl;
for (auto data_i : ati->data) {
float p = fabs(data_i);
if (p > ati->peak) {
ati->peak = p;
}
}
}
ati = nullptr;
}
//attach squelch flag to samples, to be used by audio sink.
if (ati) {
ati->is_squelch_active = squelched;
}
//Push to audio sink, if any:
if (ati && localAudioSinkOutputQueue != nullptr) {
if (!localAudioSinkOutputQueue->try_push(ati)) {
std::cout << "DemodulatorThread::run() cannot push ati into audioSinkOutputQueue, is full !" << std::endl;
std::this_thread::yield();
}
}
//now we can nullify ati if squelched, to skip the next processing entirely.
if (ati && squelched) {
ati = nullptr;
}
//At that point, capture the current state of audioVisOutputQueue in a local
//variable, and works with it with now on until the next while-turn.
DemodulatorThreadOutputQueuePtr localAudioVisOutputQueue = nullptr;
@@ -345,12 +352,6 @@ void DemodulatorThread::run() {
std::this_thread::yield();
}
}
if (localAudioSinkOutputQueue != nullptr) {
if (!localAudioSinkOutputQueue->try_push(ati)) {
std::cout << "DemodulatorThread::run() cannot push ati into audioSinkOutputQueue, is full !" << std::endl;
}
}
}
DemodulatorThreadControlCommand command;