From 90ca6ccf8b672d092ef166b16a92fd7a1901862b Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Sun, 23 Nov 2025 00:02:56 +0100 Subject: [PATCH] AR: handle stupid build flag SR_DMTYPE=-1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I don't know how the bad example "-D SR_DMTYPE=-1" made it into platformio_override.sample.ini 🫣 mic type -1 = 255 was never supported by AR, and lead to undefined behavior due to a missing "case" in setup(). Fixed. Its still a stupid build_flags option, but at least now its handled properly. --- usermods/audioreactive/audio_reactive.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/usermods/audioreactive/audio_reactive.cpp b/usermods/audioreactive/audio_reactive.cpp index b4151725..fe73231b 100644 --- a/usermods/audioreactive/audio_reactive.cpp +++ b/usermods/audioreactive/audio_reactive.cpp @@ -1227,7 +1227,6 @@ class AudioReactive : public Usermod { #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) // ADC over I2S is only possible on "classic" ESP32 case 0: - default: DEBUGSR_PRINTLN(F("AR: Analog Microphone (left channel only).")); audioSource = new I2SAdcSource(SAMPLE_RATE, BLOCK_SIZE); delay(100); @@ -1235,6 +1234,13 @@ class AudioReactive : public Usermod { if (audioSource) audioSource->initialize(audioPin); break; #endif + + case 255: // 255 = -1 = no audio source + // falls through to default + default: + if (audioSource) delete audioSource; audioSource = nullptr; + enabled = false; + break; } delay(250); // give microphone enough time to initialise