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