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

View File

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

View File

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