mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-04-05 11:09:14 -04:00
Merge pull request #358 from cjcliffe/bugfix_sessions_crashes
Session and Crash fixes
This commit is contained in:
commit
ad94fe6de3
246
src/AppFrame.cpp
246
src/AppFrame.cpp
@ -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");
|
||||
|
||||
std::string version(*header->getNext("version"));
|
||||
std::cout << "Loading " << version << " session file" << std::endl;
|
||||
if (header->hasAnother("version")) {
|
||||
std::string version(*header->getNext("version"));
|
||||
// std::cout << "Loading " << version << " session file" << std::endl;
|
||||
}
|
||||
|
||||
long long center_freq = *header->getNext("center_freq");
|
||||
std::cout << "\tCenter Frequency: " << center_freq << std::endl;
|
||||
if (header->hasAnother("center_freq")) {
|
||||
long long center_freq = *header->getNext("center_freq");
|
||||
// std::cout << "\tCenter Frequency: " << center_freq << std::endl;
|
||||
wxGetApp().setFrequency(center_freq);
|
||||
}
|
||||
|
||||
wxGetApp().setFrequency(center_freq);
|
||||
|
||||
if (header->hasAnother("sample_rate")) {
|
||||
int sample_rate = *header->getNext("sample_rate");
|
||||
@ -1623,137 +1630,136 @@ bool AppFrame::loadSession(std::string fileName) {
|
||||
|
||||
}
|
||||
|
||||
DataNode *demodulators = l.rootNode()->getNext("demodulators");
|
||||
if (l.rootNode()->hasAnother("demodulators")) {
|
||||
DataNode *demodulators = l.rootNode()->getNext("demodulators");
|
||||
|
||||
int numDemodulators = 0;
|
||||
DemodulatorInstance *loadedDemod = NULL;
|
||||
DemodulatorInstance *newDemod = NULL;
|
||||
std::vector<DemodulatorInstance *> demodsLoaded;
|
||||
|
||||
while (demodulators->hasAnother("demodulator")) {
|
||||
DataNode *demod = demodulators->getNext("demodulator");
|
||||
|
||||
if (!demod->hasAnother("bandwidth") || !demod->hasAnother("frequency")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long bandwidth = *demod->getNext("bandwidth");
|
||||
long long freq = *demod->getNext("frequency");
|
||||
float squelch_level = demod->hasAnother("squelch_level") ? (float) *demod->getNext("squelch_level") : 0;
|
||||
int squelch_enabled = demod->hasAnother("squelch_enabled") ? (int) *demod->getNext("squelch_enabled") : 0;
|
||||
int muted = demod->hasAnother("muted") ? (int) *demod->getNext("muted") : 0;
|
||||
int delta_locked = demod->hasAnother("delta_lock") ? (int) *demod->getNext("delta_lock") : 0;
|
||||
int delta_ofs = demod->hasAnother("delta_ofs") ? (int) *demod->getNext("delta_ofs") : 0;
|
||||
std::string output_device = demod->hasAnother("output_device") ? string(*(demod->getNext("output_device"))) : "";
|
||||
float gain = demod->hasAnother("gain") ? (float) *demod->getNext("gain") : 1.0;
|
||||
int numDemodulators = 0;
|
||||
DemodulatorInstance *loadedDemod = NULL;
|
||||
DemodulatorInstance *newDemod = NULL;
|
||||
std::vector<DemodulatorInstance *> demodsLoaded;
|
||||
|
||||
std::string type = "FM";
|
||||
while (demodulators->hasAnother("demodulator")) {
|
||||
DataNode *demod = demodulators->getNext("demodulator");
|
||||
|
||||
DataNode *demodTypeNode = demod->hasAnother("type")?demod->getNext("type"):nullptr;
|
||||
|
||||
if (demodTypeNode && demodTypeNode->element()->getDataType() == DATA_INT) {
|
||||
int legacyType = *demodTypeNode;
|
||||
int legacyStereo = demod->hasAnother("stereo") ? (int) *demod->getNext("stereo") : 0;
|
||||
switch (legacyType) { // legacy demod ID
|
||||
case 1: type = legacyStereo?"FMS":"FM"; break;
|
||||
case 2: type = "AM"; break;
|
||||
case 3: type = "LSB"; break;
|
||||
case 4: type = "USB"; break;
|
||||
case 5: type = "DSB"; break;
|
||||
case 6: type = "ASK"; break;
|
||||
case 7: type = "APSK"; break;
|
||||
case 8: type = "BPSK"; break;
|
||||
case 9: type = "DPSK"; break;
|
||||
case 10: type = "PSK"; break;
|
||||
case 11: type = "OOK"; break;
|
||||
case 12: type = "ST"; break;
|
||||
case 13: type = "SQAM"; break;
|
||||
case 14: type = "QAM"; break;
|
||||
case 15: type = "QPSK"; break;
|
||||
case 16: type = "I/Q"; break;
|
||||
default: type = "FM"; break;
|
||||
if (!demod->hasAnother("bandwidth") || !demod->hasAnother("frequency")) {
|
||||
continue;
|
||||
}
|
||||
} else if (demodTypeNode && demodTypeNode->element()->getDataType() == DATA_STRING) {
|
||||
demodTypeNode->element()->get(type);
|
||||
}
|
||||
|
||||
ModemSettings mSettings;
|
||||
|
||||
if (demod->hasAnother("settings")) {
|
||||
DataNode *modemSettings = demod->getNext("settings");
|
||||
for (int msi = 0, numSettings = modemSettings->numChildren(); msi < numSettings; msi++) {
|
||||
DataNode *settingNode = modemSettings->child(msi);
|
||||
std::string keyName = settingNode->getName();
|
||||
std::string strSettingValue = settingNode->element()->toString();
|
||||
|
||||
if (keyName != "" && strSettingValue != "") {
|
||||
mSettings[keyName] = strSettingValue;
|
||||
long bandwidth = *demod->getNext("bandwidth");
|
||||
long long freq = *demod->getNext("frequency");
|
||||
float squelch_level = demod->hasAnother("squelch_level") ? (float) *demod->getNext("squelch_level") : 0;
|
||||
int squelch_enabled = demod->hasAnother("squelch_enabled") ? (int) *demod->getNext("squelch_enabled") : 0;
|
||||
int muted = demod->hasAnother("muted") ? (int) *demod->getNext("muted") : 0;
|
||||
int delta_locked = demod->hasAnother("delta_lock") ? (int) *demod->getNext("delta_lock") : 0;
|
||||
int delta_ofs = demod->hasAnother("delta_ofs") ? (int) *demod->getNext("delta_ofs") : 0;
|
||||
std::string output_device = demod->hasAnother("output_device") ? string(*(demod->getNext("output_device"))) : "";
|
||||
float gain = demod->hasAnother("gain") ? (float) *demod->getNext("gain") : 1.0;
|
||||
|
||||
std::string type = "FM";
|
||||
|
||||
DataNode *demodTypeNode = demod->hasAnother("type")?demod->getNext("type"):nullptr;
|
||||
|
||||
if (demodTypeNode && demodTypeNode->element()->getDataType() == DATA_INT) {
|
||||
int legacyType = *demodTypeNode;
|
||||
int legacyStereo = demod->hasAnother("stereo") ? (int) *demod->getNext("stereo") : 0;
|
||||
switch (legacyType) { // legacy demod ID
|
||||
case 1: type = legacyStereo?"FMS":"FM"; break;
|
||||
case 2: type = "AM"; break;
|
||||
case 3: type = "LSB"; break;
|
||||
case 4: type = "USB"; break;
|
||||
case 5: type = "DSB"; break;
|
||||
case 6: type = "ASK"; break;
|
||||
case 7: type = "APSK"; break;
|
||||
case 8: type = "BPSK"; break;
|
||||
case 9: type = "DPSK"; break;
|
||||
case 10: type = "PSK"; break;
|
||||
case 11: type = "OOK"; break;
|
||||
case 12: type = "ST"; break;
|
||||
case 13: type = "SQAM"; break;
|
||||
case 14: type = "QAM"; break;
|
||||
case 15: type = "QPSK"; break;
|
||||
case 16: type = "I/Q"; break;
|
||||
default: type = "FM"; break;
|
||||
}
|
||||
} else if (demodTypeNode && demodTypeNode->element()->getDataType() == DATA_STRING) {
|
||||
demodTypeNode->element()->get(type);
|
||||
}
|
||||
|
||||
ModemSettings mSettings;
|
||||
|
||||
if (demod->hasAnother("settings")) {
|
||||
DataNode *modemSettings = demod->getNext("settings");
|
||||
for (int msi = 0, numSettings = modemSettings->numChildren(); msi < numSettings; msi++) {
|
||||
DataNode *settingNode = modemSettings->child(msi);
|
||||
std::string keyName = settingNode->getName();
|
||||
std::string strSettingValue = settingNode->element()->toString();
|
||||
|
||||
if (keyName != "" && strSettingValue != "") {
|
||||
mSettings[keyName] = strSettingValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newDemod = wxGetApp().getDemodMgr().newThread();
|
||||
|
||||
newDemod = wxGetApp().getDemodMgr().newThread();
|
||||
|
||||
if (demod->hasAnother("active")) {
|
||||
loadedDemod = newDemod;
|
||||
}
|
||||
|
||||
numDemodulators++;
|
||||
newDemod->setDemodulatorType(type);
|
||||
newDemod->writeModemSettings(mSettings);
|
||||
newDemod->setBandwidth(bandwidth);
|
||||
newDemod->setFrequency(freq);
|
||||
newDemod->setGain(gain);
|
||||
newDemod->updateLabel(freq);
|
||||
newDemod->setMuted(muted?true:false);
|
||||
if (delta_locked) {
|
||||
newDemod->setDeltaLock(true);
|
||||
newDemod->setDeltaLockOfs(delta_ofs);
|
||||
}
|
||||
if (squelch_enabled) {
|
||||
newDemod->setSquelchEnabled(true);
|
||||
newDemod->setSquelchLevel(squelch_level);
|
||||
}
|
||||
|
||||
bool found_device = false;
|
||||
std::map<int, RtAudio::DeviceInfo>::iterator i;
|
||||
for (i = outputDevices.begin(); i != outputDevices.end(); i++) {
|
||||
if (i->second.name == output_device) {
|
||||
newDemod->setOutputDevice(i->first);
|
||||
found_device = true;
|
||||
if (demod->hasAnother("active")) {
|
||||
loadedDemod = newDemod;
|
||||
}
|
||||
|
||||
numDemodulators++;
|
||||
newDemod->setDemodulatorType(type);
|
||||
newDemod->writeModemSettings(mSettings);
|
||||
newDemod->setBandwidth(bandwidth);
|
||||
newDemod->setFrequency(freq);
|
||||
newDemod->setGain(gain);
|
||||
newDemod->updateLabel(freq);
|
||||
newDemod->setMuted(muted?true:false);
|
||||
if (delta_locked) {
|
||||
newDemod->setDeltaLock(true);
|
||||
newDemod->setDeltaLockOfs(delta_ofs);
|
||||
}
|
||||
if (squelch_enabled) {
|
||||
newDemod->setSquelchEnabled(true);
|
||||
newDemod->setSquelchLevel(squelch_level);
|
||||
}
|
||||
|
||||
bool found_device = false;
|
||||
std::map<int, RtAudio::DeviceInfo>::iterator i;
|
||||
for (i = outputDevices.begin(); i != outputDevices.end(); i++) {
|
||||
if (i->second.name == output_device) {
|
||||
newDemod->setOutputDevice(i->first);
|
||||
found_device = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 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 " << newDemod->getFrequency() << " 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;
|
||||
}
|
||||
|
||||
if (!found_device) {
|
||||
std::cout << "\tWarning: named output device '" << output_device << "' was not found. Using default output.";
|
||||
|
||||
DemodulatorInstance *focusDemod = loadedDemod?loadedDemod:newDemod;
|
||||
|
||||
if (focusDemod) {
|
||||
wxGetApp().bindDemodulators(&demodsLoaded);
|
||||
wxGetApp().getDemodMgr().setActiveDemodulator(focusDemod, false);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
DemodulatorInstance *focusDemod = loadedDemod?loadedDemod:newDemod;
|
||||
|
||||
if (focusDemod) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
currentSessionFile = fileName;
|
||||
|
||||
std::string filePart = fileName.substr(fileName.find_last_of(filePathSeparator) + 1);
|
||||
|
@ -368,7 +368,7 @@ void AudioThread::run() {
|
||||
pthread_setschedparam(tID, SCHED_RR, &prio);
|
||||
#endif
|
||||
|
||||
std::cout << "Audio thread initializing.." << std::endl;
|
||||
// std::cout << "Audio thread initializing.." << std::endl;
|
||||
|
||||
if (dac.getDeviceCount() < 1) {
|
||||
std::cout << "No audio devices found!" << std::endl;
|
||||
@ -377,7 +377,7 @@ void AudioThread::run() {
|
||||
|
||||
setupDevice((outputDevice.load() == -1) ? (dac.getDefaultOutputDevice()) : outputDevice.load());
|
||||
|
||||
std::cout << "Audio thread started." << std::endl;
|
||||
// std::cout << "Audio thread started." << std::endl;
|
||||
|
||||
inputQueue = static_cast<AudioThreadInputQueue *>(getInputQueue("AudioDataInput"));
|
||||
threadQueueNotify = static_cast<DemodulatorThreadCommandQueue*>(getOutputQueue("NotifyQueue"));
|
||||
@ -414,7 +414,7 @@ void AudioThread::run() {
|
||||
tCmd.context = this;
|
||||
threadQueueNotify->push(tCmd);
|
||||
}
|
||||
std::cout << "Audio thread done." << std::endl;
|
||||
// std::cout << "Audio thread done." << std::endl;
|
||||
}
|
||||
|
||||
void AudioThread::terminate() {
|
||||
|
@ -11,17 +11,19 @@ DemodulatorInstance::DemodulatorInstance() :
|
||||
#if ENABLE_DIGITAL_LAB
|
||||
activeOutput = nullptr;
|
||||
#endif
|
||||
terminated.store(true);
|
||||
audioTerminated.store(true);
|
||||
terminated.store(true);
|
||||
demodTerminated.store(true);
|
||||
audioTerminated.store(true);
|
||||
preDemodTerminated.store(true);
|
||||
active.store(false);
|
||||
squelch.store(false);
|
||||
muted.store(false);
|
||||
tracking.store(false);
|
||||
follow.store(false);
|
||||
deltaLock.store(false);
|
||||
deltaLockOfs.store(0);
|
||||
currentOutputDevice.store(-1);
|
||||
currentAudioGain.store(1.0);
|
||||
follow.store(false);
|
||||
tracking.store(false);
|
||||
|
||||
label = new std::string("Unnamed");
|
||||
pipeIQInputData = new DemodulatorThreadInputQueue;
|
||||
@ -89,7 +91,7 @@ void DemodulatorInstance::run() {
|
||||
pthread_create(&t_Demod, &attr, &DemodulatorThread::pthread_helper, demodulatorThread);
|
||||
pthread_attr_destroy(&attr);
|
||||
|
||||
std::cout << "Initialized demodulator stack size of " << size << std::endl;
|
||||
// std::cout << "Initialized demodulator stack size of " << size << std::endl;
|
||||
|
||||
#else
|
||||
t_PreDemod = new std::thread(&DemodulatorPreThread::threadMain, demodulatorPreThread);
|
||||
@ -109,11 +111,11 @@ void DemodulatorInstance::updateLabel(long long freq) {
|
||||
}
|
||||
|
||||
void DemodulatorInstance::terminate() {
|
||||
std::cout << "Terminating demodulator audio thread.." << std::endl;
|
||||
// std::cout << "Terminating demodulator audio thread.." << std::endl;
|
||||
audioThread->terminate();
|
||||
std::cout << "Terminating demodulator thread.." << std::endl;
|
||||
// std::cout << "Terminating demodulator thread.." << std::endl;
|
||||
demodulatorThread->terminate();
|
||||
std::cout << "Terminating demodulator preprocessor thread.." << std::endl;
|
||||
// std::cout << "Terminating demodulator preprocessor thread.." << std::endl;
|
||||
demodulatorPreThread->terminate();
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,7 @@ DemodulatorMgr::~DemodulatorMgr() {
|
||||
}
|
||||
|
||||
DemodulatorInstance *DemodulatorMgr::newThread() {
|
||||
garbageCollect();
|
||||
|
||||
demods_busy.lock();
|
||||
std::lock_guard < std::mutex > lock(demods_busy);
|
||||
DemodulatorInstance *newDemod = new DemodulatorInstance;
|
||||
|
||||
std::stringstream label;
|
||||
@ -41,25 +39,22 @@ DemodulatorInstance *DemodulatorMgr::newThread() {
|
||||
newDemod->setLabel(label.str());
|
||||
|
||||
demods.push_back(newDemod);
|
||||
demods_busy.unlock();
|
||||
|
||||
return newDemod;
|
||||
}
|
||||
|
||||
void DemodulatorMgr::terminateAll() {
|
||||
std::lock_guard < std::mutex > lock(demods_busy);
|
||||
while (demods.size()) {
|
||||
demods_busy.lock();
|
||||
DemodulatorInstance *d = demods.back();
|
||||
demods.pop_back();
|
||||
demods_busy.unlock();
|
||||
wxGetApp().removeDemodulator(d);
|
||||
deleteThread(d);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<DemodulatorInstance *> &DemodulatorMgr::getDemodulators() {
|
||||
demods_busy.lock();
|
||||
demods_busy.unlock();
|
||||
std::lock_guard < std::mutex > lock(demods_busy);
|
||||
return demods;
|
||||
}
|
||||
|
||||
@ -127,8 +122,6 @@ DemodulatorInstance *DemodulatorMgr::getFirstDemodulator() {
|
||||
}
|
||||
|
||||
void DemodulatorMgr::deleteThread(DemodulatorInstance *demod) {
|
||||
demods_busy.lock();
|
||||
|
||||
std::vector<DemodulatorInstance *>::iterator i;
|
||||
|
||||
i = std::find(demods.begin(), demods.end(), demod);
|
||||
@ -149,14 +142,10 @@ void DemodulatorMgr::deleteThread(DemodulatorInstance *demod) {
|
||||
demod->terminate();
|
||||
|
||||
demods_deleted.push_back(demod);
|
||||
|
||||
demods_busy.unlock();
|
||||
|
||||
garbageCollect();
|
||||
}
|
||||
|
||||
std::vector<DemodulatorInstance *> *DemodulatorMgr::getDemodulatorsAt(long long freq, int bandwidth) {
|
||||
demods_busy.lock();
|
||||
std::lock_guard < std::mutex > lock(demods_busy);
|
||||
std::vector<DemodulatorInstance *> *foundDemods = new std::vector<DemodulatorInstance *>();
|
||||
|
||||
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
|
||||
@ -172,13 +161,12 @@ std::vector<DemodulatorInstance *> *DemodulatorMgr::getDemodulatorsAt(long long
|
||||
foundDemods->push_back(testDemod);
|
||||
}
|
||||
}
|
||||
demods_busy.unlock();
|
||||
|
||||
return foundDemods;
|
||||
}
|
||||
|
||||
bool DemodulatorMgr::anyDemodulatorsAt(long long freq, int bandwidth) {
|
||||
demods_busy.lock();
|
||||
std::lock_guard < std::mutex > lock(demods_busy);
|
||||
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
|
||||
DemodulatorInstance *testDemod = demods[i];
|
||||
|
||||
@ -189,12 +177,10 @@ bool DemodulatorMgr::anyDemodulatorsAt(long long freq, int bandwidth) {
|
||||
long long halfBuffer = bandwidth / 2;
|
||||
|
||||
if ((freq <= (freqTest + ((testDemod->getDemodulatorType() != "LSB")?halfBandwidthTest:0) + halfBuffer)) && (freq >= (freqTest - ((testDemod->getDemodulatorType() != "USB")?halfBandwidthTest:0) - halfBuffer))) {
|
||||
demods_busy.unlock();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
demods_busy.unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -213,6 +199,8 @@ void DemodulatorMgr::setActiveDemodulator(DemodulatorInstance *demod, bool tempo
|
||||
wxGetApp().getRigThread()->setFrequency(lastActiveDemodulator->getFrequency(),true);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
garbageCollect();
|
||||
}
|
||||
|
||||
if (activeVisualDemodulator) {
|
||||
@ -230,8 +218,6 @@ void DemodulatorMgr::setActiveDemodulator(DemodulatorInstance *demod, bool tempo
|
||||
}
|
||||
|
||||
activeDemodulator = demod;
|
||||
|
||||
// garbageCollect();
|
||||
}
|
||||
|
||||
DemodulatorInstance *DemodulatorMgr::getActiveDemodulator() {
|
||||
@ -246,8 +232,8 @@ DemodulatorInstance *DemodulatorMgr::getLastActiveDemodulator() {
|
||||
}
|
||||
|
||||
void DemodulatorMgr::garbageCollect() {
|
||||
std::lock_guard < std::mutex > lock(demods_busy);
|
||||
if (demods_deleted.size()) {
|
||||
demods_busy.lock();
|
||||
std::vector<DemodulatorInstance *>::iterator i;
|
||||
|
||||
for (i = demods_deleted.begin(); i != demods_deleted.end(); i++) {
|
||||
@ -259,11 +245,9 @@ void DemodulatorMgr::garbageCollect() {
|
||||
|
||||
delete deleted;
|
||||
|
||||
demods_busy.unlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
demods_busy.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ void DemodulatorPreThread::run() {
|
||||
pthread_setschedparam(tID, SCHED_FIFO, &prio);
|
||||
#endif
|
||||
|
||||
std::cout << "Demodulator preprocessor thread started.." << std::endl;
|
||||
// std::cout << "Demodulator preprocessor thread started.." << std::endl;
|
||||
|
||||
ReBuffer<DemodulatorThreadPostIQData> buffers("DemodulatorPreThreadBuffers");
|
||||
|
||||
@ -276,7 +276,7 @@ void DemodulatorPreThread::run() {
|
||||
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_PREPROCESS_TERMINATED);
|
||||
tCmd.context = this;
|
||||
threadQueueNotify->push(tCmd);
|
||||
std::cout << "Demodulator preprocessor thread done." << std::endl;
|
||||
// std::cout << "Demodulator preprocessor thread done." << std::endl;
|
||||
}
|
||||
|
||||
void DemodulatorPreThread::setDemodType(std::string demodType) {
|
||||
|
@ -23,7 +23,6 @@ DemodulatorThread::DemodulatorThread(DemodulatorInstance *parent)
|
||||
}
|
||||
|
||||
DemodulatorThread::~DemodulatorThread() {
|
||||
|
||||
}
|
||||
|
||||
void DemodulatorThread::onBindOutput(std::string name, ThreadQueueBase *threadQueue) {
|
||||
@ -65,9 +64,7 @@ void DemodulatorThread::run() {
|
||||
pthread_setschedparam(tID, SCHED_FIFO, &prio);
|
||||
#endif
|
||||
|
||||
ReBuffer<AudioThreadInput> audioVisBuffers("DemodulatorThreadAudioBuffers");
|
||||
|
||||
std::cout << "Demodulator thread started.." << std::endl;
|
||||
// std::cout << "Demodulator thread started.." << std::endl;
|
||||
|
||||
iqInputQueue = static_cast<DemodulatorThreadPostInputQueue*>(getInputQueue("IQDataInput"));
|
||||
audioOutputQueue = static_cast<AudioThreadInputQueue*>(getOutputQueue("AudioDataOutput"));
|
||||
@ -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,17 +281,16 @@ 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;
|
||||
threadQueueNotify->push(tCmd);
|
||||
|
||||
std::cout << "Demodulator thread done." << std::endl;
|
||||
// std::cout << "Demodulator thread done." << std::endl;
|
||||
}
|
||||
|
||||
void DemodulatorThread::terminate() {
|
||||
|
@ -12,7 +12,7 @@ DemodulatorWorkerThread::~DemodulatorWorkerThread() {
|
||||
|
||||
void DemodulatorWorkerThread::run() {
|
||||
|
||||
std::cout << "Demodulator worker thread started.." << std::endl;
|
||||
// std::cout << "Demodulator worker thread started.." << std::endl;
|
||||
|
||||
commandQueue = static_cast<DemodulatorThreadWorkerCommandQueue *>(getInputQueue("WorkerCommandQueue"));
|
||||
resultQueue = static_cast<DemodulatorThreadWorkerResultQueue *>(getOutputQueue("WorkerResultQueue"));
|
||||
@ -99,7 +99,7 @@ void DemodulatorWorkerThread::run() {
|
||||
|
||||
}
|
||||
|
||||
std::cout << "Demodulator worker thread done." << std::endl;
|
||||
// std::cout << "Demodulator worker thread done." << std::endl;
|
||||
}
|
||||
|
||||
void DemodulatorWorkerThread::terminate() {
|
||||
|
@ -35,7 +35,7 @@ void FFTVisualDataThread::run() {
|
||||
wproc.attachOutput(pipeFFTDataOut);
|
||||
wproc.setup(DEFAULT_FFT_SIZE);
|
||||
|
||||
std::cout << "FFT visual data thread started." << std::endl;
|
||||
// std::cout << "FFT visual data thread started." << std::endl;
|
||||
|
||||
while(!terminated) {
|
||||
|
||||
@ -63,6 +63,6 @@ void FFTVisualDataThread::run() {
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "FFT visual data thread done." << std::endl;
|
||||
// std::cout << "FFT visual data thread done." << std::endl;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ SpectrumVisualProcessor *SpectrumVisualDataThread::getProcessor() {
|
||||
}
|
||||
|
||||
void SpectrumVisualDataThread::run() {
|
||||
std::cout << "Spectrum visual data thread started." << std::endl;
|
||||
// std::cout << "Spectrum visual data thread started." << std::endl;
|
||||
|
||||
while(!terminated) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
@ -21,6 +21,6 @@ void SpectrumVisualDataThread::run() {
|
||||
sproc.run();
|
||||
}
|
||||
|
||||
std::cout << "Spectrum visual data thread done." << std::endl;
|
||||
// std::cout << "Spectrum visual data thread done." << std::endl;
|
||||
}
|
||||
|
||||
|
@ -27,22 +27,20 @@ SDRPostThread::~SDRPostThread() {
|
||||
}
|
||||
|
||||
void SDRPostThread::bindDemodulator(DemodulatorInstance *demod) {
|
||||
busy_demod.lock();
|
||||
std::lock_guard < std::mutex > lock(busy_demod);
|
||||
demodulators.push_back(demod);
|
||||
doRefresh.store(true);
|
||||
busy_demod.unlock();
|
||||
}
|
||||
|
||||
void SDRPostThread::bindDemodulators(std::vector<DemodulatorInstance *> *demods) {
|
||||
if (!demods) {
|
||||
return;
|
||||
}
|
||||
busy_demod.lock();
|
||||
std::lock_guard < std::mutex > lock(busy_demod);
|
||||
for (std::vector<DemodulatorInstance *>::iterator di = demods->begin(); di != demods->end(); di++) {
|
||||
demodulators.push_back(*di);
|
||||
doRefresh.store(true);
|
||||
}
|
||||
busy_demod.unlock();
|
||||
}
|
||||
|
||||
void SDRPostThread::removeDemodulator(DemodulatorInstance *demod) {
|
||||
@ -50,14 +48,13 @@ void SDRPostThread::removeDemodulator(DemodulatorInstance *demod) {
|
||||
return;
|
||||
}
|
||||
|
||||
busy_demod.lock();
|
||||
std::lock_guard < std::mutex > lock(busy_demod);
|
||||
std::vector<DemodulatorInstance *>::iterator i = std::find(demodulators.begin(), demodulators.end(), demod);
|
||||
|
||||
if (i != demodulators.end()) {
|
||||
demodulators.erase(i);
|
||||
doRefresh.store(true);
|
||||
}
|
||||
busy_demod.unlock();
|
||||
}
|
||||
|
||||
void SDRPostThread::initPFBChannelizer() {
|
||||
@ -171,7 +168,7 @@ void SDRPostThread::run() {
|
||||
pthread_setschedparam(tID, SCHED_FIFO, &prio);
|
||||
#endif
|
||||
|
||||
std::cout << "SDR post-processing thread started.." << std::endl;
|
||||
// std::cout << "SDR post-processing thread started.." << std::endl;
|
||||
|
||||
iqDataInQueue = static_cast<SDRThreadIQDataQueue*>(getInputQueue("IQDataInput"));
|
||||
iqDataOutQueue = static_cast<DemodulatorThreadInputQueue*>(getOutputQueue("IQDataOutput"));
|
||||
@ -186,7 +183,7 @@ void SDRPostThread::run() {
|
||||
iqDataInQueue->pop(data_in);
|
||||
// std::lock_guard < std::mutex > lock(data_in->m_mutex);
|
||||
|
||||
busy_demod.lock();
|
||||
std::lock_guard < std::mutex > lock(busy_demod);
|
||||
|
||||
if (data_in && data_in->data.size()) {
|
||||
if(data_in->numChannels > 1) {
|
||||
@ -211,8 +208,6 @@ void SDRPostThread::run() {
|
||||
if (doUpdate) {
|
||||
updateActiveDemodulators();
|
||||
}
|
||||
|
||||
busy_demod.unlock();
|
||||
}
|
||||
|
||||
if (iqVisualQueue && !iqVisualQueue->empty()) {
|
||||
@ -223,7 +218,7 @@ void SDRPostThread::run() {
|
||||
// buffers.purge();
|
||||
// visualDataBuffers.purge();
|
||||
|
||||
std::cout << "SDR post-processing thread done." << std::endl;
|
||||
// std::cout << "SDR post-processing thread done." << std::endl;
|
||||
}
|
||||
|
||||
void SDRPostThread::terminate() {
|
||||
|
Loading…
Reference in New Issue
Block a user