OTA: quiet the audio sources during a firmware upload

An upload during an active Spotify session crawled (~10 kB/s, 197 s)
and ended in a reset (seen twice). Workaround:
- aes67_ota_on_update(cb): cb(true) right before an accepted upload
  writes flash, cb(false) if it then fails.
- The player pauses Spotify (spotify_pause -> SpircHandler::setPause, the
  app follows) and suspends HLS fetching (hls_suspend); resumed if the
  upload fails. AES67 TX keeps running (silence).
- Verified: upload during Spotify playback paused the session and
  installed in 25.8 s (normal for 2 MB), clean reboot and self-test.
  Root cause still open (noted in CLAUDE.md with the other cspot items).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 19:02:03 +10:00
parent cd747aec40
commit 8ba4de5eda
8 changed files with 90 additions and 2 deletions
+10 -1
View File
@@ -36,6 +36,12 @@ static media_pl_t *s_pl; // parsed media playlist (PSRAM)
static char s_url[URL_MAX]; // configured URL
static char s_media_url[URL_MAX];
static uint8_t *s_seg; // current segment (PSRAM)
static volatile bool s_suspended;
void hls_suspend(bool suspend)
{
s_suspended = suspend;
}
// hls_url when source.mode needs HLS, else "".
static void wanted_url(char *out, size_t n)
@@ -50,6 +56,9 @@ static void wanted_url(char *out, size_t n)
static bool still_wanted(void)
{
if (s_suspended) {
return false;
}
char u[URL_MAX];
wanted_url(u, sizeof(u));
return strcmp(u, s_url) == 0;
@@ -237,7 +246,7 @@ static void hls_task(void *arg)
{
while (1) {
wanted_url(s_url, sizeof(s_url));
if (!s_url[0]) {
if (!s_url[0] || s_suspended) {
vTaskDelay(pdMS_TO_TICKS(1000));
continue;
}
+2
View File
@@ -11,3 +11,5 @@
typedef bool (*hls_sink_t)(const uint8_t *data, size_t len, bool segment_start);
esp_err_t hls_start(hls_sink_t sink);
// Stop fetching (current download is abandoned) until resumed.
void hls_suspend(bool suspend);
+21
View File
@@ -4,6 +4,7 @@
#include <string.h>
#include "aes67_cfg.h"
#include "aes67_ota.h"
#include "aes67_tx.h"
#include "aes67_web.h"
#include "audio_out.h"
@@ -156,6 +157,25 @@ static void spotify_event(spotify_event_t ev, int value)
}
}
// Firmware upload: flash writes stall everything running from PSRAM; a Spotify session
// streaming at the same time made uploads crawl and end in a reset. Quiet the sources meanwhile.
static void on_ota(bool starting)
{
static bool paused_spotify;
if (starting) {
paused_spotify = s_src == PLAYER_SRC_SPOTIFY && !s_paused;
spotify_pause(true);
hls_suspend(true);
ESP_LOGI(TAG, "firmware update: sources paused");
} else {
hls_suspend(false);
if (paused_spotify) {
spotify_pause(false);
}
ESP_LOGI(TAG, "firmware update failed: sources resumed");
}
}
static void player_status(cJSON *st)
{
const char *state = s_src == PLAYER_SRC_TONE ? "playing" : s_src == PLAYER_SRC_OFF ? "idle" :
@@ -186,6 +206,7 @@ esp_err_t player_init(void)
return ESP_ERR_NO_MEM;
}
spotify_init(spotify_pcm, spotify_event);
aes67_ota_on_update(on_ota);
err = hls_start(decoder_feed);
if (err != ESP_OK) {
return err;