Repository navigation
v3.3.0 — station logos, a sleep timer, and 59 KB that were being wasted
Station logos, a sleep timer, and 59 KB that were being wasted
The radio now shows the station's logo. That sounds like decoration, and it
started as one — but it only became possible after something else was fixed, and
that fix is the real content of this release.
SBR was being compiled into the AAC decoder and never used. SBR is the “+”
in AAC+; this device has played the base layer only since day one, because SBR's
own state wants another 50 KB that do not exist here. Compiling it in anyway
cost 59 KB of decoder workspace for nothing. Measured with the device's own
toolchain: 89,428 bytes with it, 26,352 without.
Taking it out changed the machine underneath. During playback there are now
72 to 104 KB of free heap with 59 to 78 KB in one contiguous piece, where it
used to be 20 to 30 KB free and 8 to 18 KB in one piece. That is what pays for
the PNG decoder, the TLS connection that fetches a logo, and the room to keep it
on the SD card.
It needs a one-time patch to the audio library — three lines in two files plus
one condition in a third. It is in library-patch/, and the sketch refuses to
compile without it, so you cannot get it wrong quietly.
What else is new
- Station logos. Fetched once, kept in
/logoson the card, shown on the
new info screen. Fetching happens while the sound is off — the one moment the
heap is clean. - An info screen.
Fpast the spectrum analyzer: codec, bitrate, sample
rate, channels, buffer fill, largest free block, and the host the audio really
comes from — the resolved one, not the one in your list. - A sleep timer. Sleeptime in the menu,
HH:MMup to twelve hours, digit
by digit. The remaining time counts down in the footer in yellow; at zero the
stream stops and the screen goes dark. Any key wakes it, restores the
brightness and reconnects. - Playlists are resolved instead of refused.
.plsand plain.m3ucarry
the real stream address, so the radio reads it and connects. HLS keeps its own
message — a segment list has no stream address in it to find. - https stations play, by rewriting the address to
httpand trying. Of the
80 most-clicked German stations the directory files as https, 80 of 80
serve the same audio over plain http.
Fixed
- Wi-Fi failed for some users under M5Launcher. Three reports, same cause:
M5Launcher up to 2.8.0 lays out a smaller shared NVS area than usual
(0x4000instead of0x5000), and the Wi-Fi driver writes its configuration
there while connecting. The radio now callsWiFi.persistent(false)before
its first Wi-Fi call — the driver keeps its configuration in RAM and never
touches that area. Credentials are ours to store, and we store them ourselves. - A sixth failure message, for the case where the Wi-Fi driver refuses to
start at all. It used to wait 15 seconds and then blame the network. - Stations whose address redirects to https did not play. Reported for NTS
Radio: a plain-http request is answered with a redirect to an https host,
which redirects again to a plain-http node that serves the audio. The address
was never the problem, the redirect was. Those are now rewritten and followed. - The first play of a new station could show a false
https not work, with
a short break in the sound a few seconds later. The stream watchdog's
five-second clock was started before the logo was fetched, so a slow logo
download used up the budget meant for connecting. The clock now starts after
the logo is in. - Quoted playlist entries (
File1="http://…") were rejected. Found by
testing real stations, not by reading code.
Still not there: real https
The radio does not speak TLS for audio, and this release does not change
that. It side-steps it, and where a station truly insists on TLS it stays
unplayable.
It is worth saying why, because the memory situation did improve and the
obvious next thought is “so do TLS now”. An open TLS connection costs roughly
36 to 40 KB permanently, with a peak near 50 KB during the handshake. The logo
fetch already uses TLS out of the same pot — that is why it refuses to start
below 56 KB in one contiguous block — and the PNG decoder behind it needs 32,768
bytes in one piece. The audio pre-buffer, the decoder workspace and the I2S DMA
buffers are reserved statically on purpose, so they cannot depend on what the
heap happens to look like. Add a permanent 40 KB for a stream connection and the
largest free block drops below what the rest needs: the stream would play while
everything around it began failing quietly.
On top of that the audio library opens its own HTTP client internally and does
not accept a TLS one, so it would take a second library patch.
So it stays on the list. If real TLS streaming lands, it will be because those
numbers were measured again and worked out — not because it sounded achievable.
Size
Sketch: 2,919,043 bytes (92% of 3,145,728)
Global variables: 102,164 bytes (31% of 327,680)
Global variables are down 59 KB against 3.2.0 — that is the SBR workspace.
The M5Launcher gives an application 2880 KB and this build is 2851 KB, so there
are 29 KB left. Anything added from here has to fit in that.
Thanks
To everyone in r/CardPuter who reported
something instead of shrugging. Four of the five fixes above came from there.