add flac support and files management app
This commit is contained in:
1 parent
4126ea13a1
commit
45f7b83e7c
12 files changed
+1526
-139
No files matched your search
+15
-20
@@ -292,6 +292,8 @@ static void audio_set_format(uint32_t sample_rate, uint16_t bits)
|
||||
/* ---------------- 曲目扫描 ---------------- */
|
||||
/**
|
||||
* @brief 判断是否为可播放的音频文件(.wav / .flac)
|
||||
* @note 两种扩展名都要检查,不能因为不是 .wav 就提前 return false,
|
||||
* 否则 .flac 永远被过滤掉。
|
||||
*/
|
||||
static bool name_is_audio(const char *name)
|
||||
{
|
||||
@@ -302,34 +304,27 @@ static bool name_is_audio(const char *name)
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *ext = name + len - 4; /* 指向 ".xxx" */
|
||||
const char *ext = name + len - 4; /* 指向最后 4 个字符 */
|
||||
|
||||
if (ext[0] != '.')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* .wav */
|
||||
if (((ext[1] == 'w') || (ext[1] == 'W')) &&
|
||||
/* .wav —— 最后 4 个字符为 ".wav" */
|
||||
if ((ext[0] == '.') &&
|
||||
((ext[1] == 'w') || (ext[1] == 'W')) &&
|
||||
((ext[2] == 'a') || (ext[2] == 'A')) &&
|
||||
((ext[3] == 'v') || (ext[3] == 'V')))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* .flac(长度至少 5:"a.flac") */
|
||||
if (len >= 5)
|
||||
{
|
||||
const char *f = name + len - 5;
|
||||
/* .flac —— 最后 5 个字符为 ".flac" */
|
||||
const char *ext5 = name + len - 5;
|
||||
|
||||
if ((f[0] == '.') &&
|
||||
((f[1] == 'f') || (f[1] == 'F')) &&
|
||||
((f[2] == 'l') || (f[2] == 'L')) &&
|
||||
((f[3] == 'a') || (f[3] == 'A')) &&
|
||||
((f[4] == 'c') || (f[4] == 'C')))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ((ext5[0] == '.') &&
|
||||
((ext5[1] == 'f') || (ext5[1] == 'F')) &&
|
||||
((ext5[2] == 'l') || (ext5[2] == 'L')) &&
|
||||
((ext5[3] == 'a') || (ext5[3] == 'A')) &&
|
||||
((ext5[4] == 'c') || (ext5[4] == 'C')))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user