fix(audiod): ALSA 几何收窄 period=1024×4(tiny_alsa惯例) — 根治长流停摆(驱动默认巨buffer致hbc3000桥周期中断稀缺wedge; tonepcm2矩阵实测60s零stall)。宿主38/38 PASS

This commit is contained in:
MeowOS committed 2026-09-01 11:06:01 +08:00
1 parent 805fcf179a
commit 84fd0a87aa
4 files changed
+18 -1

No files matched your search

+11
View File
@@ -86,6 +86,17 @@ int main(int argc, char **argv)
iv->min = iv->max = 2; iv->integer = 1;
iv = &p.intervals[SNDRV_PCM_HW_PARAM_RATE - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
iv->min = iv->max = 44100; iv->integer = 1;
{ /* 几何收窄:TPCM_PERIOD/TPCM_BCOUNT 环境变量(默认 1024x4,对齐 tinyalsa 惯例) */
unsigned ps = 1024, bc = 4;
const char *e;
if ((e = getenv("TPCM_PERIOD"))) ps = (unsigned)atoi(e);
if ((e = getenv("TPCM_BCOUNT"))) bc = (unsigned)atoi(e);
struct snd_interval *iv2 = &p.intervals[SNDRV_PCM_HW_PARAM_PERIOD_SIZE - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
iv2->min = iv2->max = ps; iv2->integer = 1;
iv2 = &p.intervals[SNDRV_PCM_HW_PARAM_PERIODS - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
iv2->min = iv2->max = bc; iv2->integer = 1;
printf("geometry: period=%u count=%u\n", ps, bc);
}
if (ioctl(fd, SNDRV_PCM_IOCTL_HW_REFINE, &p) != 0) { printf("REFINE2 fail\n"); close(fd); return 1; }
if (getenv("PROBE_ONLY")) { printf("PROBE_ONLY: stop before PARAMS/write\n"); close(fd); return 0; }
if (ioctl(fd, SNDRV_PCM_IOCTL_HW_PARAMS, &p) != 0) { printf("HW_PARAMS fail\n"); close(fd); return 1; }