1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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;
}
|