Cleanup / finalize demod before initial testing

This commit is contained in:
Charles J. Cliffe 2015-11-17 21:49:02 -05:00
parent 62ca78141f
commit f53e228849
7 changed files with 23 additions and 20 deletions

View File

@ -44,7 +44,7 @@ DemodulatorInstance::DemodulatorInstance() :
audioThread->setInputQueue("AudioDataInput", pipeAudioData);
audioThread->setOutputQueue("NotifyQueue", pipeDemodNotify);
currentDemodType = demodulatorThread->getDemodulatorType();
currentDemodType = demodulatorPreThread->getParams().demodType;
currentDemodCons = demodulatorThread->getDemodulatorCons();
}
@ -74,7 +74,7 @@ void DemodulatorInstance::run() {
// }
currentFrequency = demodulatorPreThread->getParams().frequency;
currentDemodType = demodulatorThread->getDemodulatorType();
currentDemodType = demodulatorPreThread->getParams().demodType;
currentDemodCons = demodulatorThread->getDemodulatorCons();
currentAudioSampleRate = AudioThread::deviceSampleRate[getOutputDevice()];
demodulatorPreThread->getParams().audioSampleRate = currentAudioSampleRate;
@ -290,7 +290,6 @@ void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
if (!active) {
checkBandwidth();
demodulatorPreThread->getParams().demodType = currentDemodType;
demodulatorThread->setDemodulatorType(currentDemodType);
} else if (demodulatorThread && threadQueueControl) {
DemodulatorThreadControlCommand command;
command.cmd = DemodulatorThreadControlCommand::DEMOD_THREAD_CMD_CTL_TYPE;

View File

@ -182,6 +182,7 @@ void DemodulatorPreThread::run() {
resamp->setRefCount(1);
resamp->data.assign(resampledData.begin(), resampledData.begin() + numWritten);
resamp->modemType = demodType;
resamp->modem = cModem;
resamp->modemKit = cModemKit;
resamp->sampleRate = params.bandwidth;
@ -220,6 +221,11 @@ void DemodulatorPreThread::run() {
if (result.sampleRate) {
params.sampleRate = result.sampleRate;
}
if (result.modemType != "") {
demodType = result.modemType;
demodTypeChanged.store(false);
}
break;
default:
break;
@ -245,11 +251,16 @@ void DemodulatorPreThread::setParams(DemodulatorThreadParameters &params_in) {
}
void DemodulatorPreThread::setDemodType(std::string demodType) {
this->demodType = demodType;
demodTypeChanged.store(true);
this->newDemodType = demodType;
DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_MAKE_DEMOD);
command.demodType = demodType;
workerQueue->push(command);
}
std::string DemodulatorPreThread::getDemodType() {
if (newDemodType != demodType) {
return newDemodType;
}
return demodType;
}

View File

@ -47,6 +47,7 @@ protected:
std::atomic_bool initialized;
std::atomic_bool demodTypeChanged;
std::string demodType;
std::string newDemodType;
DemodulatorWorkerThread *workerThread;
std::thread *t_Worker;

View File

@ -15,7 +15,6 @@ DemodulatorThread::DemodulatorThread() : IOThread(), iqAutoGain(NULL), amOutputC
muted.store(false);
agcEnabled.store(false);
demodulatorType = "FM";
// advanced demodulators
@ -530,7 +529,7 @@ void DemodulatorThread::run() {
ati_vis->data.resize(stereoSize);
if (demodulatorType == "I/Q") {
if (inp->modemType == "I/Q") {
for (int i = 0; i < stereoSize / 2; i++) {
ati_vis->data[i] = agcData[i].real * 0.75;
ati_vis->data[i + stereoSize / 2] = agcData[i].imag * 0.75;
@ -656,14 +655,6 @@ float DemodulatorThread::getSquelchLevel() {
return squelchLevel;
}
void DemodulatorThread::setDemodulatorType(std::string demod_type_in) {
demodulatorType = demod_type_in;
}
std::string DemodulatorThread::getDemodulatorType() {
return demodulatorType;
}
void DemodulatorThread::setDemodulatorLock(bool demod_lock_in) {
demod_lock_in ? currentDemodLock = true : currentDemodLock = false;
}

View File

@ -31,9 +31,6 @@ public:
float getSignalLevel();
void setSquelchLevel(float signal_level_in);
float getSquelchLevel();
void setDemodulatorType(std::string demod_type_in);
std::string getDemodulatorType();
void setDemodulatorLock(bool demod_lock_in);
int getDemodulatorLock();
@ -137,7 +134,6 @@ protected:
std::atomic_bool muted;
std::atomic_bool agcEnabled;
std::string demodulatorType;
std::atomic_int demodulatorCons;
int audioSampleRate;

View File

@ -53,6 +53,7 @@ void DemodulatorWorkerThread::run() {
if (makeDemod) {
cModem = Modem::makeModem(filterCommand.demodType);
cModemType = filterCommand.demodType;
}
if (filterCommand.bandwidth && filterCommand.audioSampleRate) {
@ -71,6 +72,8 @@ void DemodulatorWorkerThread::run() {
result.sampleRate = filterCommand.sampleRate;
}
result.modemType = cModemType;
resultQueue->push(result);
}

View File

@ -16,7 +16,7 @@ public:
};
DemodulatorWorkerThreadResult() :
cmd(DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(nullptr), iqResampleRatio(0), sampleRate(0), bandwidth(0), modemKit(nullptr) {
cmd(DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(nullptr), iqResampleRatio(0), sampleRate(0), bandwidth(0), modemKit(nullptr), modemType("") {
}
@ -36,6 +36,7 @@ public:
unsigned int bandwidth;
Modem *modem;
ModemKit *modemKit;
std::string modemType;
};
class DemodulatorWorkerThreadCommand {
@ -90,4 +91,5 @@ protected:
DemodulatorThreadWorkerResultQueue *resultQueue;
Modem *cModem;
ModemKit *cModemKit;
std::string cModemType;
};