|
TB2026-YDS Firmware
|
Enumerate the SD card's playable tracks and serve them by index. More...

Macros | |
| #define | STORAGE_MAX_TRACKS 512 |
| Largest number of tracks held in the in-memory index. Overflow fails loud. | |
| #define | STORAGE_PATH_MAX 320 |
| Size of one stored path buffer: "/sdcard/" + FATFS LFN (255) + nul, rounded up. | |
Functions | |
| esp_err_t | storage_init (void) |
| Mount the SD card and scan its root for playable tracks. | |
| esp_err_t | storage_rescan (void) |
| Re-scan the (already mounted) card root, rebuilding the track index. | |
| esp_err_t | storage_unmount (void) |
| Unmount the card and invalidate the index, after a card removal. | |
| bool | storage_ready (void) |
| Whether the card is mounted and a scan has completed. | |
| size_t | storage_count (void) |
| Number of tracks in the index (0 before any successful scan). | |
| esp_err_t | storage_get_usage (uint64_t *total_bytes, uint64_t *used_bytes) |
| Total and used size of the mounted FAT volume, in bytes. | |
| const char * | storage_track_path (size_t index) |
| Full POSIX path of a track, ready for decoder_open(). | |
| const char * | storage_track_name (size_t index) |
| Display name of a track (file name, no directory prefix). | |
| esp_err_t | storage_scan_dir (const char *root) |
| Scan an arbitrary directory for playable tracks, rebuilding the index. | |
| esp_err_t | storage_deinit (void) |
| Unmount the card and free the index. | |
Enumerate the SD card's playable tracks and serve them by index.
| #define STORAGE_MAX_TRACKS 512 |
Largest number of tracks held in the in-memory index. Overflow fails loud.
| #define STORAGE_PATH_MAX 320 |
Size of one stored path buffer: "/sdcard/" + FATFS LFN (255) + nul, rounded up.
| size_t storage_count | ( | void | ) |
Number of tracks in the index (0 before any successful scan).
| esp_err_t storage_deinit | ( | void | ) |
Unmount the card and free the index.
| esp_err_t storage_get_usage | ( | uint64_t * | total_bytes, |
| uint64_t * | used_bytes ) |
Total and used size of the mounted FAT volume, in bytes.
Thin wrapper over esp_vfs_fat_info(): a full scan of the FAT, so call it from a non-time-critical context (the stats page), not the audio path.
| [out] | total_bytes | Volume capacity in bytes (ignored if NULL). |
| [out] | used_bytes | Bytes in use = total - free (ignored if NULL). |
| esp_err_t storage_init | ( | void | ) |
Mount the SD card and scan its root for playable tracks.
Checks card presence, mounts the FAT volume via sdcard_mount, then scans SDCARD_MOUNT_POINT. Idempotent: a second call while already ready is a no-op.
| bool storage_ready | ( | void | ) |
Whether the card is mounted and a scan has completed.
| esp_err_t storage_rescan | ( | void | ) |
Re-scan the (already mounted) card root, rebuilding the track index.
Use after a card is (re)inserted and remounted. Requires the volume to be mounted.
| esp_err_t storage_scan_dir | ( | const char * | root | ) |
Scan an arbitrary directory for playable tracks, rebuilding the index.
The pure enumeration core: recursive opendir/readdir walk + extension filter + sort, parameterised by directory. storage_init and storage_rescan wrap it onto SDCARD_MOUNT_POINT; the host tests call it on a temporary folder, so the logic is exercised without hardware.
| root | Directory to scan (no trailing slash), e.g. "/sdcard". |
root cannot be opened; ESP_ERR_NO_MEM on allocation failure or more than STORAGE_MAX_TRACKS tracks. | const char * storage_track_name | ( | size_t | index | ) |
Display name of a track (file name, no directory prefix).
| index | 0-based track index. |
index is out of range. | const char * storage_track_path | ( | size_t | index | ) |
Full POSIX path of a track, ready for decoder_open().
| index | 0-based track index. |
index is out of range. | esp_err_t storage_unmount | ( | void | ) |
Unmount the card and invalidate the index, after a card removal.
Unlike storage_deinit it keeps the PSRAM index buffer allocated, ready for the storage_init() that follows a re-insertion. No-op if not mounted.