diff --git a/main.cpp b/main.cpp index 7fa5fde..3c22add 100644 --- a/main.cpp +++ b/main.cpp @@ -97,6 +97,31 @@ static void poh_thread() } } +static std::atomic ls_accept_input; +static std::binary_semaphore ls_input_ready{0}; +static std::complex ls_input_block[block_len]; +static std::mutex wf_ls_mutex; +static unsigned int wf_ls[wf_width*wf_height]; + +static void ls_thread() +{ + std::vector block_mag(block_len); + + while(!shutdown_threads) { + ls_accept_input = true; + ls_input_ready.acquire(); + fft_mag(ls_input_block, block_mag.data(), block_len); + { + std::lock_guard guard(wf_ls_mutex); + std::memmove(&wf_ls[wf_width], &wf_ls[0], sizeof(int)*wf_width*(wf_height - 1)); + for(int i=0;i frames_processed; static std::atomic frames_dropped; @@ -107,15 +132,16 @@ static int brf_frames_dropped_cnt = 0; static void* brf_dispatch(struct bladerf* dev, struct bladerf_stream* stream, struct bladerf_metadata* meta, void* samples_v, size_t num_samples, void* user_data) { - if(poh_accept_input) { + if(poh_accept_input && ls_accept_input) { std::complex* samples = (std::complex*)samples_v; - for(size_t i=0;i guard(wf_poh_mutex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, wf_width, wf_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, wf_poh); + std::lock_guard guard(wf_ls_mutex); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, wf_width, wf_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, wf_ls); } }