|
TB2026-YDS Firmware
|
Audio file decoder: turns an MP3 or WAV file into interleaved PCM frames. More...
#include "esp_err.h"#include <stdint.h>#include <stddef.h>Go to the source code of this file.
Data Structures | |
| struct | decoder_format_t |
| PCM format of the open stream, read once after decoder_open(). More... | |
Macros | |
| #define | DECODER_READ_BUF_BYTES (2304 * 4) |
| Largest number of PCM bytes a single decoder_read() can emit. | |
Functions | |
| esp_err_t | decoder_open (const char *path) |
| Open an audio file, pick the backend, and read its format. | |
| esp_err_t | decoder_format (decoder_format_t *fmt) |
| Get the PCM format of the open stream. | |
| esp_err_t | decoder_read (void *pcm, size_t cap_bytes, size_t *got_bytes) |
Decode the next chunk of audio into pcm. | |
| esp_err_t | decoder_close (void) |
| Close the stream and free the decoder. Safe to call when nothing is open. | |
Audio file decoder: turns an MP3 or WAV file into interleaved PCM frames.
The mirror image of Audio sink interface on the input side. The public API is a concrete facade: decoder_open() auto-detects the format (by extension, confirmed by the file's magic bytes) and routes to the matching backend (libhelix MP3 or raw WAV). The caller never sees which backend is active; it just reads PCM until end of file.
Output layout is always 32-bit MSB-justified words (4 bytes per sample), ready to hand straight to sink->write(): 16-bit sources sit in the high 16 bits, 24-bit sources in the high 24 bits. The format's bits field reports the source width only. Always interleaved stereo (mono sources are up-mixed L=R), so the wired sink's fixed stereo slots stay full.
One stream at a time: decoder_open() while a stream is already open returns an error.