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