3#include <ossia/detail/config.hpp>
5#include <ossia/detail/dylib_loader.hpp>
7#include <alsa/asoundlib.h>
13#define snd_alloca(ptr, lib, type) \
16 *ptr = (snd_##type##_t*)alloca(lib.type##_sizeof()); \
17 memset(*ptr, 0, lib.type##_sizeof()); \
23 decltype(&::snd_pcm_open) pcm_open{};
24 decltype(&::snd_pcm_avail_update) pcm_avail_update{};
25 decltype(&::snd_pcm_drop) pcm_drop{};
26 decltype(&::snd_pcm_link) pcm_link{};
27 decltype(&::snd_pcm_poll_descriptors) pcm_poll_descriptors{};
28 decltype(&::snd_pcm_poll_descriptors_revents) pcm_poll_descriptors_revents{};
29 decltype(&::snd_pcm_poll_descriptors_count) pcm_poll_descriptors_count{};
30 decltype(&::snd_pcm_mmap_begin) pcm_mmap_begin{};
31 decltype(&::snd_pcm_mmap_commit) pcm_mmap_commit{};
32 decltype(&::snd_pcm_format_name) pcm_format_name{};
33 decltype(&::snd_pcm_status) pcm_status{};
34 decltype(&::snd_pcm_status_sizeof) pcm_status_sizeof{};
35 decltype(&::snd_pcm_status_get_state) pcm_status_get_state{};
36 decltype(&::snd_pcm_status_get_tstamp) pcm_status_get_tstamp{};
37 decltype(&::snd_pcm_status_get_trigger_tstamp) pcm_status_get_trigger_tstamp{};
38 decltype(&::snd_pcm_hw_params_malloc) pcm_hw_params_malloc{};
39 decltype(&::snd_pcm_hw_params_get_access) pcm_hw_params_get_access{};
40 decltype(&::snd_pcm_hw_params_set_periods_min) pcm_hw_params_set_periods_min{};
41 decltype(&::snd_pcm_hw_params_set_rate) pcm_hw_params_set_rate{};
42 decltype(&::snd_pcm_hw_params_set_period_size_near) pcm_hw_params_set_period_size_near{};
43 decltype(&::snd_ctl_open) ctl_open{};
44 decltype(&::snd_ctl_close) ctl_close{};
45 decltype(&::snd_ctl_card_info) ctl_card_info{};
46 decltype(&::snd_ctl_card_info_sizeof) ctl_card_info_sizeof{};
47 decltype(&::snd_pcm_hw_params_any) pcm_hw_params_any{};
48 decltype(&::snd_pcm_hw_params_sizeof) pcm_hw_params_sizeof{};
49 decltype(&::snd_pcm_hw_params_set_access) pcm_hw_params_set_access{};
50 decltype(&::snd_pcm_hw_params_get_format) pcm_hw_params_get_format{};
51 decltype(&::snd_pcm_hw_params_set_format) pcm_hw_params_set_format{};
52 decltype(&::snd_pcm_hw_params_set_channels) pcm_hw_params_set_channels{};
53 decltype(&::snd_pcm_hw_params_set_period_size) pcm_hw_params_set_period_size{};
54 decltype(&::snd_pcm_hw_params_set_buffer_size) pcm_hw_params_set_buffer_size{};
55 decltype(&::snd_pcm_hw_params_set_periods) pcm_hw_params_set_periods{};
56 decltype(&::snd_pcm_hw_params_set_periods_near) pcm_hw_params_set_periods_near{};
57 decltype(&::snd_pcm_hw_params_set_periods_integer) pcm_hw_params_set_periods_integer{};
58 decltype(&::snd_pcm_hw_params_set_rate_near) pcm_hw_params_set_rate_near{};
59 decltype(&::snd_pcm_hw_params_get_channels) pcm_hw_params_get_channels{};
60 decltype(&::snd_pcm_hw_params_get_channels_min) pcm_hw_params_get_channels_min{};
61 decltype(&::snd_pcm_hw_params_get_channels_max) pcm_hw_params_get_channels_max{};
62 decltype(&::snd_pcm_hw_params_get_rate) pcm_hw_params_get_rate{};
63 decltype(&::snd_pcm_hw_params_get_rate_min) pcm_hw_params_get_rate_min{};
64 decltype(&::snd_pcm_hw_params_get_rate_max) pcm_hw_params_get_rate_max{};
65 decltype(&::snd_pcm_hw_params_get_buffer_size) pcm_hw_params_get_buffer_size{};
66 decltype(&::snd_pcm_hw_params_get_buffer_size_min) pcm_hw_params_get_buffer_size_min{};
67 decltype(&::snd_pcm_hw_params_get_buffer_size_max) pcm_hw_params_get_buffer_size_max{};
68 decltype(&::snd_pcm_hw_params_get_period_size) pcm_hw_params_get_period_size{};
69 decltype(&::snd_pcm_hw_params_get_period_size_min) pcm_hw_params_get_period_size_min{};
70 decltype(&::snd_pcm_hw_params_get_period_size_max) pcm_hw_params_get_period_size_max{};
71 decltype(&::snd_pcm_hw_params_get_periods) pcm_hw_params_get_periods{};
72 decltype(&::snd_pcm_hw_params) pcm_hw_params{};
73 decltype(&::snd_pcm_hw_params_free) pcm_hw_params_free{};
74 decltype(&::snd_pcm_sw_params_malloc) pcm_sw_params_malloc{};
75 decltype(&::snd_pcm_sw_params_current) pcm_sw_params_current{};
76 decltype(&::snd_pcm_sw_params_sizeof) pcm_sw_params_sizeof{};
77 decltype(&::snd_pcm_sw_params_set_start_threshold) pcm_sw_params_set_start_threshold{};
78 decltype(&::snd_pcm_sw_params_set_avail_min) pcm_sw_params_set_avail_min{};
79 decltype(&::snd_pcm_sw_params_set_tstamp_mode) pcm_sw_params_set_tstamp_mode{};
80 decltype(&::snd_pcm_sw_params) pcm_sw_params{};
81 decltype(&::snd_pcm_sw_params_free) pcm_sw_params_free{};
82 decltype(&::snd_pcm_name) pcm_name{};
83 decltype(&::snd_pcm_state) pcm_state{};
84 decltype(&::snd_pcm_state_name) pcm_state_name{};
85 decltype(&::snd_pcm_writei) pcm_writei{};
86 decltype(&::snd_pcm_writen) pcm_writen{};
87 decltype(&::snd_pcm_prepare) pcm_prepare{};
88 decltype(&::snd_pcm_start) pcm_start{};
89 decltype(&::snd_pcm_recover) pcm_recover{};
90 decltype(&::snd_pcm_drain) pcm_drain{};
91 decltype(&::snd_pcm_close) pcm_close{};
92 decltype(&::snd_pcm_wait) pcm_wait{};
93 decltype(&::snd_strerror) strerror{};
94 decltype(&::snd_device_name_hint) device_name_hint{};
95 decltype(&::snd_device_name_get_hint) device_name_get_hint{};
96 decltype(&::snd_device_name_free_hint) device_name_free_hint{};
99 static const libasound& instance()
101 static const libasound self;
106 dylib_loader library;
109 : library(
"libasound.so.2")
114 pcm_open = library.symbol<
decltype(&::snd_pcm_open)>(
"snd_pcm_open");
116 = library.symbol<
decltype(&::snd_pcm_avail_update)>(
"snd_pcm_avail_update");
117 pcm_drop = library.symbol<
decltype(&::snd_pcm_drop)>(
"snd_pcm_drop");
118 pcm_link = library.symbol<
decltype(&::snd_pcm_link)>(
"snd_pcm_link");
119 pcm_poll_descriptors = library.symbol<
decltype(&::snd_pcm_poll_descriptors)>(
120 "snd_pcm_poll_descriptors");
121 pcm_poll_descriptors_revents
122 = library.symbol<
decltype(&::snd_pcm_poll_descriptors_revents)>(
123 "snd_pcm_poll_descriptors_revents");
124 pcm_poll_descriptors_count
125 = library.symbol<
decltype(&::snd_pcm_poll_descriptors_count)>(
126 "snd_pcm_poll_descriptors_count");
128 = library.symbol<
decltype(&::snd_pcm_mmap_begin)>(
"snd_pcm_mmap_begin");
130 = library.symbol<
decltype(&::snd_pcm_mmap_commit)>(
"snd_pcm_mmap_commit");
132 = library.symbol<
decltype(&::snd_pcm_format_name)>(
"snd_pcm_format_name");
133 pcm_status = library.symbol<
decltype(&::snd_pcm_status)>(
"snd_pcm_status");
135 = library.symbol<
decltype(&::snd_pcm_status_sizeof)>(
"snd_pcm_status_sizeof");
136 pcm_status_get_state = library.symbol<
decltype(&::snd_pcm_status_get_state)>(
137 "snd_pcm_status_get_state");
138 pcm_status_get_tstamp = library.symbol<
decltype(&::snd_pcm_status_get_tstamp)>(
139 "snd_pcm_status_get_tstamp");
140 pcm_status_get_trigger_tstamp
141 = library.symbol<
decltype(&::snd_pcm_status_get_trigger_tstamp)>(
142 "snd_pcm_status_get_trigger_tstamp");
143 pcm_hw_params_malloc = library.symbol<
decltype(&::snd_pcm_hw_params_malloc)>(
144 "snd_pcm_hw_params_malloc");
145 pcm_hw_params_get_access = library.symbol<
decltype(&::snd_pcm_hw_params_get_access)>(
146 "snd_pcm_hw_params_get_access");
147 pcm_hw_params_set_periods_min
148 = library.symbol<
decltype(&::snd_pcm_hw_params_set_periods_min)>(
149 "snd_pcm_hw_params_set_periods_min");
150 pcm_hw_params_set_rate = library.symbol<
decltype(&::snd_pcm_hw_params_set_rate)>(
151 "snd_pcm_hw_params_set_rate");
152 pcm_hw_params_set_period_size_near
153 = library.symbol<
decltype(&::snd_pcm_hw_params_set_period_size_near)>(
154 "snd_pcm_hw_params_set_period_size_near");
155 ctl_open = library.symbol<
decltype(&::snd_ctl_open)>(
"snd_ctl_open");
156 ctl_close = library.symbol<
decltype(&::snd_ctl_close)>(
"snd_ctl_close");
157 ctl_card_info = library.symbol<
decltype(&::snd_ctl_card_info)>(
"snd_ctl_card_info");
158 ctl_card_info_sizeof = library.symbol<
decltype(&::snd_ctl_card_info_sizeof)>(
159 "snd_ctl_card_info_sizeof");
161 = library.symbol<
decltype(&::snd_pcm_hw_params_any)>(
"snd_pcm_hw_params_any");
162 pcm_hw_params_sizeof = library.symbol<
decltype(&::snd_pcm_hw_params_sizeof)>(
163 "snd_pcm_hw_params_sizeof");
164 pcm_hw_params_set_access = library.symbol<
decltype(&::snd_pcm_hw_params_set_access)>(
165 "snd_pcm_hw_params_set_access");
166 pcm_hw_params_get_format = library.symbol<
decltype(&::snd_pcm_hw_params_get_format)>(
167 "snd_pcm_hw_params_get_format");
168 pcm_hw_params_set_format = library.symbol<
decltype(&::snd_pcm_hw_params_set_format)>(
169 "snd_pcm_hw_params_set_format");
170 pcm_hw_params_set_channels
171 = library.symbol<
decltype(&::snd_pcm_hw_params_set_channels)>(
172 "snd_pcm_hw_params_set_channels");
173 pcm_hw_params_set_period_size
174 = library.symbol<
decltype(&::snd_pcm_hw_params_set_period_size)>(
175 "snd_pcm_hw_params_set_period_size");
176 pcm_hw_params_set_buffer_size
177 = library.symbol<
decltype(&::snd_pcm_hw_params_set_buffer_size)>(
178 "snd_pcm_hw_params_set_buffer_size");
179 pcm_hw_params_set_periods
180 = library.symbol<
decltype(&::snd_pcm_hw_params_set_periods)>(
181 "snd_pcm_hw_params_set_periods");
182 pcm_hw_params_set_periods_near
183 = library.symbol<
decltype(&::snd_pcm_hw_params_set_periods_near)>(
184 "snd_pcm_hw_params_set_periods_near");
185 pcm_hw_params_set_periods_integer
186 = library.symbol<
decltype(&::snd_pcm_hw_params_set_periods_integer)>(
187 "snd_pcm_hw_params_set_periods_integer");
188 pcm_hw_params_set_rate_near
189 = library.symbol<
decltype(&::snd_pcm_hw_params_set_rate_near)>(
190 "snd_pcm_hw_params_set_rate_near");
191 pcm_hw_params_get_channels
192 = library.symbol<
decltype(&::snd_pcm_hw_params_get_channels)>(
193 "snd_pcm_hw_params_get_channels");
194 pcm_hw_params_get_channels_min
195 = library.symbol<
decltype(&::snd_pcm_hw_params_get_channels_min)>(
196 "snd_pcm_hw_params_get_channels_min");
197 pcm_hw_params_get_channels_max
198 = library.symbol<
decltype(&::snd_pcm_hw_params_get_channels_max)>(
199 "snd_pcm_hw_params_get_channels_max");
200 pcm_hw_params_get_rate = library.symbol<
decltype(&::snd_pcm_hw_params_get_rate)>(
201 "snd_pcm_hw_params_get_rate");
202 pcm_hw_params_get_rate_min
203 = library.symbol<
decltype(&::snd_pcm_hw_params_get_rate_min)>(
204 "snd_pcm_hw_params_get_rate_min");
205 pcm_hw_params_get_rate_max
206 = library.symbol<
decltype(&::snd_pcm_hw_params_get_rate_max)>(
207 "snd_pcm_hw_params_get_rate_max");
208 pcm_hw_params_get_buffer_size
209 = library.symbol<
decltype(&::snd_pcm_hw_params_get_buffer_size)>(
210 "snd_pcm_hw_params_get_buffer_size");
211 pcm_hw_params_get_buffer_size_min
212 = library.symbol<
decltype(&::snd_pcm_hw_params_get_buffer_size_min)>(
213 "snd_pcm_hw_params_get_buffer_size_min");
214 pcm_hw_params_get_buffer_size_max
215 = library.symbol<
decltype(&::snd_pcm_hw_params_get_buffer_size_max)>(
216 "snd_pcm_hw_params_get_buffer_size_max");
217 pcm_hw_params_get_period_size
218 = library.symbol<
decltype(&::snd_pcm_hw_params_get_period_size)>(
219 "snd_pcm_hw_params_get_period_size");
220 pcm_hw_params_get_period_size_min
221 = library.symbol<
decltype(&::snd_pcm_hw_params_get_period_size_min)>(
222 "snd_pcm_hw_params_get_period_size_min");
223 pcm_hw_params_get_period_size_max
224 = library.symbol<
decltype(&::snd_pcm_hw_params_get_period_size_max)>(
225 "snd_pcm_hw_params_get_period_size_max");
226 pcm_hw_params_get_periods
227 = library.symbol<
decltype(&::snd_pcm_hw_params_get_periods)>(
228 "snd_pcm_hw_params_get_periods");
229 pcm_hw_params = library.symbol<
decltype(&::snd_pcm_hw_params)>(
"snd_pcm_hw_params");
231 = library.symbol<
decltype(&::snd_pcm_hw_params_free)>(
"snd_pcm_hw_params_free");
232 pcm_sw_params_malloc = library.symbol<
decltype(&::snd_pcm_sw_params_malloc)>(
233 "snd_pcm_sw_params_malloc");
234 pcm_sw_params_current = library.symbol<
decltype(&::snd_pcm_sw_params_current)>(
235 "snd_pcm_sw_params_current");
236 pcm_sw_params_sizeof = library.symbol<
decltype(&::snd_pcm_sw_params_sizeof)>(
237 "snd_pcm_sw_params_sizeof");
238 pcm_sw_params_set_start_threshold
239 = library.symbol<
decltype(&::snd_pcm_sw_params_set_start_threshold)>(
240 "snd_pcm_sw_params_set_start_threshold");
241 pcm_sw_params_set_avail_min
242 = library.symbol<
decltype(&::snd_pcm_sw_params_set_avail_min)>(
243 "snd_pcm_sw_params_set_avail_min");
244 pcm_sw_params_set_tstamp_mode
245 = library.symbol<
decltype(&::snd_pcm_sw_params_set_tstamp_mode)>(
246 "snd_pcm_sw_params_set_tstamp_mode");
247 pcm_sw_params = library.symbol<
decltype(&::snd_pcm_sw_params)>(
"snd_pcm_sw_params");
249 = library.symbol<
decltype(&::snd_pcm_sw_params_free)>(
"snd_pcm_sw_params_free");
250 pcm_name = library.symbol<
decltype(&::snd_pcm_name)>(
"snd_pcm_name");
251 pcm_state = library.symbol<
decltype(&::snd_pcm_state)>(
"snd_pcm_state");
253 = library.symbol<
decltype(&::snd_pcm_state_name)>(
"snd_pcm_state_name");
254 pcm_writei = library.symbol<
decltype(&::snd_pcm_writei)>(
"snd_pcm_writei");
255 pcm_writen = library.symbol<
decltype(&::snd_pcm_writen)>(
"snd_pcm_writen");
256 pcm_prepare = library.symbol<
decltype(&::snd_pcm_prepare)>(
"snd_pcm_prepare");
257 pcm_start = library.symbol<
decltype(&::snd_pcm_start)>(
"snd_pcm_start");
258 pcm_recover = library.symbol<
decltype(&::snd_pcm_recover)>(
"snd_pcm_recover");
259 pcm_drain = library.symbol<
decltype(&::snd_pcm_drain)>(
"snd_pcm_drain");
260 pcm_close = library.symbol<
decltype(&::snd_pcm_close)>(
"snd_pcm_close");
261 pcm_wait = library.symbol<
decltype(&::snd_pcm_wait)>(
"snd_pcm_wait");
262 strerror = library.symbol<
decltype(&::snd_strerror)>(
"snd_strerror");
264 = library.symbol<
decltype(&::snd_device_name_hint)>(
"snd_device_name_hint");
265 device_name_get_hint = library.symbol<
decltype(&::snd_device_name_get_hint)>(
266 "snd_device_name_get_hint");
267 device_name_free_hint = library.symbol<
decltype(&::snd_device_name_free_hint)>(
268 "snd_device_name_free_hint");
273 assert(snd_pcm_open);
274 assert(snd_pcm_avail_update);
275 assert(snd_pcm_drop);
276 assert(snd_pcm_link);
277 assert(snd_pcm_poll_descriptors);
278 assert(snd_pcm_poll_descriptors_revents);
279 assert(snd_pcm_poll_descriptors_count);
280 assert(snd_pcm_mmap_begin);
281 assert(snd_pcm_mmap_commit);
282 assert(snd_pcm_format_name);
283 assert(snd_pcm_status);
284 assert(snd_pcm_status_sizeof);
285 assert(snd_pcm_status_get_state);
286 assert(snd_pcm_status_get_tstamp);
287 assert(snd_pcm_status_get_trigger_tstamp);
288 assert(snd_pcm_hw_params_malloc);
289 assert(snd_pcm_hw_params_get_access);
290 assert(snd_pcm_hw_params_set_periods_min);
291 assert(snd_pcm_hw_params_set_rate);
292 assert(snd_pcm_hw_params_set_period_size_near);
293 assert(snd_ctl_open);
294 assert(snd_ctl_close);
295 assert(snd_ctl_card_info);
296 assert(snd_ctl_card_info_sizeof);
297 assert(snd_pcm_hw_params_any);
298 assert(snd_pcm_hw_params_sizeof);
299 assert(snd_pcm_hw_params_set_access);
300 assert(snd_pcm_hw_params_get_format);
301 assert(snd_pcm_hw_params_set_format);
302 assert(snd_pcm_hw_params_set_channels);
303 assert(snd_pcm_hw_params_set_period_size);
304 assert(snd_pcm_hw_params_set_buffer_size);
305 assert(snd_pcm_hw_params_set_periods);
306 assert(snd_pcm_hw_params_set_periods_near);
307 assert(snd_pcm_hw_params_set_periods_integer);
308 assert(snd_pcm_hw_params_set_rate_near);
309 assert(snd_pcm_hw_params_get_channels);
310 assert(snd_pcm_hw_params_get_channels_min);
311 assert(snd_pcm_hw_params_get_channels_max);
312 assert(snd_pcm_hw_params_get_rate);
313 assert(snd_pcm_hw_params_get_rate_min);
314 assert(snd_pcm_hw_params_get_rate_max);
315 assert(snd_pcm_hw_params_get_buffer_size);
316 assert(snd_pcm_hw_params_get_buffer_size_min);
317 assert(snd_pcm_hw_params_get_buffer_size_max);
318 assert(snd_pcm_hw_params_get_period_size);
319 assert(snd_pcm_hw_params_get_period_size_min);
320 assert(snd_pcm_hw_params_get_period_size_max);
321 assert(snd_pcm_hw_params_get_periods);
322 assert(snd_pcm_hw_params);
323 assert(snd_pcm_hw_params_free);
324 assert(snd_pcm_sw_params_malloc);
325 assert(snd_pcm_sw_params_current);
326 assert(snd_pcm_sw_params_sizeof);
327 assert(snd_pcm_sw_params_set_start_threshold);
328 assert(snd_pcm_sw_params_set_avail_min);
329 assert(snd_pcm_sw_params_set_tstamp_mode);
330 assert(snd_pcm_sw_params);
331 assert(snd_pcm_sw_params_free);
332 assert(snd_pcm_name);
333 assert(snd_pcm_state);
334 assert(snd_pcm_state_name);
335 assert(snd_pcm_writei);
336 assert(snd_pcm_writen);
337 assert(snd_pcm_prepare);
338 assert(snd_pcm_start);
339 assert(snd_pcm_recover);
340 assert(snd_pcm_drain);
341 assert(snd_pcm_close);
342 assert(snd_pcm_wait);
343 assert(snd_strerror);
344 assert(snd_device_name_hint);
345 assert(snd_device_name_get_hint);
346 assert(snd_device_name_free_hint);