-
Notifications
You must be signed in to change notification settings - Fork 2
/
gosoundio.c
37 lines (31 loc) · 949 Bytes
/
gosoundio.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include "gosoundio.h"
int gosoundio_connect(void* s) {
struct SoundIo* snd = (struct SoundIo*)s;
int res = soundio_connect(snd);
soundio_flush_events(snd);
return res;
}
struct SoundIoOutStream* create_outstream(struct SoundIoDevice* device) {
struct SoundIoOutStream* outstream = soundio_outstream_create(device);
if (!outstream) {
return NULL;
}
outstream->write_callback = writeCallbackProxy;
outstream->format = SoundIoFormatFloat32NE;
return outstream;
}
void run(struct SoundIoOutStream *outstream) {
int err;
if ((err = soundio_outstream_start(outstream))) {
fprintf(stderr, "unable to start device: %s", soundio_strerror(err));
return;
}
for (;;)
soundio_wait_events(outstream->device->soundio);
printf("Done waiting for events...\n");
}