#include <soundio/soundio.h>
#include <stdio.h>
#include <error.h>
#include <signal.h>
int main (int argc, char ** argv) {
int r = 0;
fprintf(stderr, "s prvim argumentom bi lahko izbral zaledje izmed: dummy, alsa, pulseaudio, jack, coreaudio, wasapi\n");
enum SoundIoBackend backend = SoundIoBackendNone;
if (argc > 1) {
switch (argv[1][0]) {
case 'd':
backend = SoundIoBackendDummy;
break;
case 'a':
backend = SoundIoBackendAlsa;
break;
case 'p':
backend = SoundIoBackendPulseAudio;
break;
case 'j':
backend = SoundIoBackendJack;
break;
case 'c':
backend = SoundIoBackendCoreAudio;
break;
case 'w':
backend = SoundIoBackendWasapi;
break;
default:
error_at_line(1, 0, __FILE__, __LINE__, "neobstoječe zaledje");
}
}
struct SoundIo * soundio = soundio_create();
if (!soundio)
error_at_line(2, 0, __FILE__, __LINE__, "oom");
int err = (backend == SoundIoBackendNone) ? soundio_connect(soundio) : soundio_connect_backend(soundio, backend);
if (err) {
error_at_line(0, 0, __FILE__, __LINE__, "povezava na zaledje neuspešna: %s", soundio_strerror(err));
r = 3;
goto r;
}
soundio_flush_events(soundio);
fprintf(stderr, "zap. št.\tid\time\ttip\tfrekvenca vzorčenja\n");
for (int i = 0; i < soundio_input_device_count(soundio); i++) {
struct SoundIoDevice * device = soundio_get_input_device(soundio, i);
int max = 0;
for (int j = 0; j < device->sample_rate_count; j++) {
if (device->sample_rates[j].max > max)
max = device->sample_rates[j].max;
}
printf("%d\t%s\t%s\t%s\t%d\n", i, device->id, device->name, device->aim == SoundIoDeviceAimInput ? "vhodna" : "izhodna", max);
soundio_device_unref(device);
}
r:
soundio_destroy(soundio);
return r;
}