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