diff --git a/example/list_devices.c b/example/list_devices.c index e54a00e..40192be 100644 --- a/example/list_devices.c +++ b/example/list_devices.c @@ -14,7 +14,7 @@ // list or keep a watch on audio devices static int usage(char *exe) { - fprintf(stderr, "Usage: %s [--watch]\n", exe); + fprintf(stderr, "Usage: %s [--watch] [--dummy] [--alsa] [--pulseaudio]\n", exe); return 1; } @@ -108,11 +108,18 @@ static void on_devices_change(struct SoundIo *soundio) { int main(int argc, char **argv) { char *exe = argv[0]; bool watch = false; + enum SoundIoBackend backend = SoundIoBackendNone; for (int i = 1; i < argc; i += 1) { char *arg = argv[i]; if (strcmp("--watch", arg) == 0) { watch = true; + } else if (strcmp("--dummy", arg) == 0) { + backend = SoundIoBackendDummy; + } else if (strcmp("--alsa", arg) == 0) { + backend = SoundIoBackendAlsa; + } else if (strcmp("--pulseaudio", arg) == 0) { + backend = SoundIoBackendPulseAudio; } else { return usage(exe); } @@ -124,8 +131,10 @@ int main(int argc, char **argv) { return 1; } - int err; - if ((err = soundio_connect(soundio))) { + int err = (backend == SoundIoBackendNone) ? + soundio_connect(soundio) : soundio_connect_backend(soundio, backend); + + if (err) { fprintf(stderr, "%s\n", soundio_strerror(err)); return err; } diff --git a/src/soundio.h b/src/soundio.h index c82bf07..11ecc6a 100644 --- a/src/soundio.h +++ b/src/soundio.h @@ -479,12 +479,13 @@ enum SoundIoDevicePurpose soundio_device_purpose(const struct SoundIoDevice *dev // Sorts channel layouts by channel count, descending. void soundio_device_sort_channel_layouts(struct SoundIoDevice *device); -// Returns whether `format` is included in the devices supported formats. +// Convenience function. Returns whether `format` is included in the device's +// supported formats. bool soundio_device_supports_format(struct SoundIoDevice *device, enum SoundIoFormat format); -// Returns whether `layout` is included in the devices supported channel -// layouts. +// Convenience function. Returns whether `layout` is included in the device's +// supported channel layouts. bool soundio_device_supports_layout(struct SoundIoDevice *device, const struct SoundIoChannelLayout *layout);