ncm: FLAC 解码落地(dr_flac 0.13.4 单头入库) + 缓存键=歌曲ID+音质档位
- 解码分发 decoder.c:magic(fLaC→dr_flac / 其它→minimp3);flac ≤16bit→S16、 >16bit→S32 满幅送 audiod(AUDIO_FMT_S32),rate/ch/bits 按实际流,零 SRC 零裁剪 - song_url_auto 接受 flac(type 权威/url 扩展名兜底),降级语义不变;flac 下载限幅 1GB - 缓存键 song_<id>_<level>.<ext>:同歌同档命中不重下,换档新条目旧档留 LRU; ext 前导点正名(修双点名),lookup 回退历史双点名+旧无档键温和兼容 - audio_out S32 通路(AUDIOD/ALSA/WAV)+ 流死重开按 bits 还原格式 - 验证(0 真实请求):44.1k/16 与 96k/24 自制样本宿主+qemu 帧数/时长精确、 逐样本零误差;mp3 回归逐帧一致;player_flow_sim P1-P6(新 P6 档位键/flac ext)、 cache_evict/cover/pagination/window/audiod_chain sim 全 PASS;mipsel 0 warning - REPORT §19 / VENDOR_NOTES dr_flac 条目;未部署真机(留主会话)
This commit is contained in:
1 parent
80bc191593
commit
70aec677ce
23 files changed
+13377
-110
No files matched your search
@@ -62,7 +62,7 @@ static void pivset(struct snd_interval *iv, unsigned val)
|
||||
}
|
||||
static int alsa_open(int rate, int ch, int bits)
|
||||
{
|
||||
if (bits != 16) return -1;
|
||||
if (bits != 16 && bits != 32) return -1; /* §19:S16 + S32(flac >16bit 满幅) */
|
||||
int fd = open("/dev/snd/pcmC0D0p", O_RDWR);
|
||||
if (fd < 0) {
|
||||
meow_log(MEOW_LOG_ERROR, "audio: alsa open /dev/snd/pcmC0D0p failed errno=%d", errno);
|
||||
@@ -84,7 +84,8 @@ static int alsa_open(int rate, int ch, int bits)
|
||||
struct snd_mask *am = &p.masks[SNDRV_PCM_HW_PARAM_ACCESS - SNDRV_PCM_HW_PARAM_FIRST_MASK];
|
||||
memset(am, 0, sizeof *am); pmask(am, SNDRV_PCM_ACCESS_RW_INTERLEAVED);
|
||||
struct snd_mask *fm = &p.masks[SNDRV_PCM_HW_PARAM_FORMAT - SNDRV_PCM_HW_PARAM_FIRST_MASK];
|
||||
memset(fm, 0, sizeof *fm); pmask(fm, SNDRV_PCM_FORMAT_S16_LE);
|
||||
memset(fm, 0, sizeof *fm);
|
||||
pmask(fm, bits == 32 ? SNDRV_PCM_FORMAT_S32_LE : SNDRV_PCM_FORMAT_S16_LE);
|
||||
struct snd_mask *sm = &p.masks[SNDRV_PCM_HW_PARAM_SUBFORMAT - SNDRV_PCM_HW_PARAM_FIRST_MASK];
|
||||
memset(sm, 0, sizeof *sm); pmask(sm, SNDRV_PCM_SUBFORMAT_STD);
|
||||
pivset(&p.intervals[SNDRV_PCM_HW_PARAM_CHANNELS - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL],
|
||||
@@ -99,13 +100,14 @@ static int alsa_open(int rate, int ch, int bits)
|
||||
return -1;
|
||||
}
|
||||
ioctl(fd, SNDRV_PCM_IOCTL_PREPARE, 0);
|
||||
meow_log(MEOW_LOG_INFO, "audio: alsa open ok rate=%d ch=%d (direct debug)", rate, ch);
|
||||
meow_log(MEOW_LOG_INFO, "audio: alsa open ok rate=%d ch=%d bits=%d (direct debug)", rate, ch, bits);
|
||||
return fd;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 写 WAV 头(44 字节标准 PCM 布局:RIFF/WAVE/fmt(16)/data)。
|
||||
* fmt(16) = format(2) ch(2) sample_rate(4) byte_rate(4) block_align(2) bits(2)。 */
|
||||
* fmt(16) = format(2) ch(2) sample_rate(4) byte_rate(4) block_align(2) bits(2)。
|
||||
* §19:bits 16/32 均合法(32=flac >16bit 的 S32 满幅样本)。 */
|
||||
static void file_write_header(int fd, int rate, int ch, int bits, uint32_t data_len)
|
||||
{
|
||||
unsigned char h[44];
|
||||
@@ -174,12 +176,16 @@ int audio_out_open(int sample_rate, int channels, int bits)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* 默认:SINK_AUDIOD(meow_audiod 独占服务)。v1 SDK 声源格式 S16(minimp3 输出即 S16_LE)。 */
|
||||
if (bits != 16) {
|
||||
meow_log(MEOW_LOG_ERROR, "audio: audiod open: bits=%d unsupported (v1 S16 only)", bits);
|
||||
/* 默认:SINK_AUDIOD(meow_audiod 独占服务)。§19:bits 16→S16 / 32→S32
|
||||
* (flac >16bit 由 dr_flac 出 S32 满幅;格式归一/DAC 原生率跟随在 audiod 侧)。 */
|
||||
int fmt;
|
||||
if (bits == 16) fmt = AUDIO_FMT_S16;
|
||||
else if (bits == 32) fmt = AUDIO_FMT_S32;
|
||||
else {
|
||||
meow_log(MEOW_LOG_ERROR, "audio: audiod open: bits=%d unsupported (16/32)", bits);
|
||||
return -1;
|
||||
}
|
||||
int sid = meow_audio_open(sample_rate, channels, AUDIO_FMT_S16);
|
||||
int sid = meow_audio_open(sample_rate, channels, fmt);
|
||||
if (sid < 0) {
|
||||
meow_log(MEOW_LOG_ERROR, "audio: audiod open failed rc=%d rate=%d ch=%d (audiod 不在?)",
|
||||
sid, sample_rate, channels);
|
||||
@@ -199,7 +205,7 @@ int audio_out_open(int sample_rate, int channels, int bits)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int audio_out_write(const short *samples, int frames)
|
||||
int audio_out_write(const void *samples, int frames)
|
||||
{
|
||||
if (g_app_quit) return -1;
|
||||
if (g_sink == SINK_NULL || g_sink < 0) return frames;
|
||||
@@ -252,11 +258,11 @@ int audio_out_pause(int paused)
|
||||
meow_log(MEOW_LOG_WARN, "audio: audiod pause sid=%d rc=%d (stream dead?)", g_sid, rc);
|
||||
return 0;
|
||||
}
|
||||
/* 恢复失败 = 流已死 → 重开 */
|
||||
/* 恢复失败 = 流已死 → 重开(格式按本次 open 的 bits 还原:16→S16 / 32→S32) */
|
||||
meow_log(MEOW_LOG_WARN, "audio: audiod resume sid=%d rc=%d -> reopen", g_sid, rc);
|
||||
meow_audio_close(g_sid);
|
||||
g_sid = 0;
|
||||
int sid = meow_audio_open(g_rate, g_ch, AUDIO_FMT_S16);
|
||||
int sid = meow_audio_open(g_rate, g_ch, g_bits == 32 ? AUDIO_FMT_S32 : AUDIO_FMT_S16);
|
||||
if (sid < 0) {
|
||||
meow_log(MEOW_LOG_ERROR, "audio: audiod reopen failed rc=%d rate=%d ch=%d", sid, g_rate, g_ch);
|
||||
return -1;
|
||||
|
||||
Reference in new issue
Block a user