diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-02-09 02:08:17 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-02-09 02:08:17 +0100 |
commit | 21f8e1c794cbd90c6ac8cf62e832fdb8a196bcb8 (patch) | |
tree | 9da02c8a0824d48168957e5af8c94071e4b7fc85 /naprave.c | |
parent | razno (diff) | |
download | soča-21f8e1c794cbd90c6ac8cf62e832fdb8a196bcb8.tar soča-21f8e1c794cbd90c6ac8cf62e832fdb8a196bcb8.tar.gz soča-21f8e1c794cbd90c6ac8cf62e832fdb8a196bcb8.tar.bz2 soča-21f8e1c794cbd90c6ac8cf62e832fdb8a196bcb8.tar.lz soča-21f8e1c794cbd90c6ac8cf62e832fdb8a196bcb8.tar.xz soča-21f8e1c794cbd90c6ac8cf62e832fdb8a196bcb8.tar.zst soča-21f8e1c794cbd90c6ac8cf62e832fdb8a196bcb8.zip |
Diffstat (limited to '')
-rw-r--r-- | naprave.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/naprave.c b/naprave.c new file mode 100644 index 0000000..6b137af --- /dev/null +++ b/naprave.c @@ -0,0 +1,57 @@ +#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; +} |