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
|
use sdl2;
use types::c;
type SDL_AudioFormat = u16;
def AUDIO_S16LSB: SDL_AudioFormat = 0x8010;
type SDL_AudioCallback = *fn(userdata: nullable *opaque, stream: *u8, len_: int) void;
type SDL_AudioSpec = struct {
freq: int,
format: SDL_AudioFormat,
channels: u8,
silence: u8,
samples: u16,
padding: u16,
size_: u32,
callback: SDL_AudioCallback,
userdata: nullable *opaque
};
type SDL_AudioDeviceID = u32;
@symbol("SDL_OpenAudioDevice") fn _SDL_OpenAudioDevice(device: nullable *c::char, iscapture: int, desired: const *SDL_AudioSpec, obtained: nullable *SDL_AudioSpec, allowed_changes: int) SDL_AudioDeviceID;
@symbol("SDL_CloseAudioDevice") fn SDL_CloseAudioDevice(dev: SDL_AudioDeviceID) void;
@symbol("SDL_PauseAudioDevice") fn SDL_PauseAudioDevice(dev: SDL_AudioDeviceID, pause_on: int) void;
@symbol("SDL_GetError") fn SDL_GetError() const *c::char;
fn SDL_OpenAudioDevice(device: nullable *c::char, iscapture: int, desired: const *SDL_AudioSpec, obtained: nullable *SDL_AudioSpec, allowed_changes: int) (SDL_AudioDeviceID | sdl2::error) = {
const ret = _SDL_OpenAudioDevice(device, iscapture, desired, obtained, allowed_changes);
if (ret == 0) {
return c::tostr(SDL_GetError()): sdl2::error;
};
return ret;
};
|