From 753ae51dd524e6b7c0aed4ed5855bb23d6837cc0 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Thu, 18 Aug 2022 20:42:58 +0200 Subject: [PATCH] Stop & restart UDP on pause/update. --- usermods/audioreactive/audio_reactive.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/usermods/audioreactive/audio_reactive.h b/usermods/audioreactive/audio_reactive.h index 02b20def9..d33fd218f 100644 --- a/usermods/audioreactive/audio_reactive.h +++ b/usermods/audioreactive/audio_reactive.h @@ -1172,11 +1172,16 @@ class AudioReactive : public Usermod { if (init && FFT_Task) { vTaskSuspend(FFT_Task); // update is about to begin, disable task to prevent crash + if (udpSyncConnected) { // close UDP sync connection (if open) + udpSyncConnected = false; + fftUdp.stop(); + } } else { // update has failed or create task requested - if (FFT_Task) + if (FFT_Task) { vTaskResume(FFT_Task); - else + connected(); // resume UDP + } else // xTaskCreatePinnedToCore( xTaskCreate( // no need to "pin" this task to core #0 FFTcode, // Function to implement the task @@ -1184,11 +1189,11 @@ class AudioReactive : public Usermod { 5000, // Stack size in words NULL, // Task input parameter 1, // Priority of the task - &FFT_Task // Task handle + &FFT_Task // Task handle // , 0 // Core where the task should run ); } - micDataReal = 0.0f; // just to ber sure + micDataReal = 0.0f; // just to be sure if (enabled) disableSoundProcessing = false; }