1 /// C declarations of ALSA that libsoundio uses 2 module soundio.headers.alsaheader; 3 4 extern(C): @nogc: nothrow: __gshared: 5 6 import core.stdc.config: c_long, c_ulong; 7 import core.sys.posix.poll; 8 9 // conf.h 10 int snd_config_update_free_global(); 11 int snd_config_update(); 12 13 // control.h 14 struct snd_ctl_t; 15 struct snd_ctl_card_info_t; 16 int snd_card_next(int* card); 17 char *snd_device_name_get_hint(const(void)* hint, const(char)* id); 18 int snd_device_name_hint(int card, const(char)* iface, void*** hints); 19 int snd_device_name_free_hint(void** hints); 20 int snd_ctl_open(snd_ctl_t** ctl, const(char)* name, int mode); 21 int snd_ctl_close(snd_ctl_t* ctl); 22 int snd_ctl_card_info(snd_ctl_t* ctl, snd_ctl_card_info_t* info); 23 int snd_ctl_pcm_next_device(snd_ctl_t* ctl, int* device); 24 int snd_ctl_pcm_info(snd_ctl_t* ctl, snd_pcm_info_t* info); 25 const(char)* snd_ctl_card_info_get_name(const(snd_ctl_card_info_t)* obj); 26 27 28 size_t snd_ctl_card_info_sizeof(); 29 int snd_ctl_card_info_malloc(snd_ctl_card_info_t** ptr); 30 void snd_ctl_card_info_free(snd_ctl_card_info_t* obj); 31 32 // pcm.h 33 size_t snd_pcm_sw_params_sizeof(); 34 size_t snd_pcm_hw_params_sizeof(); 35 size_t snd_pcm_format_mask_sizeof(); 36 size_t snd_pcm_info_sizeof(); 37 38 39 int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t** ptr); 40 void snd_pcm_sw_params_free(snd_pcm_sw_params_t* obj); 41 int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t** ptr); 42 void snd_pcm_hw_params_free(snd_pcm_hw_params_t* obj); 43 int snd_pcm_format_mask_malloc(snd_pcm_format_mask_t** ptr); 44 void snd_pcm_format_mask_free(snd_pcm_format_mask_t* obj); 45 int snd_pcm_info_malloc(snd_pcm_info_t** ptr); 46 void snd_pcm_info_free(snd_pcm_info_t* obj); 47 48 int snd_pcm_open(snd_pcm_t** pcm, const(char)* name, snd_pcm_stream_t stream, int mode); 49 50 int snd_pcm_hw_params_any(snd_pcm_t* pcm, snd_pcm_hw_params_t* params); 51 void snd_pcm_free_chmaps(snd_pcm_chmap_query_t** maps); 52 int snd_pcm_format_mask_test(const(snd_pcm_format_mask_t)* mask, snd_pcm_format_t val); 53 int snd_pcm_hw_params_get_rate_min(const(snd_pcm_hw_params_t)* params, uint* val, int* dir); 54 int snd_pcm_hw_params_get_buffer_size_min(const(snd_pcm_hw_params_t)* params, snd_pcm_uframes_t* val); 55 int snd_pcm_hw_params_get_buffer_size_max(const(snd_pcm_hw_params_t)* params, snd_pcm_uframes_t* val); 56 57 58 void snd_pcm_format_mask_none(snd_pcm_format_mask_t* mask); 59 void snd_pcm_format_mask_set(snd_pcm_format_mask_t* mask, snd_pcm_format_t val); 60 int snd_pcm_hw_params_set_access(snd_pcm_t* pcm, snd_pcm_hw_params_t* params, snd_pcm_access_t _access); 61 snd_pcm_chmap_query_t** snd_pcm_query_chmaps(snd_pcm_t* pcm); 62 int snd_pcm_close(snd_pcm_t* pcm); 63 snd_pcm_chmap_t* snd_pcm_get_chmap(snd_pcm_t* pcm); 64 65 int snd_pcm_hw_params_set_rate_resample(snd_pcm_t* pcm, snd_pcm_hw_params_t* params, uint val); 66 int snd_pcm_hw_params_get_channels_min(const(snd_pcm_hw_params_t)* params, uint* val); 67 int snd_pcm_hw_params_set_channels_last(snd_pcm_t* pcm, snd_pcm_hw_params_t* params, uint* val); 68 int snd_pcm_hw_params_set_rate_last(snd_pcm_t* pcm, snd_pcm_hw_params_t* params, uint* val, int* dir); 69 70 int snd_pcm_hw_params_set_buffer_size_first(snd_pcm_t* pcm, snd_pcm_hw_params_t* params, snd_pcm_uframes_t* val); 71 72 int snd_pcm_poll_descriptors_count(snd_pcm_t* pcm); 73 int snd_pcm_poll_descriptors(snd_pcm_t* pcm, pollfd* pfds, uint space); 74 int snd_pcm_poll_descriptors_revents(snd_pcm_t* pcm, pollfd* pfds, uint nfds, ushort* revents); 75 int snd_pcm_hw_params(snd_pcm_t* pcm, snd_pcm_hw_params_t* params); 76 int snd_pcm_sw_params_current(snd_pcm_t* pcm, snd_pcm_sw_params_t* params); 77 int snd_pcm_sw_params(snd_pcm_t* pcm, snd_pcm_sw_params_t* params); 78 int snd_pcm_prepare(snd_pcm_t* pcm); 79 int snd_pcm_reset(snd_pcm_t* pcm); 80 int snd_pcm_start(snd_pcm_t* pcm); 81 int snd_pcm_drop(snd_pcm_t* pcm); 82 int snd_pcm_pause(snd_pcm_t* pcm, int enable); 83 snd_pcm_state_t snd_pcm_state(snd_pcm_t* pcm); 84 int snd_pcm_delay(snd_pcm_t* pcm, snd_pcm_sframes_t* delayp); 85 int snd_pcm_resume(snd_pcm_t* pcm); 86 snd_pcm_sframes_t snd_pcm_avail(snd_pcm_t* pcm); 87 snd_pcm_sframes_t snd_pcm_avail_update(snd_pcm_t* pcm); 88 snd_pcm_sframes_t snd_pcm_readi(snd_pcm_t* pcm, void* buffer, snd_pcm_uframes_t size); 89 snd_pcm_sframes_t snd_pcm_readn(snd_pcm_t* pcm, void** bufs, snd_pcm_uframes_t size); 90 snd_pcm_chmap_query_t** snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev, snd_pcm_stream_t stream); 91 int snd_pcm_set_chmap(snd_pcm_t* pcm, const(snd_pcm_chmap_t)* map); 92 const(char)* snd_pcm_info_get_name(const(snd_pcm_info_t)* obj); 93 void snd_pcm_info_set_device(snd_pcm_info_t* obj, uint val); 94 void snd_pcm_info_set_subdevice(snd_pcm_info_t* obj, uint val); 95 void snd_pcm_info_set_stream(snd_pcm_info_t* obj, snd_pcm_stream_t val); 96 int snd_pcm_hw_params_set_format(snd_pcm_t* pcm, snd_pcm_hw_params_t* params, snd_pcm_format_t val); 97 int snd_pcm_hw_params_set_format_mask(snd_pcm_t* pcm, snd_pcm_hw_params_t* params, snd_pcm_format_mask_t* mask); 98 void snd_pcm_hw_params_get_format_mask(snd_pcm_hw_params_t* params, snd_pcm_format_mask_t* mask); 99 int snd_pcm_hw_params_set_channels(snd_pcm_t* pcm, snd_pcm_hw_params_t* params, uint val); 100 int snd_pcm_hw_params_set_rate(snd_pcm_t* pcm, snd_pcm_hw_params_t* params, uint val, int dir); 101 int snd_pcm_hw_params_get_period_size(const(snd_pcm_hw_params_t)* params, snd_pcm_uframes_t* frames, int* dir); 102 int snd_pcm_hw_params_set_period_size_near(snd_pcm_t* pcm, snd_pcm_hw_params_t* params, snd_pcm_uframes_t* val, int* dir); 103 int snd_pcm_hw_params_set_buffer_size_near(snd_pcm_t* pcm, snd_pcm_hw_params_t* params, snd_pcm_uframes_t* val); 104 int snd_pcm_hw_params_set_buffer_size_last(snd_pcm_t* pcm, snd_pcm_hw_params_t* params, snd_pcm_uframes_t* val); 105 int snd_pcm_sw_params_set_avail_min(snd_pcm_t* pcm, snd_pcm_sw_params_t* params, snd_pcm_uframes_t val); 106 int snd_pcm_sw_params_set_start_threshold(snd_pcm_t* pcm, snd_pcm_sw_params_t* params, snd_pcm_uframes_t val); 107 int snd_pcm_mmap_begin(snd_pcm_t* pcm, const(snd_pcm_channel_area_t)** areas, snd_pcm_uframes_t* offset, snd_pcm_uframes_t* frames); 108 snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t* pcm, snd_pcm_uframes_t offset, snd_pcm_uframes_t frames); 109 int snd_pcm_format_physical_width(snd_pcm_format_t format); 110 snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t* pcm, const(void)* buffer, snd_pcm_uframes_t size); 111 snd_pcm_sframes_t snd_pcm_writen(snd_pcm_t* pcm, void** bufs, snd_pcm_uframes_t size); 112 113 struct snd_pcm_t; 114 struct snd_pcm_chmap_t { 115 uint channels; 116 uint[0] pos; 117 } 118 119 // C enum 120 alias snd_pcm_access_t = int; 121 enum { 122 SND_PCM_ACCESS_MMAP_INTERLEAVED = 0, 123 SND_PCM_ACCESS_MMAP_NONINTERLEAVED, 124 SND_PCM_ACCESS_MMAP_COMPLEX, 125 SND_PCM_ACCESS_RW_INTERLEAVED, 126 SND_PCM_ACCESS_RW_NONINTERLEAVED, 127 SND_PCM_ACCESS_LAST = SND_PCM_ACCESS_RW_NONINTERLEAVED 128 } 129 130 alias snd_pcm_uframes_t = c_ulong; 131 alias snd_pcm_sframes_t = c_long; 132 133 // C enum 134 alias snd_pcm_format_t = int; 135 136 // C enum 137 alias snd_pcm_stream_t = int; 138 enum { 139 SND_PCM_STREAM_PLAYBACK = 0, 140 SND_PCM_STREAM_CAPTURE, 141 SND_PCM_STREAM_LAST = SND_PCM_STREAM_CAPTURE 142 } 143 144 // C enum 145 alias snd_pcm_state_t = int; 146 enum { 147 SND_PCM_STATE_OPEN = 0, 148 SND_PCM_STATE_SETUP, 149 SND_PCM_STATE_PREPARED, 150 SND_PCM_STATE_RUNNING, 151 SND_PCM_STATE_XRUN, 152 SND_PCM_STATE_DRAINING, 153 SND_PCM_STATE_PAUSED, 154 SND_PCM_STATE_SUSPENDED, 155 SND_PCM_STATE_DISCONNECTED, 156 SND_PCM_STATE_LAST = SND_PCM_STATE_DISCONNECTED 157 } 158 159 struct snd_pcm_chmap_query_t { 160 //enum snd_pcm_chmap_type; 161 //snd_pcm_chmap_type type; 162 int type; // C enum 163 snd_pcm_chmap_t map; 164 } 165 166 struct snd_pcm_channel_area_t { 167 void* addr; 168 uint first; 169 uint step; 170 } 171 172 struct snd_pcm_format_mask_t; 173 struct snd_pcm_info_t; 174 struct snd_pcm_hw_params_t; 175 struct snd_pcm_sw_params_t; 176 enum { 177 SND_CHMAP_UNKNOWN = 0, 178 SND_CHMAP_NA, 179 SND_CHMAP_MONO, 180 SND_CHMAP_FL, 181 SND_CHMAP_FR, 182 SND_CHMAP_RL, 183 SND_CHMAP_RR, 184 SND_CHMAP_FC, 185 SND_CHMAP_LFE, 186 SND_CHMAP_SL, 187 SND_CHMAP_SR, 188 SND_CHMAP_RC, 189 SND_CHMAP_FLC, 190 SND_CHMAP_FRC, 191 SND_CHMAP_RLC, 192 SND_CHMAP_RRC, 193 SND_CHMAP_FLW, 194 SND_CHMAP_FRW, 195 SND_CHMAP_FLH, 196 SND_CHMAP_FCH, 197 SND_CHMAP_FRH, 198 SND_CHMAP_TC, 199 SND_CHMAP_TFL, 200 SND_CHMAP_TFR, 201 SND_CHMAP_TFC, 202 SND_CHMAP_TRL, 203 SND_CHMAP_TRR, 204 SND_CHMAP_TRC, 205 SND_CHMAP_TFLC, 206 SND_CHMAP_TFRC, 207 SND_CHMAP_TSL, 208 SND_CHMAP_TSR, 209 SND_CHMAP_LLFE, 210 SND_CHMAP_RLFE, 211 SND_CHMAP_BC, 212 SND_CHMAP_BLC, 213 SND_CHMAP_BRC, 214 SND_CHMAP_LAST = SND_CHMAP_BRC, 215 } 216 217 enum { 218 SND_PCM_FORMAT_UNKNOWN = -1, 219 SND_PCM_FORMAT_S8 = 0, 220 SND_PCM_FORMAT_U8, 221 SND_PCM_FORMAT_S16_LE, 222 SND_PCM_FORMAT_S16_BE, 223 SND_PCM_FORMAT_U16_LE, 224 SND_PCM_FORMAT_U16_BE, 225 SND_PCM_FORMAT_S24_LE, 226 SND_PCM_FORMAT_S24_BE, 227 SND_PCM_FORMAT_U24_LE, 228 SND_PCM_FORMAT_U24_BE, 229 SND_PCM_FORMAT_S32_LE, 230 SND_PCM_FORMAT_S32_BE, 231 SND_PCM_FORMAT_U32_LE, 232 SND_PCM_FORMAT_U32_BE, 233 SND_PCM_FORMAT_FLOAT_LE, 234 SND_PCM_FORMAT_FLOAT_BE, 235 SND_PCM_FORMAT_FLOAT64_LE, 236 SND_PCM_FORMAT_FLOAT64_BE, 237 SND_PCM_FORMAT_IEC958_SUBFRAME_LE, 238 SND_PCM_FORMAT_IEC958_SUBFRAME_BE, 239 SND_PCM_FORMAT_MU_LAW, 240 SND_PCM_FORMAT_A_LAW, 241 SND_PCM_FORMAT_IMA_ADPCM, 242 SND_PCM_FORMAT_MPEG, 243 SND_PCM_FORMAT_GSM, 244 SND_PCM_FORMAT_SPECIAL = 31, 245 SND_PCM_FORMAT_S24_3LE = 32, 246 SND_PCM_FORMAT_S24_3BE, 247 SND_PCM_FORMAT_U24_3LE, 248 SND_PCM_FORMAT_U24_3BE, 249 SND_PCM_FORMAT_S20_3LE, 250 SND_PCM_FORMAT_S20_3BE, 251 SND_PCM_FORMAT_U20_3LE, 252 SND_PCM_FORMAT_U20_3BE, 253 SND_PCM_FORMAT_S18_3LE, 254 SND_PCM_FORMAT_S18_3BE, 255 SND_PCM_FORMAT_U18_3LE, 256 SND_PCM_FORMAT_U18_3BE, 257 SND_PCM_FORMAT_G723_24, 258 SND_PCM_FORMAT_G723_24_1B, 259 SND_PCM_FORMAT_G723_40, 260 SND_PCM_FORMAT_G723_40_1B, 261 SND_PCM_FORMAT_DSD_U8, 262 SND_PCM_FORMAT_DSD_U16_LE, 263 SND_PCM_FORMAT_DSD_U32_LE, 264 SND_PCM_FORMAT_DSD_U16_BE, 265 SND_PCM_FORMAT_DSD_U32_BE, 266 SND_PCM_FORMAT_LAST = SND_PCM_FORMAT_DSD_U32_BE, 267 } 268 version(LittleEndian) { 269 enum { 270 SND_PCM_FORMAT_S16 = SND_PCM_FORMAT_S16_LE, 271 SND_PCM_FORMAT_U16 = SND_PCM_FORMAT_U16_LE, 272 SND_PCM_FORMAT_S24 = SND_PCM_FORMAT_S24_LE, 273 SND_PCM_FORMAT_U24 = SND_PCM_FORMAT_U24_LE, 274 SND_PCM_FORMAT_S32 = SND_PCM_FORMAT_S32_LE, 275 SND_PCM_FORMAT_U32 = SND_PCM_FORMAT_U32_LE, 276 SND_PCM_FORMAT_FLOAT = SND_PCM_FORMAT_FLOAT_LE, 277 SND_PCM_FORMAT_FLOAT64 = SND_PCM_FORMAT_FLOAT64_LE, 278 SND_PCM_FORMAT_IEC958_SUBFRAME = SND_PCM_FORMAT_IEC958_SUBFRAME_LE 279 } 280 } else version(BigEndian) { 281 enum { 282 SND_PCM_FORMAT_S16 = SND_PCM_FORMAT_S16_BE, 283 SND_PCM_FORMAT_U16 = SND_PCM_FORMAT_U16_BE, 284 SND_PCM_FORMAT_S24 = SND_PCM_FORMAT_S24_BE, 285 SND_PCM_FORMAT_U24 = SND_PCM_FORMAT_U24_BE, 286 SND_PCM_FORMAT_S32 = SND_PCM_FORMAT_S32_BE, 287 SND_PCM_FORMAT_U32 = SND_PCM_FORMAT_U32_BE, 288 SND_PCM_FORMAT_FLOAT = SND_PCM_FORMAT_FLOAT_BE, 289 SND_PCM_FORMAT_FLOAT64 = SND_PCM_FORMAT_FLOAT64_BE, 290 SND_PCM_FORMAT_IEC958_SUBFRAME = SND_PCM_FORMAT_IEC958_SUBFRAME_BE 291 } 292 } else { 293 static assert(0, "cannot determine whether to compile for a little endian or big endian target"); 294 }