Demod worker now handles filter reconstruction
Reduces audio jittering and only generates the last queued filter to save redundant regeneration during dragging.
This commit is contained in:
parent
38b1393c44
commit
746eca8d3e
|
@ -113,48 +113,13 @@ void DemodulatorThread::threadMain() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bandwidthChanged) {
|
if (bandwidthChanged) {
|
||||||
std::cout << "Requesting new filters from worker.." << std::endl;
|
|
||||||
DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS);
|
DemodulatorWorkerThreadCommand command(DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS);
|
||||||
command.audioSampleRate = bandwidthParams.audioSampleRate;
|
command.audioSampleRate = bandwidthParams.audioSampleRate;
|
||||||
command.bandwidth = bandwidthParams.bandwidth;
|
command.bandwidth = bandwidthParams.bandwidth;
|
||||||
command.frequency = bandwidthParams.frequency;
|
command.frequency = bandwidthParams.frequency;
|
||||||
command.inputRate = bandwidthParams.inputRate;
|
command.inputRate = bandwidthParams.inputRate;
|
||||||
//
|
|
||||||
workerQueue->push(command);
|
workerQueue->push(command);
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +211,33 @@ void DemodulatorThread::threadMain() {
|
||||||
visOutQueue->push(ati);
|
visOutQueue->push(ati);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!workerResults->empty()) {
|
||||||
|
while (!workerResults->empty()) {
|
||||||
|
DemodulatorWorkerThreadResult result;
|
||||||
|
workerResults->pop(result);
|
||||||
|
|
||||||
|
switch (result.cmd) {
|
||||||
|
case DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS:
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Demodulator thread done." << std::endl;
|
std::cout << "Demodulator thread done." << std::endl;
|
||||||
|
|
|
@ -18,7 +18,6 @@ void DemodulatorWorkerThread::threadMain() {
|
||||||
bool filterChanged = false;
|
bool filterChanged = false;
|
||||||
DemodulatorWorkerThreadCommand filterCommand;
|
DemodulatorWorkerThreadCommand filterCommand;
|
||||||
DemodulatorWorkerThreadCommand command;
|
DemodulatorWorkerThreadCommand command;
|
||||||
DemodulatorWorkerThreadResult result;
|
|
||||||
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
while (!done) {
|
while (!done) {
|
||||||
|
@ -33,7 +32,7 @@ void DemodulatorWorkerThread::threadMain() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterChanged) {
|
if (filterChanged) {
|
||||||
result.cmd = DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS;
|
DemodulatorWorkerThreadResult result(DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS);
|
||||||
|
|
||||||
result.resample_ratio = (float) (filterCommand.bandwidth) / (float) filterCommand.inputRate;
|
result.resample_ratio = (float) (filterCommand.bandwidth) / (float) filterCommand.inputRate;
|
||||||
result.audio_resample_ratio = (float) (filterCommand.audioSampleRate) / (float) filterCommand.bandwidth;
|
result.audio_resample_ratio = (float) (filterCommand.audioSampleRate) / (float) filterCommand.bandwidth;
|
||||||
|
@ -58,10 +57,12 @@ void DemodulatorWorkerThread::threadMain() {
|
||||||
liquid_firdes_kaiser(h_len, fc, As, mu, h);
|
liquid_firdes_kaiser(h_len, fc, As, mu, h);
|
||||||
|
|
||||||
result.fir_filter = firfilt_crcf_create(h, h_len);
|
result.fir_filter = firfilt_crcf_create(h, h_len);
|
||||||
|
|
||||||
result.resampler = msresamp_crcf_create(result.resample_ratio, As);
|
result.resampler = msresamp_crcf_create(result.resample_ratio, As);
|
||||||
result.audio_resampler = msresamp_crcf_create(result.audio_resample_ratio, As);
|
result.audio_resampler = msresamp_crcf_create(result.audio_resample_ratio, As);
|
||||||
// msresamp_crcf_print(audio_resampler);
|
|
||||||
|
result.audioSampleRate = filterCommand.audioSampleRate;
|
||||||
|
result.bandwidth = filterCommand.bandwidth;
|
||||||
|
result.inputRate = filterCommand.inputRate;
|
||||||
|
|
||||||
resultQueue->push(result);
|
resultQueue->push(result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue