ReBuffer is overkill for scope vis and crashes OSX; just push and delete at reciever; clean up lazy exception-fallback loadSession code

This commit is contained in:
Charles J. Cliffe 2016-06-02 19:25:52 -04:00
parent 00d3140c0d
commit 99f7beba49
3 changed files with 134 additions and 132 deletions

View File

@ -1598,15 +1598,22 @@ bool AppFrame::loadSession(std::string fileName) {
wxGetApp().getDemodMgr().terminateAll();
try {
if (!l.rootNode()->hasAnother("header")) {
return false;
}
DataNode *header = l.rootNode()->getNext("header");
if (header->hasAnother("version")) {
std::string version(*header->getNext("version"));
std::cout << "Loading " << version << " session file" << std::endl;
// std::cout << "Loading " << version << " session file" << std::endl;
}
if (header->hasAnother("center_freq")) {
long long center_freq = *header->getNext("center_freq");
std::cout << "\tCenter Frequency: " << center_freq << std::endl;
// std::cout << "\tCenter Frequency: " << center_freq << std::endl;
wxGetApp().setFrequency(center_freq);
}
if (header->hasAnother("sample_rate")) {
int sample_rate = *header->getNext("sample_rate");
@ -1623,6 +1630,7 @@ bool AppFrame::loadSession(std::string fileName) {
}
if (l.rootNode()->hasAnother("demodulators")) {
DataNode *demodulators = l.rootNode()->getNext("demodulators");
int numDemodulators = 0;
@ -1724,20 +1732,20 @@ bool AppFrame::loadSession(std::string fileName) {
}
}
if (!found_device) {
std::cout << "\tWarning: named output device '" << output_device << "' was not found. Using default output.";
}
// if (!found_device) {
// std::cout << "\tWarning: named output device '" << output_device << "' was not found. Using default output.";
// }
newDemod->run();
newDemod->setActive(true);
demodsLoaded.push_back(newDemod);
// wxGetApp().bindDemodulator(newDemod);
std::cout << "\tAdded demodulator at frequency " << freq << " type " << type << std::endl;
std::cout << "\t\tBandwidth: " << bandwidth << std::endl;
std::cout << "\t\tSquelch Level: " << squelch_level << std::endl;
std::cout << "\t\tSquelch Enabled: " << (squelch_enabled ? "true" : "false") << std::endl;
std::cout << "\t\tOutput Device: " << output_device << std::endl;
// std::cout << "\tAdded demodulator at frequency " << freq << " type " << type << std::endl;
// std::cout << "\t\tBandwidth: " << bandwidth << std::endl;
// std::cout << "\t\tSquelch Level: " << squelch_level << std::endl;
// std::cout << "\t\tSquelch Enabled: " << (squelch_enabled ? "true" : "false") << std::endl;
// std::cout << "\t\tOutput Device: " << output_device << std::endl;
}
DemodulatorInstance *focusDemod = loadedDemod?loadedDemod:newDemod;
@ -1746,9 +1754,7 @@ bool AppFrame::loadSession(std::string fileName) {
wxGetApp().bindDemodulators(&demodsLoaded);
wxGetApp().getDemodMgr().setActiveDemodulator(focusDemod, false);
}
} catch (DataInvalidChildException &e) {
std::cout << e.what() << std::endl;
return false;
}
} catch (DataTypeMismatchException &e) {
std::cout << e.what() << std::endl;
return false;

View File

@ -23,7 +23,6 @@ DemodulatorThread::DemodulatorThread(DemodulatorInstance *parent)
}
DemodulatorThread::~DemodulatorThread() {
}
void DemodulatorThread::onBindOutput(std::string name, ThreadQueueBase *threadQueue) {
@ -65,8 +64,6 @@ void DemodulatorThread::run() {
pthread_setschedparam(tID, SCHED_FIFO, &prio);
#endif
ReBuffer<AudioThreadInput> audioVisBuffers("DemodulatorThreadAudioBuffers");
std::cout << "Demodulator thread started.." << std::endl;
iqInputQueue = static_cast<DemodulatorThreadPostInputQueue*>(getInputQueue("IQDataInput"));
@ -188,7 +185,7 @@ void DemodulatorThread::run() {
}
if (ati && localAudioVisOutputQueue != nullptr && localAudioVisOutputQueue->empty()) {
AudioThreadInput *ati_vis = audioVisBuffers.getBuffer();
AudioThreadInput *ati_vis = new AudioThreadInput;
ati_vis->setRefCount(1);
ati_vis->sampleRate = inp->sampleRate;
@ -284,11 +281,10 @@ void DemodulatorThread::run() {
//Guard the cleanup of audioVisOutputQueue properly.
std::lock_guard < std::mutex > lock(m_mutexAudioVisOutputQueue);
if (audioVisOutputQueue != nullptr && !audioVisOutputQueue->empty()) {
AudioThreadInput *dummy_vis;
audioVisOutputQueue->pop(dummy_vis);
}
audioVisBuffers.purge();
// if (audioVisOutputQueue != nullptr && !audioVisOutputQueue->empty()) {
// AudioThreadInput *dummy_vis;
// audioVisOutputQueue->pop(dummy_vis);
// }
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_TERMINATED);
tCmd.context = this;

View File

@ -99,7 +99,7 @@ void ScopeVisualProcessor::process() {
}
size_t i, iMax = audioInputData->data.size();
if (!iMax) {
audioInputData->decRefCount();
delete audioInputData; //->decRefCount();
return;
}
@ -213,7 +213,7 @@ void ScopeVisualProcessor::process() {
renderData->inputRate = audioInputData->inputRate;
renderData->sampleRate = audioInputData->sampleRate;
audioInputData->decRefCount();
delete audioInputData; //->decRefCount();
float fft_ceil = 0, fft_floor = 1;
@ -280,7 +280,7 @@ void ScopeVisualProcessor::process() {
renderData->spectrum = true;
distribute(renderData);
} else {
audioInputData->decRefCount();
delete audioInputData; //->decRefCount();
}
}
}