feat(sim): startup can be slow when scanning SYSTEM audio files (#5822)
This commit is contained in:
+15
-2
@@ -213,6 +213,17 @@ void referenceSystemAudioFiles()
|
|||||||
|
|
||||||
sdAvailableSystemAudioFiles.reset();
|
sdAvailableSystemAudioFiles.reset();
|
||||||
|
|
||||||
|
#if defined(SIMU)
|
||||||
|
// f_readdir does an f_stat call on every file when running in the simulator
|
||||||
|
// so it is faster to just call f_stat on the files we are interested in
|
||||||
|
for (int i=0; i<AU_SPECIAL_SOUND_FIRST; i++) {
|
||||||
|
getSystemAudioFile(path, i);
|
||||||
|
if (f_stat(path, nullptr) == FR_OK)
|
||||||
|
sdAvailableSystemAudioFiles.setBit(i);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// On the radio f_readdir on the whole SYSTEM folder is faster than
|
||||||
|
// calling f_stat for each audio file name
|
||||||
char * filename = strAppendSystemAudioPath(path);
|
char * filename = strAppendSystemAudioPath(path);
|
||||||
*(filename-1) = '\0';
|
*(filename-1) = '\0';
|
||||||
|
|
||||||
@@ -227,8 +238,9 @@ void referenceSystemAudioFiles()
|
|||||||
if (len < 5 || strcasecmp(fno.fname+len-4, SOUNDS_EXT) || (fno.fattrib & AM_DIR)) continue;
|
if (len < 5 || strcasecmp(fno.fname+len-4, SOUNDS_EXT) || (fno.fattrib & AM_DIR)) continue;
|
||||||
|
|
||||||
for (int i=0; i<AU_SPECIAL_SOUND_FIRST; i++) {
|
for (int i=0; i<AU_SPECIAL_SOUND_FIRST; i++) {
|
||||||
getSystemAudioFile(path, i);
|
strcpy(path, audioFilenames[i]);
|
||||||
if (!strcasecmp(filename, fno.fname)) {
|
strcat(path, SOUNDS_EXT);
|
||||||
|
if (!strcasecmp(path, fno.fname)) {
|
||||||
sdAvailableSystemAudioFiles.setBit(i);
|
sdAvailableSystemAudioFiles.setBit(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -236,6 +248,7 @@ void referenceSystemAudioFiles()
|
|||||||
}
|
}
|
||||||
f_closedir(&dir);
|
f_closedir(&dir);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void referenceModelAudioFiles()
|
void referenceModelAudioFiles()
|
||||||
|
|||||||
Reference in New Issue
Block a user