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