race/init fix; skip audio output on digital

This commit is contained in:
Charles J. Cliffe 2015-11-19 00:11:34 -05:00
parent dfd7496175
commit 86270b3300
3 changed files with 13 additions and 10 deletions

View File

@ -73,7 +73,6 @@ void DemodulatorInstance::run() {
// } // }
currentFrequency = demodulatorPreThread->getParams().frequency; currentFrequency = demodulatorPreThread->getParams().frequency;
currentDemodType = demodulatorPreThread->getParams().demodType;
currentAudioSampleRate = AudioThread::deviceSampleRate[getOutputDevice()]; currentAudioSampleRate = AudioThread::deviceSampleRate[getOutputDevice()];
demodulatorPreThread->getParams().audioSampleRate = currentAudioSampleRate; demodulatorPreThread->getParams().audioSampleRate = currentAudioSampleRate;
@ -101,6 +100,8 @@ void DemodulatorInstance::run() {
t_PreDemod = new std::thread(&DemodulatorPreThread::threadMain, demodulatorPreThread); t_PreDemod = new std::thread(&DemodulatorPreThread::threadMain, demodulatorPreThread);
t_Demod = new std::thread(&DemodulatorThread::threadMain, demodulatorThread); t_Demod = new std::thread(&DemodulatorThread::threadMain, demodulatorThread);
#endif #endif
setDemodulatorType(demodulatorPreThread->getParams().demodType);
active = true; active = true;
audioTerminated = demodTerminated = preDemodTerminated = terminated = false; audioTerminated = demodTerminated = preDemodTerminated = terminated = false;
@ -285,9 +286,9 @@ void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
} }
setGain(getGain()); setGain(getGain());
demodulatorPreThread->getParams().demodType = currentDemodType;
if (!active) { if (!active) {
checkBandwidth(); checkBandwidth();
demodulatorPreThread->getParams().demodType = currentDemodType;
} else if (demodulatorThread && threadQueueControl) { } else if (demodulatorThread && threadQueueControl) {
demodulatorPreThread->setDemodType(currentDemodType); demodulatorPreThread->setDemodType(currentDemodType);
} }

View File

@ -52,8 +52,6 @@ void DemodulatorPreThread::run() {
std::cout << "Demodulator preprocessor thread started.." << std::endl; std::cout << "Demodulator preprocessor thread started.." << std::endl;
t_Worker = new std::thread(&DemodulatorWorkerThread::threadMain, workerThread);
ReBuffer<DemodulatorThreadPostIQData> buffers; ReBuffer<DemodulatorThreadPostIQData> buffers;
iqInputQueue = (DemodulatorThreadInputQueue*)getInputQueue("IQDataInput"); iqInputQueue = (DemodulatorThreadInputQueue*)getInputQueue("IQDataInput");
@ -65,6 +63,7 @@ void DemodulatorPreThread::run() {
std::vector<liquid_float_complex> out_buf_data; std::vector<liquid_float_complex> out_buf_data;
setDemodType(params.demodType); setDemodType(params.demodType);
t_Worker = new std::thread(&DemodulatorWorkerThread::threadMain, workerThread);
while (!terminated) { while (!terminated) {
DemodulatorThreadIQData *inp; DemodulatorThreadIQData *inp;
@ -262,10 +261,11 @@ void DemodulatorPreThread::setDemodType(std::string demodType) {
command.bandwidth = params.bandwidth; command.bandwidth = params.bandwidth;
command.audioSampleRate = params.audioSampleRate; command.audioSampleRate = params.audioSampleRate;
workerQueue->push(command); workerQueue->push(command);
demodTypeChanged.store(true);
} }
std::string DemodulatorPreThread::getDemodType() { std::string DemodulatorPreThread::getDemodType() {
if (newDemodType != demodType) { if (demodTypeChanged.load()) {
return newDemodType; return newDemodType;
} }
return demodType; return demodType;

View File

@ -116,12 +116,14 @@ void DemodulatorThread::run() {
modemData.setRefCount(1); modemData.setRefCount(1);
AudioThreadInput *ati = NULL; AudioThreadInput *ati = NULL;
if (cModem->getType() != "digital") {
ati = outputBuffers.getBuffer(); ati = outputBuffers.getBuffer();
ati->sampleRate = audioSampleRate; ati->sampleRate = audioSampleRate;
ati->inputRate = inp->sampleRate; ati->inputRate = inp->sampleRate;
ati->setRefCount(1); ati->setRefCount(1);
}
cModem->demodulate(cModemKit, &modemData, ati); cModem->demodulate(cModemKit, &modemData, ati);
if (currentSignalLevel > signalLevel) { if (currentSignalLevel > signalLevel) {