48 kHz only: drop 96 kHz from the AES67 output
All sources (player, test signals) are 48 kHz; at 96 kHz Spotify and HLS played at the wrong speed. Validation, the page and the docs allow 48000 only, and a 96000 stored before is reset to 48000 at boot (stored values aren't re-validated, and the SDP would still have said 96 kHz). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/sockets.h"
|
||||
|
||||
#define AES67_RATE 48000 // the only sample rate (all sources are 48 kHz)
|
||||
#define MAX_FRAMES 192 // 4 ms at 48 kHz
|
||||
#define MAX_CH 2
|
||||
#define RTP_HDR 12
|
||||
@@ -56,7 +57,7 @@ static bool aes67_validate(const cJSON *g, char *err, size_t n)
|
||||
{
|
||||
static const char *const discovery[] = { "manual", "sap", NULL };
|
||||
static const char *const encodings[] = { "L16", "L24", NULL };
|
||||
static const double rates[] = { 48000, 96000 };
|
||||
static const double rates[] = { AES67_RATE }; // the sources (player, test signals) are 48 kHz
|
||||
static const double ptimes[] = { 0.125, 0.25, 0.333, 1, 4 };
|
||||
|
||||
bool ok = cfg_check_str(g, "name", 1, 63, err, n) &&
|
||||
@@ -67,7 +68,7 @@ static bool aes67_validate(const cJSON *g, char *err, size_t n)
|
||||
cfg_check_int(g, "dscp", 0, 63, err, n) &&
|
||||
cfg_check_int(g, "channels", 1, 2, err, n) &&
|
||||
cfg_check_enum(g, "encoding", encodings, err, n) &&
|
||||
cfg_check_num_in(g, "rate", rates, 2, err, n) &&
|
||||
cfg_check_num_in(g, "rate", rates, 1, err, n) &&
|
||||
cfg_check_num_in(g, "ptime", ptimes, 5, err, n) &&
|
||||
cfg_check_int(g, "pt", 96, 127, err, n) &&
|
||||
cfg_check_int(g, "ssrc", 0, 4294967295.0, err, n) &&
|
||||
@@ -168,8 +169,6 @@ static int64_t samples_to_ns(int64_t s, int rate)
|
||||
return (s / rate) * 1000000000LL + ((s % rate) * 1000000000LL + rate - 1) / rate;
|
||||
}
|
||||
|
||||
// 1 kHz tone, phase from the PTP sample index, so every sender's tone lines up.
|
||||
// One period is rate / 1000 samples (48 at 48 kHz, 96 at 96 kHz): precomputed table.
|
||||
// Pink noise: xorshift32 white noise through Paul Kellet's refined pink filter (within 0.05 dB
|
||||
// above 9 Hz). The scale gives -18 dBFS RMS (measured over 10 s; peaks about -6 dBFS).
|
||||
#define PINK_SCALE 0.0714f
|
||||
@@ -209,9 +208,11 @@ static void to_mono(int32_t *buf, int frames, bool sum)
|
||||
}
|
||||
}
|
||||
|
||||
// 1 kHz tone, phase from the PTP sample index, so every sender's tone lines up.
|
||||
// One period is rate / 1000 samples (48 at 48 kHz): precomputed table.
|
||||
static void tone(int32_t *buf, int frames, int channels, int rate, int64_t s0)
|
||||
{
|
||||
static int32_t table[96000 / TONE_HZ];
|
||||
static int32_t table[AES67_RATE / TONE_HZ];
|
||||
static int table_rate;
|
||||
int period = rate / TONE_HZ;
|
||||
if (table_rate != rate) {
|
||||
@@ -361,5 +362,13 @@ esp_err_t aes67_tx_init(void)
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
// Stored before 96 kHz was dropped: stored values aren't re-validated, so fix it here (SDP too).
|
||||
cJSON *a = cfg_get("aes67");
|
||||
double rate = cJSON_GetObjectItemCaseSensitive(a, "rate")->valuedouble;
|
||||
cJSON_Delete(a);
|
||||
if (rate != AES67_RATE) {
|
||||
ESP_LOGW(TAG, "stored sample rate %.0f not supported: using %d", rate, AES67_RATE);
|
||||
cfg_set_number("aes67", "rate", AES67_RATE, false);
|
||||
}
|
||||
return status_register(tx_status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user