From 38b1393c44e246e5d83c1b3049debb1dc62865a2 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 1 Dec 2014 01:14:32 -0500 Subject: [PATCH] Worker results.. --- src/demod/DemodulatorThread.cpp | 50 ++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/src/demod/DemodulatorThread.cpp b/src/demod/DemodulatorThread.cpp index e1d1160..1fd4d92 100644 --- a/src/demod/DemodulatorThread.cpp +++ b/src/demod/DemodulatorThread.cpp @@ -113,21 +113,51 @@ void DemodulatorThread::threadMain() { } if (bandwidthChanged) { -// DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS); -// command.audioSampleRate = bandwidthParams.audioSampleRate; -// command.bandwidth = bandwidthParams.bandwidth; -// command.frequency = bandwidthParams.frequency; -// command.inputRate = bandwidthParams.inputRate; + std::cout << "Requesting new filters from worker.." << std::endl; + DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS); + command.audioSampleRate = bandwidthParams.audioSampleRate; + command.bandwidth = bandwidthParams.bandwidth; + command.frequency = bandwidthParams.frequency; + command.inputRate = bandwidthParams.inputRate; // -// workerQueue->push(command); + workerQueue->push(command); - initialize(); - while (!inputQueue->empty()) { // catch up - inputQueue->pop(inp); - } +// params = bandwidthParams; +// initialize(); +// while (!inputQueue->empty()) { // catch up +// inputQueue->pop(inp); +// } } } + if (!workerResults->empty()) { + while (!workerResults->empty()) { + DemodulatorWorkerThreadResult result; + workerResults->pop(result); + + switch (result.cmd) { + case DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS: + std::cout << "New filters arrived from worker.." << std::endl; + firfilt_crcf_destroy(fir_filter); + msresamp_crcf_destroy(resampler); + msresamp_crcf_destroy(audio_resampler); + + fir_filter = result.fir_filter; + resampler = result.resampler; + audio_resampler = result.audio_resampler; + + resample_ratio = result.resample_ratio; + audio_resample_ratio = result.audio_resample_ratio; + + params.audioSampleRate = result.audioSampleRate; + params.bandwidth = result.bandwidth; + params.inputRate = result.inputRate; + + break; + } + } + } + if (!initialized) { continue; }