Stop & restart UDP on pause/update.

This commit is contained in:
Blaz Kristan 2022-08-18 20:42:58 +02:00
parent 3e494cc551
commit 753ae51dd5

View File

@ -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
@ -1188,7 +1193,7 @@ class AudioReactive : public Usermod {
// , 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;
}