feat(ncm): 首页顶栏「已缓存」入口 + 已缓存列表页(歌名/歌手/实际档位/大小,点播/单曲删除/清空)
入口:首页 topbar 新增动作 3(MEOW_ICON_DOWNLOAD 位图,原「回播放页」顺延动作 4)→ push ACT_CACHE;左缘返回弹回首页(app.c 路由补齐 tap/swipe/touch/tick)。 列表页 app/ui/cache.c(对齐 queue.c 惯例:圆角卡/红 mini-vinyl/按压红条/当前播放行高亮): - 行 = 歌名 / 歌手 · 实际档位 · 大小;空态/页脚(N 首 · 合计 X MB)。 - 点行 = 点播(NCM_QUEUE_CACHE 队列,上/下一首在缓存列表内循环);行右「删除」=单曲删除; 顶栏「清空」=确认框 + ncm_cache_clear(与设置页「清理缓存」同语义)。 - 数据全在 worker:cache_reload → appstate_cache_list_load → ncm_cache_scan(读目录 + 文件内 tag + 音频头探测)→ 快照;UI 线程零磁盘 IO。快照上限 512 条(最近访问优先, ≈116KB bss),更多条目按 mtime 保留最近的。 core: - ncm_cache_scan / ncm_cache_remove(songs/ 池,song_<id>_<请求档>.<实际格式> 解析, 跳过 .tmp/.part 与非数字 id;按 mtime 降序;历史双点名删除兜底)。 - ncm_api_level_from_key(缓存键后缀 ↔ 档位枚举,与 ncm_api_level_key 互逆)。 - **档位显示实际档而非请求档**:真机存在 song_171650_hires.mp3(无损请求被降级链落到 exhigh mp3),故 scan 用 ncm_audio_probe_file 读实际容器参数后只降不升地推断 (FLAC 16bit→无损 / 24bit→Hi-Res+,MP3 ≤128k→标准 / >128k→极高)。 播放:player_manager 对 NCM_QUEUE_CACHE 用条目真实键(id+请求档+实际扩展名)直读缓存 文件,不按用户当前档键重下;song_local_file/play_is_same_song/queue 页均支持第三种队列。 宿主 mock(NCM_PAGE=cache)造 3 条缓存 + 嵌入 tag + 同步扫描。
This commit is contained in:
1 parent
184ebd0ac9
commit
f392ee5c48
16 files changed
+829
-18
No files matched your search
@@ -242,6 +242,7 @@ static const char *ncm_act_name(int act)
|
||||
case ACT_PLAYER: return "player";
|
||||
case ACT_SETTINGS: return "settings";
|
||||
case ACT_SEARCH: return "search";
|
||||
case ACT_CACHE: return "cache"; /* M5 已缓存列表(app.json 未声明常亮 → 照常息屏) */
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,9 +167,10 @@ void player_manager_set_quality(int level, int cache_gb)
|
||||
static int play_is_same_song(int song_idx)
|
||||
{
|
||||
ncm_song_t cand;
|
||||
int have = (appstate_get_queue() == NCM_QUEUE_SEARCH)
|
||||
? (appstate_search_song(song_idx, &cand) == NCM_OK)
|
||||
: (appstate_song_copy(song_idx, &cand) == NCM_OK);
|
||||
int src = appstate_get_queue();
|
||||
int have = (src == NCM_QUEUE_SEARCH) ? (appstate_search_song(song_idx, &cand) == NCM_OK)
|
||||
: (src == NCM_QUEUE_CACHE) ? (appstate_cache_song(song_idx, &cand) == NCM_OK)
|
||||
: (appstate_song_copy(song_idx, &cand) == NCM_OK);
|
||||
if (!have || !cand.id[0]) return 0; /* 未物化:不能确证同曲 → 交下方正常起播 */
|
||||
pthread_mutex_lock(&g_play.mu);
|
||||
int same = g_play.play_song_valid && g_play.play_song.id[0] &&
|
||||
@@ -645,6 +646,31 @@ static int song_local_file(const ncm_song_t *s, int idx, int seq, song_src_t *ss
|
||||
char key[64];
|
||||
audio_cache_key(key, sizeof key, id, g_level);
|
||||
|
||||
/* 已缓存列表点播(NCM_QUEUE_CACHE):用条目**真实键**(id+文件名请求档)与实际扩展名直接
|
||||
* 命中,不走用户当前档键——否则别的档位/降级产物条目会 miss 而被重下(与「点缓存就该放缓存」
|
||||
* 相悖,也会白耗流量)。条目已被删/被 LRU 淘汰 → NOENT(不重下,UI 报错)。 */
|
||||
if (appstate_get_queue() == NCM_QUEUE_CACHE) {
|
||||
ncm_cache_item_t it;
|
||||
if (appstate_cache_item(idx, &it) == NCM_OK) {
|
||||
char ck[48];
|
||||
if (it.level[0]) snprintf(ck, sizeof ck, "%s_%s", it.id, it.level);
|
||||
else ncm_strlcpy(ck, it.id, sizeof ck);
|
||||
if (ncm_cache_lookup(&g_st.ctx.cache, ck, it.ext, path, psz) == NCM_OK) {
|
||||
struct stat st;
|
||||
if (stat(path, &st) == 0 &&
|
||||
stream_src_open_static(&ss->src, path, (uint64_t)st.st_size) == 0) {
|
||||
ss->total = (int64_t)st.st_size;
|
||||
*bytes = ss->total;
|
||||
pthread_mutex_lock(&g_play.mu);
|
||||
g_play.eff_level = it.actual_level; /* 实际档(非请求档),UI 标注用 */
|
||||
pthread_mutex_unlock(&g_play.mu);
|
||||
return NCM_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NCM_ERR_NOENT;
|
||||
}
|
||||
|
||||
/* 缓存命中 → 静态 stream_src(新键两扩展名都试;档位=用户设定档,降级产物也归该档键) */
|
||||
int hit = 0;
|
||||
if (ncm_cache_lookup(&g_st.ctx.cache, key, "flac", path, psz) == NCM_OK ||
|
||||
|
||||
Reference in new issue
Block a user