1 /++
2 + Machine generated D bindings for Sokol library.
3 + 
4 +     Source header: sokol_audio.h
5 +     Module: sokol.audio
6 + 
7 +     Do not edit manually; regenerate using gen_d.py.
8 +/
9 module sokol.audio;
10 
11 enum LogItem {
12     Ok,
13     Malloc_failed,
14     Alsa_snd_pcm_open_failed,
15     Alsa_float_samples_not_supported,
16     Alsa_requested_buffer_size_not_supported,
17     Alsa_requested_channel_count_not_supported,
18     Alsa_snd_pcm_hw_params_set_rate_near_failed,
19     Alsa_snd_pcm_hw_params_failed,
20     Alsa_pthread_create_failed,
21     Pulseaudio_invalid_sample_spec,
22     Pulseaudio_simple_new_failed,
23     Pulseaudio_simple_write_failed,
24     Pulseaudio_pthread_create_failed,
25     Wasapi_create_event_failed,
26     Wasapi_create_device_enumerator_failed,
27     Wasapi_get_default_audio_endpoint_failed,
28     Wasapi_device_activate_failed,
29     Wasapi_audio_client_initialize_failed,
30     Wasapi_audio_client_get_buffer_size_failed,
31     Wasapi_audio_client_get_service_failed,
32     Wasapi_audio_client_set_event_handle_failed,
33     Wasapi_create_thread_failed,
34     Aaudio_streambuilder_open_stream_failed,
35     Aaudio_pthread_create_failed,
36     Aaudio_restarting_stream_after_error,
37     Using_aaudio_backend,
38     Aaudio_create_streambuilder_failed,
39     Coreaudio_new_output_failed,
40     Coreaudio_allocate_buffer_failed,
41     Coreaudio_start_failed,
42     Backend_buffer_size_isnt_multiple_of_packet_size,
43     Vita_sceaudio_open_failed,
44     Vita_pthread_create_failed,
45     N3ds_ndsp_open_failed,
46 }
47 /++
48 + saudio_logger
49 + 
50 +     Used in saudio_desc to provide a custom logging and error reporting
51 +     callback to sokol-audio.
52 +/
53 extern(C) struct Logger {
54     extern(C) void function(const(char)*, uint, uint, const(char)*, uint, const(char)*, void*) func = null;
55     void* user_data = null;
56 }
57 /++
58 + saudio_allocator
59 + 
60 +     Used in saudio_desc to provide custom memory-alloc and -free functions
61 +     to sokol_audio.h. If memory management should be overridden, both the
62 +     alloc_fn and free_fn function must be provided (e.g. it's not valid to
63 +     override one function but not the other).
64 +/
65 extern(C) struct Allocator {
66     extern(C) void* function(size_t, void*) alloc_fn = null;
67     extern(C) void function(void*, void*) free_fn = null;
68     void* user_data = null;
69 }
70 enum N3dsNdspinterptype {
71     Dsp_interp_polyphase = 0,
72     Dsp_interp_linear = 1,
73     Dsp_interp_none = 2,
74 }
75 extern(C) struct N3dsDesc {
76     int queue_count = 0;
77     N3dsNdspinterptype interpolation_type = N3dsNdspinterptype.Dsp_interp_polyphase;
78     int channel_id = 0;
79 }
80 extern(C) struct Win32Desc {
81     bool skip_coinitialize = false;
82 }
83 extern(C) struct Desc {
84     int sample_rate = 0;
85     int num_channels = 0;
86     int buffer_frames = 0;
87     int packet_frames = 0;
88     int num_packets = 0;
89     extern(C) void function(float*, int, int) stream_cb = null;
90     extern(C) void function(float*, int, int, void*) stream_userdata_cb = null;
91     void* user_data = null;
92     Win32Desc win32 = {};
93     N3dsDesc n3ds = {};
94     Allocator allocator = {};
95     Logger logger = {};
96 }
97 /++
98 + setup sokol-audio
99 +/
100 extern(C) void saudio_setup(const Desc* desc) @system @nogc nothrow pure;
101 void setup(scope ref Desc desc) @trusted @nogc nothrow pure {
102     saudio_setup(&desc);
103 }
104 /++
105 + shutdown sokol-audio
106 +/
107 extern(C) void saudio_shutdown() @system @nogc nothrow pure;
108 void shutdown() @trusted @nogc nothrow pure {
109     saudio_shutdown();
110 }
111 /++
112 + true after setup if audio backend was successfully initialized
113 +/
114 extern(C) bool saudio_isvalid() @system @nogc nothrow pure;
115 bool isvalid() @trusted @nogc nothrow pure {
116     return saudio_isvalid();
117 }
118 /++
119 + return the saudio_desc.user_data pointer
120 +/
121 extern(C) void* saudio_userdata() @system @nogc nothrow pure;
122 void* userdata() @trusted @nogc nothrow pure {
123     return saudio_userdata();
124 }
125 /++
126 + return a copy of the original saudio_desc struct
127 +/
128 extern(C) Desc saudio_query_desc() @system @nogc nothrow pure;
129 Desc queryDesc() @trusted @nogc nothrow pure {
130     return saudio_query_desc();
131 }
132 /++
133 + actual sample rate
134 +/
135 extern(C) int saudio_sample_rate() @system @nogc nothrow pure;
136 int sampleRate() @trusted @nogc nothrow pure {
137     return saudio_sample_rate();
138 }
139 /++
140 + return actual backend buffer size in number of frames
141 +/
142 extern(C) int saudio_buffer_frames() @system @nogc nothrow pure;
143 int bufferFrames() @trusted @nogc nothrow pure {
144     return saudio_buffer_frames();
145 }
146 /++
147 + actual number of channels
148 +/
149 extern(C) int saudio_channels() @system @nogc nothrow pure;
150 int channels() @trusted @nogc nothrow pure {
151     return saudio_channels();
152 }
153 /++
154 + return true if audio context is currently suspended (only in WebAudio backend, all other backends return false)
155 +/
156 extern(C) bool saudio_suspended() @system @nogc nothrow pure;
157 bool suspended() @trusted @nogc nothrow pure {
158     return saudio_suspended();
159 }
160 /++
161 + get current number of frames to fill packet queue
162 +/
163 extern(C) int saudio_expect() @system @nogc nothrow pure;
164 int expect() @trusted @nogc nothrow pure {
165     return saudio_expect();
166 }
167 /++
168 + push sample frames from main thread, returns number of frames actually pushed
169 +/
170 extern(C) int saudio_push(const float* frames, int num_frames) @system @nogc nothrow pure;
171 int push(const float* frames, int num_frames) @trusted @nogc nothrow pure {
172     return saudio_push(frames, num_frames);
173 }