/* * audprobe.c - probe the AIX audio device * Claude Opus 4.5, 2026-10-13 */ #include #undef BIG_ENDIAN #include #include #include #include #include #include #include #include int main(int argc, char **argv) { int fd; audio_init init; audio_status status; int flags = O_RDWR; char *dev = "/dev/paud0"; if (argc > 1) dev = argv[1]; if (argc > 2) { if (strcmp(argv[2], "r") == 0) flags = O_RDONLY; else if (strcmp(argv[2], "w") == 0) flags = O_WRONLY; else if (strcmp(argv[2], "rw") == 0) flags = O_RDWR; } printf("opening %s with flags 0x%x\n", dev, flags); fd = open(dev, flags); if (fd < 0) { printf("open failed: errno=%d (%s)\n", errno, strerror(errno)); return 1; } printf("open succeeded, fd=%d\n", fd); /* try AUDIO_STATUS first - should work even without INIT */ memset(&status, 0, sizeof(status)); if (ioctl(fd, AUDIO_STATUS, &status) < 0) { printf("AUDIO_STATUS failed: errno=%d (%s)\n", errno, strerror(errno)); } else { printf("AUDIO_STATUS ok:\n"); printf(" srate=%ld bits=%ld mode=%d channels=%d\n", status.srate, status.bits_per_sample, status.mode, status.channels); printf(" flags=0x%lx operation=0x%lx\n", status.flags, status.operation); } /* try AUDIO_INIT to query capabilities */ memset(&init, 0, sizeof(init)); init.srate = 22050; init.bits_per_sample = 16; init.mode = PCM; init.channels = 1; init.flags = SIGNED | TWOS_COMPLEMENT | BIG_ENDIAN | FIXED; init.operation = PLAY; printf("\nattempting AUDIO_INIT: srate=%ld bits=%ld mode=%d channels=%d flags=0x%lx op=%ld\n", init.srate, init.bits_per_sample, init.mode, init.channels, init.flags, init.operation); if (ioctl(fd, AUDIO_INIT, &init) < 0) { printf("AUDIO_INIT failed: errno=%d (%s)\n", errno, strerror(errno)); } else { printf("AUDIO_INIT returned:\n"); printf(" rc=%d srate=%ld bits=%ld bsize=%ld\n", init.rc, init.srate, init.bits_per_sample, init.bsize); printf(" flags=0x%lx slot=%d device_id=%d\n", init.flags, init.slot_number, init.device_id); } close(fd); return 0; }