fix: increase HTTP server stack size to 16KB to prevent MP3 decode stack overflow and reset I2S controller on stop to eliminate static noise
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -516,7 +516,7 @@ bool WebServerService::startServer() {
|
||||
settings.webServerPort,
|
||||
"0.0.0.0",
|
||||
handlers,
|
||||
8192 // Stack size
|
||||
16384 // Stack size
|
||||
);
|
||||
|
||||
httpServer->start();
|
||||
|
||||
Reference in New Issue
Block a user