mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2024-12-23 04:05:36 +00:00
list_devices takes arguments to override backend
This commit is contained in:
parent
13e6aba370
commit
24f466a0a0
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue