-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsokol_audio.nelua
83 lines (83 loc) · 3.68 KB
/
sokol_audio.nelua
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
##[[
if not SOKOL_AUDIO_NO_IMPL then
cdefine 'SOKOL_AUDIO_API_DECL static'
cdefine 'SOKOL_AUDIO_IMPL'
end
cinclude 'sokol_audio.h'
if ccinfo.is_windows then
linklib 'ole32'
elseif ccinfo.is_linux then
linklib 'asound'
cflags '-pthread'
end
]]
global saudio_log_item: type <cimport,nodecl,using> = @enum(cint){
SAUDIO_LOGITEM_OK = 0,
SAUDIO_LOGITEM_MALLOC_FAILED = 1,
SAUDIO_LOGITEM_ALSA_SND_PCM_OPEN_FAILED = 2,
SAUDIO_LOGITEM_ALSA_FLOAT_SAMPLES_NOT_SUPPORTED = 3,
SAUDIO_LOGITEM_ALSA_REQUESTED_BUFFER_SIZE_NOT_SUPPORTED = 4,
SAUDIO_LOGITEM_ALSA_REQUESTED_CHANNEL_COUNT_NOT_SUPPORTED = 5,
SAUDIO_LOGITEM_ALSA_SND_PCM_HW_PARAMS_SET_RATE_NEAR_FAILED = 6,
SAUDIO_LOGITEM_ALSA_SND_PCM_HW_PARAMS_FAILED = 7,
SAUDIO_LOGITEM_ALSA_PTHREAD_CREATE_FAILED = 8,
SAUDIO_LOGITEM_WASAPI_CREATE_EVENT_FAILED = 9,
SAUDIO_LOGITEM_WASAPI_CREATE_DEVICE_ENUMERATOR_FAILED = 10,
SAUDIO_LOGITEM_WASAPI_GET_DEFAULT_AUDIO_ENDPOINT_FAILED = 11,
SAUDIO_LOGITEM_WASAPI_DEVICE_ACTIVATE_FAILED = 12,
SAUDIO_LOGITEM_WASAPI_AUDIO_CLIENT_INITIALIZE_FAILED = 13,
SAUDIO_LOGITEM_WASAPI_AUDIO_CLIENT_GET_BUFFER_SIZE_FAILED = 14,
SAUDIO_LOGITEM_WASAPI_AUDIO_CLIENT_GET_SERVICE_FAILED = 15,
SAUDIO_LOGITEM_WASAPI_AUDIO_CLIENT_SET_EVENT_HANDLE_FAILED = 16,
SAUDIO_LOGITEM_WASAPI_CREATE_THREAD_FAILED = 17,
SAUDIO_LOGITEM_AAUDIO_STREAMBUILDER_OPEN_STREAM_FAILED = 18,
SAUDIO_LOGITEM_AAUDIO_PTHREAD_CREATE_FAILED = 19,
SAUDIO_LOGITEM_AAUDIO_RESTARTING_STREAM_AFTER_ERROR = 20,
SAUDIO_LOGITEM_USING_AAUDIO_BACKEND = 21,
SAUDIO_LOGITEM_AAUDIO_CREATE_STREAMBUILDER_FAILED = 22,
SAUDIO_LOGITEM_USING_SLES_BACKEND = 23,
SAUDIO_LOGITEM_SLES_CREATE_ENGINE_FAILED = 24,
SAUDIO_LOGITEM_SLES_ENGINE_GET_ENGINE_INTERFACE_FAILED = 25,
SAUDIO_LOGITEM_SLES_CREATE_OUTPUT_MIX_FAILED = 26,
SAUDIO_LOGITEM_SLES_MIXER_GET_VOLUME_INTERFACE_FAILED = 27,
SAUDIO_LOGITEM_SLES_ENGINE_CREATE_AUDIO_PLAYER_FAILED = 28,
SAUDIO_LOGITEM_SLES_PLAYER_GET_PLAY_INTERFACE_FAILED = 29,
SAUDIO_LOGITEM_SLES_PLAYER_GET_VOLUME_INTERFACE_FAILED = 30,
SAUDIO_LOGITEM_SLES_PLAYER_GET_BUFFERQUEUE_INTERFACE_FAILED = 31,
SAUDIO_LOGITEM_COREAUDIO_NEW_OUTPUT_FAILED = 32,
SAUDIO_LOGITEM_COREAUDIO_ALLOCATE_BUFFER_FAILED = 33,
SAUDIO_LOGITEM_COREAUDIO_START_FAILED = 34,
SAUDIO_LOGITEM_BACKEND_BUFFER_SIZE_ISNT_MULTIPLE_OF_PACKET_SIZE = 35
}
global saudio_logger: type <cimport,nodecl> = @record{
func: function(cstring, uint32, uint32, cstring, uint32, cstring, pointer): void,
user_data: pointer
}
global saudio_allocator: type <cimport,nodecl> = @record{
alloc: function(csize, pointer): pointer,
free: function(pointer, pointer): void,
user_data: pointer
}
global saudio_desc: type <cimport,nodecl> = @record{
sample_rate: cint,
num_channels: cint,
buffer_frames: cint,
packet_frames: cint,
num_packets: cint,
stream_cb: function(*float32, cint, cint): void,
stream_userdata_cb: function(*float32, cint, cint, pointer): void,
user_data: pointer,
allocator: saudio_allocator,
logger: saudio_logger
}
global function saudio_setup(desc: *saudio_desc): void <cimport,nodecl> end
global function saudio_shutdown(): void <cimport,nodecl> end
global function saudio_isvalid(): boolean <cimport,nodecl> end
global function saudio_userdata(): pointer <cimport,nodecl> end
global function saudio_query_desc(): saudio_desc <cimport,nodecl> end
global function saudio_sample_rate(): cint <cimport,nodecl> end
global function saudio_buffer_frames(): cint <cimport,nodecl> end
global function saudio_channels(): cint <cimport,nodecl> end
global function saudio_suspended(): boolean <cimport,nodecl> end
global function saudio_expect(): cint <cimport,nodecl> end
global function saudio_push(frames: *float32, num_frames: cint): cint <cimport,nodecl> end