4# error("ZephyrSD only supported by zephyr")
7#include "AudioLogger.h"
13#include <zephyr/fs/fs.h>
16# define FS_MAX_PATH 256
35 const char *ext =
".mp3") {
74 LOGI(
"nextStream: %d", offset);
78 if (!s && offset > 0) {
79 LOGI(
"wrap to start");
96 int norm =
index % cnt;
97 if (norm < 0) norm += cnt;
101 const char *path =
get(norm);
103 LOGW(
"Invalid index: %d", norm);
107 LOGI(
"Playing: %s", path);
114 LOGI(
"selectStream(path): %s", path);
148 long size(
bool force_rescan =
false) {
199 if (!path)
return nullptr;
218 const char *
get(
int idx) {
230 if (fs_opendir(&dir, path) != 0) {
234 struct fs_dirent entry;
235 const char *result =
nullptr;
238 int rc = fs_readdir(&dir, &entry);
239 if (rc != 0 || entry.name[0] ==
'\0')
break;
243 if (snprintf(full,
sizeof(full),
244 "%s/%s", path, entry.name) >= (
int)
sizeof(full)) {
248 if (entry.type == FS_DIR_ENTRY_DIR) {
254 if (running == target) {
276 if (fs_opendir(&dir, path) != 0) {
280 struct fs_dirent entry;
283 int rc = fs_readdir(&dir, &entry);
284 if (rc != 0 || entry.name[0] ==
'\0')
break;
288 if (snprintf(full,
sizeof(full),
289 "%s/%s", path, entry.name) >= (
int)
sizeof(full)) {
293 if (entry.type == FS_DIR_ENTRY_DIR) {
#define LOGW(...)
Definition AudioLoggerIDF.h:29
#define TRACED()
Definition AudioLoggerIDF.h:31
#define LOGI(...)
Definition AudioLoggerIDF.h:28
#define LOGE(...)
Definition AudioLoggerIDF.h:30
#define FS_MAX_PATH
Definition AudioSourceZephyr.h:16