Skip to content

Commit

Permalink
fix(examples): fix the recursion error in hmi mp3_example
Browse files Browse the repository at this point in the history
Co-authored-by: leeebo <[email protected]>

Resolve #395
  • Loading branch information
herexiong authored and Lzw655 committed Oct 25, 2024
1 parent 4d44973 commit 167ce0d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions examples/hmi/mp3_example/main/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,11 @@ static void sdmmc_init()
sdmmc_card_print_info(stdout, card);
}

static void read_content(const char *path, uint8_t *filecount)
static int read_content(const char *path, uint8_t *filecount)
{
uint8_t ret = 0;
char nextpath[100];
struct dirent *de;
*filecount = 0;
DIR *dir = opendir(path);
while (1) {
de = readdir(dir);
Expand All @@ -389,16 +389,21 @@ static void read_content(const char *path, uint8_t *filecount)
if (strstr(de->d_name, ".mp3") || strstr(de->d_name, ".MP3")) {
sprintf(directory[*filecount], "%s/%s", path, de->d_name);
printf("%s\n", directory[*filecount]);
if ((*filecount)++ >= MAX_PLAY_FILE_NUM) {
if (++(*filecount) >= MAX_PLAY_FILE_NUM) {
ret = -1;
break;
}
}
} else if (de->d_type == DT_DIR) {
sprintf(nextpath, "%s/%s", path, de->d_name);
read_content(nextpath, filecount);
ret = read_content(nextpath, filecount);
if(ret == -1){
break;
}
}
}
closedir(dir);
return ret;
}

#if USE_ADF_TO_PLAY
Expand Down

0 comments on commit 167ce0d

Please sign in to comment.