diff --git a/Tactility/Source/mcp/McpSystem.cpp b/Tactility/Source/mcp/McpSystem.cpp index 929f2bb3..1cbcb8d4 100644 --- a/Tactility/Source/mcp/McpSystem.cpp +++ b/Tactility/Source/mcp/McpSystem.cpp @@ -432,6 +432,16 @@ static bool begin_audio(McpSystemState& state, std::string& error) { return true; } +static void end_audio(McpSystemState& state) { + state.audioRunning = false; + state.audioBusy = false; + if (state.i2sDevice != nullptr) { + device_lock(state.i2sDevice); + i2s_controller_reset(state.i2sDevice); + device_unlock(state.i2sDevice); + } +} + static bool configure_i2s(McpSystemState& state, int sample_rate, int channels, std::string& error) { I2sConfig config = { .communication_format = I2S_FORMAT_STAND_I2S, @@ -662,8 +672,7 @@ bool playTone(int frequency, int durationMs, int volume, std::string& error) { } done: - state.audioRunning = false; - state.audioBusy = false; + end_audio(state); return success; } @@ -727,8 +736,7 @@ done: if (file != NULL) { fclose(file); } - state.audioRunning = false; - state.audioBusy = false; + end_audio(state); return success; } @@ -769,8 +777,7 @@ bool playWavMemory(const uint8_t* data, size_t size, int volume, std::string& er } done: - state.audioRunning = false; - state.audioBusy = false; + end_audio(state); return success; } @@ -836,8 +843,7 @@ done: if (file != NULL) { fclose(file); } - state.audioRunning = false; - state.audioBusy = false; + end_audio(state); return success; } @@ -970,8 +976,7 @@ bool playMp3Memory(const uint8_t* data, size_t size, int volume, std::string& er success = true; done: - state.audioRunning = false; - state.audioBusy = false; + end_audio(state); return success; } @@ -1084,8 +1089,7 @@ done: if (file != NULL) { fclose(file); } - state.audioRunning = false; - state.audioBusy = false; + end_audio(state); return success; } diff --git a/Tactility/Source/service/webserver/WebServerService.cpp b/Tactility/Source/service/webserver/WebServerService.cpp index a42a03ff..d3771d13 100644 --- a/Tactility/Source/service/webserver/WebServerService.cpp +++ b/Tactility/Source/service/webserver/WebServerService.cpp @@ -516,7 +516,7 @@ bool WebServerService::startServer() { settings.webServerPort, "0.0.0.0", handlers, - 8192 // Stack size + 16384 // Stack size ); httpServer->start();