From 793a807ce3271b3c16dd242f0a9af4e774729591 Mon Sep 17 00:00:00 2001 From: MeowOS Date: Tue, 1 Sep 2026 03:16:52 +0800 Subject: [PATCH] =?UTF-8?q?tools:=20tonepcm2=20=E6=94=AF=E6=8C=81=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=8F=82=E6=95=B0(=E6=B5=8B=20D1p)=20+=20PROBE=5FONLY?= =?UTF-8?q?=20=E6=A8=A1=E5=BC=8F(=E5=8F=AA=E6=8E=A2=E6=B5=8B=E4=B8=8D?= =?UTF-8?q?=E6=92=AD=E6=94=BE,=20=E9=98=B2=E6=8C=82=E6=AD=BB)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- patch_v2/tools/tonepcm2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/patch_v2/tools/tonepcm2.c b/patch_v2/tools/tonepcm2.c index 84ce4be..0972865 100644 --- a/patch_v2/tools/tonepcm2.c +++ b/patch_v2/tools/tonepcm2.c @@ -41,8 +41,10 @@ static const char *fmt_name(unsigned f) int main(int argc, char **argv) { int sec = argc > 1 ? atoi(argv[1]) : 5; - int fd = open("/dev/snd/pcmC0D0p", O_RDWR); - if (fd < 0) { printf("open fail\n"); return 1; } + const char *dev = (argc > 2) ? argv[2] : "/dev/snd/pcmC0D0p"; + int fd = open(dev, O_RDWR); + if (fd < 0) { printf("open %s fail\n", dev); return 1; } + printf("dev=%s\n", dev); /* 1) REFINE 探测 */ struct snd_pcm_hw_params p; @@ -85,6 +87,7 @@ int main(int argc, char **argv) iv = &p.intervals[SNDRV_PCM_HW_PARAM_RATE - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; iv->min = iv->max = 44100; iv->integer = 1; 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; } printf("HW_PARAMS ok\n"); if (ioctl(fd, SNDRV_PCM_IOCTL_PREPARE, 0) != 0) { printf("PREPARE fail\n"); close(fd); return 1; }