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; }