d3897f3179
- main/audio_ring: SPSC ring of interleaved int32 frames in PSRAM (4 s at 48 kHz stereo), lock-free with acquire/release counters; the TX pull callback never blocks. - main/player: source selection from source.mode and the pull callback for aes67_tx. tone -> the core's PTP-phased 1 kHz tone; off -> silence; hls/spotify -> ring with 1 s prefill (silence while buffering is not an underrun; running dry is, and prefills again). Status fields active_source, source_state, spotify_state, buffer_ms. source config applies live. - New source.mode "tone" (validation, UI dropdown, doc) for commissioning. - Temporary 440 Hz producer in hls mode (until the HLS player exists). - Verified: tone 999.7 Hz -18 dBFS; off silent; hls 440.0 Hz with max sample step 60816 (ideal sine 60825, i.e. no discontinuities), buffer 3983 ms, 0 underruns; spotify silent/not implemented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
35 lines
1.3 KiB
C
35 lines
1.3 KiB
C
// Project config: defaults over the core groups and the "source" group.
|
|
#include "project_cfg.h"
|
|
|
|
#include "aes67_cfg.h"
|
|
#include "esp_err.h"
|
|
#include "player.h"
|
|
|
|
static const char SOURCE_DEFAULTS[] =
|
|
"{\"mode\":\"spotify\",\"spotify_name\":\"P4 AES67\",\"spotify_bitrate\":320,\"hls_url\":\"\","
|
|
"\"autoplay\":false,\"gain_db\":0,\"failover_delay_s\":5,\"failover_on_pause\":false}";
|
|
|
|
static bool source_validate(const cJSON *g, char *err, size_t n)
|
|
{
|
|
static const char *const modes[] = { "spotify", "hls", "auto", "tone", "off", NULL };
|
|
static const double bitrates[] = { 96, 160, 320 };
|
|
return cfg_check_enum(g, "mode", modes, err, n) &&
|
|
cfg_check_str(g, "spotify_name", 1, 63, err, n) &&
|
|
cfg_check_num_in(g, "spotify_bitrate", bitrates, 3, err, n) &&
|
|
cfg_check_str(g, "hls_url", 0, 255, err, n) &&
|
|
cfg_check_num(g, "gain_db", -60, 12, err, n) &&
|
|
cfg_check_int(g, "failover_delay_s", 0, 3600, err, n);
|
|
}
|
|
|
|
void project_cfg_defaults(void)
|
|
{
|
|
// Same as PROJECT.def in web/index.html.
|
|
ESP_ERROR_CHECK(cfg_override_defaults("aes67", "{\"name\":\"P4 AES67\"}"));
|
|
ESP_ERROR_CHECK(cfg_override_defaults("net", "{\"hostname\":\"p4-aes67\"}"));
|
|
}
|
|
|
|
void project_cfg_register(void)
|
|
{
|
|
ESP_ERROR_CHECK(cfg_register("source", SOURCE_DEFAULTS, source_validate, player_apply));
|
|
}
|