Go to the documentation of this file. 1 #ifndef OALPLUS_AL_API_API_HPP
9 #define OALPLUS_AL_API_API_HPP
19 #define OALPAFP(FUNC) decltype(c_api::FUNC), &c_api::FUNC
25 template <
typename ApiTraits>
29 using api_traits = ApiTraits;
32 using int_type =
typename al_types::int_type;
33 using bool_type =
typename al_types::char_type;
34 using char_type =
typename al_types::char_type;
35 using enum_type =
typename al_types::enum_type;
36 using name_type =
typename al_types::name_type;
37 using size_type =
typename al_types::size_type;
38 using float_type =
typename al_types::float_type;
40 struct derived_func : derived_c_api_function<c_api, api_traits, nothing_t> {
41 using base = derived_c_api_function<c_api, api_traits, nothing_t>;
44 template <
typename Res>
45 constexpr
auto _check(Res&& res)
const noexcept {
46 res.error_code(this->api().
GetError());
47 return std::forward<Res>(res);
51 template <
typename W, W c_api::*F,
typename Signature =
typename W::signature>
54 template <
typename W, W
c_api::*F,
typename RVC,
typename... Params>
55 class func<W, F, RVC(Params...)>
56 :
public wrapped_c_api_function<c_api, api_traits, nothing_t, W, F> {
57 using base = wrapped_c_api_function<c_api, api_traits, nothing_t, W, F>;
60 template <
typename Res>
61 constexpr
auto _check(Res&& res)
const noexcept {
62 res.error_code(this->api().
GetError());
63 return std::forward<Res>(res);
67 template <
typename... Args>
68 constexpr
auto _chkcall(Args&&... args)
const noexcept {
69 return this->_check(this->_call(std::forward<Args>(args)...));
77 constexpr
auto operator()(Params... params)
const noexcept {
78 return this->_chkcall(_conv(params)...)
83 template <
typename ObjTag,
typename W, W c_api::*GenObjects>
84 struct gen_object_func : func<W, GenObjects> {
85 using func<W, GenObjects>::func;
87 constexpr
auto operator()(span<name_type> names)
const noexcept {
88 return this->_chkcall(size_type(names.size()), names.data());
91 constexpr
auto operator()()
const noexcept {
93 return this->_chkcall(1, &n).transformed(
99 gen_object_func<source_tag, OALPAFP(
GenSources)> gen_sources;
102 gen_object_func<buffer_tag, OALPAFP(
GenBuffers)> gen_buffers;
105 gen_object_func<effect_tag, OALPAFP(
GenEffects)> gen_effects;
108 gen_object_func<filter_tag, OALPAFP(
GenFilters)> gen_filters;
112 gen_auxiliary_effect_slots;
114 template <
typename ObjTag,
typename W, W c_api::*DeleteObjects>
115 struct delete_object_func : func<W, DeleteObjects> {
116 using func<W, DeleteObjects>::func;
118 constexpr
auto operator()(span<const name_type> names)
const noexcept {
119 return this->_chkcall(size_type(names.size()), names.data());
125 return this->_chkcall(1, &n);
132 template <
typename Res>
133 auto raii_opt(Res& res) noexcept {
143 delete_object_func<source_tag, OALPAFP(
DeleteSources)> delete_sources;
146 delete_object_func<buffer_tag, OALPAFP(
DeleteBuffers)> delete_buffers;
149 delete_object_func<effect_tag, OALPAFP(
DeleteEffects)> delete_effects;
152 delete_object_func<filter_tag, OALPAFP(
DeleteFilters)> delete_filters;
156 auxiliary_effect_slot_tag,
158 delete_auxiliary_effect_slots;
160 template <
typename ObjTag,
typename W, W c_api::*IsObject>
161 struct is_object_func : func<W, IsObject> {
162 using func<W, IsObject>::func;
165 return this->_chkcall(name_type(name));
170 is_object_func<source_tag, OALPAFP(
IsSource)> is_source;
173 is_object_func<buffer_tag, OALPAFP(
IsBuffer)> is_buffer;
176 is_object_func<effect_tag, OALPAFP(
IsEffect)> is_effect;
179 is_object_func<filter_tag, OALPAFP(
IsFilter)> is_filter;
183 is_auxiliary_effect_slot;
186 struct : derived_func {
187 using derived_func::derived_func;
189 explicit constexpr
operator bool()
const noexcept {
197 this->_call(this->api().
Listeneri, enum_type(attr), v0));
200 constexpr
auto operator()(
204 int_type v2)
const noexcept {
206 this->_call(this->api().
Listener3i, enum_type(attr), v0, v1, v2));
209 constexpr
auto operator()(
211 span<const int_type> v)
const noexcept {
213 this->_call(this->api().
Listeneriv, enum_type(attr), v.data()));
218 struct : derived_func {
219 using derived_func::derived_func;
221 explicit constexpr
operator bool()
const noexcept {
229 this->_call(this->api().
Listenerf, enum_type(attr), v0));
232 constexpr
auto operator()(
236 float_type v2)
const noexcept {
238 this->_call(this->api().
Listener3f, enum_type(attr), v0, v1, v2));
241 constexpr
auto operator()(
243 span<const float_type> v)
const noexcept {
245 this->_call(this->api().
Listenerfv, enum_type(attr), v.data()));
255 return this->_chkcall(enum_type(attr), v.data());
265 return this->_chkcall(enum_type(attr), v.data());
270 struct : derived_func {
271 using derived_func::derived_func;
273 explicit constexpr
operator bool()
const noexcept {
278 constexpr
auto operator()(
281 int_type v0)
const noexcept {
282 return this->_check(this->_call(
283 this->api().
Bufferi, name_type(src), enum_type(attr), v0));
286 constexpr
auto operator()(
291 int_type v2)
const noexcept {
292 return this->_check(this->_call(
301 constexpr
auto operator()(
304 span<const int_type> v)
const noexcept {
305 return this->_check(this->_call(
306 this->api().
Bufferiv, name_type(src), enum_type(attr), v.data()));
311 struct : derived_func {
312 using derived_func::derived_func;
314 explicit constexpr
operator bool()
const noexcept {
319 constexpr
auto operator()(
322 float_type v0)
const noexcept {
323 return this->_check(this->_call(
324 this->api().
Bufferf, name_type(src), enum_type(attr), v0));
327 constexpr
auto operator()(
332 float_type v2)
const noexcept {
333 return this->_check(this->_call(
342 constexpr
auto operator()(
345 span<const float_type> v)
const noexcept {
346 return this->_check(this->_call(
347 this->api().
Bufferfv, name_type(src), enum_type(attr), v.data()));
355 constexpr
auto operator()(
358 span<int_type> v)
const noexcept {
359 return this->_chkcall(name_type(src), enum_type(attr), v.data());
367 constexpr
auto operator()(
370 span<float_type> v)
const noexcept {
371 return this->_chkcall(name_type(src), enum_type(attr), v.data());
376 struct : derived_func {
377 using derived_func::derived_func;
379 explicit constexpr
operator bool()
const noexcept {
384 constexpr
auto operator()(
387 int_type v0)
const noexcept {
388 return this->_check(this->_call(
389 this->api().
Sourcei, name_type(src), enum_type(attr), v0));
392 constexpr
auto operator()(
397 int_type v2)
const noexcept {
398 return this->_check(this->_call(
407 constexpr
auto operator()(
410 span<const int_type> v)
const noexcept {
411 return this->_check(this->_call(
412 this->api().
Sourceiv, name_type(src), enum_type(attr), v.data()));
417 struct : derived_func {
418 using derived_func::derived_func;
420 explicit constexpr
operator bool()
const noexcept {
425 constexpr
auto operator()(
428 float_type v0)
const noexcept {
429 return this->_check(this->_call(
430 this->api().
Sourcef, name_type(src), enum_type(attr), v0));
433 constexpr
auto operator()(
438 float_type v2)
const noexcept {
439 return this->_check(this->_call(
448 constexpr
auto operator()(
451 span<const float_type> v)
const noexcept {
452 return this->_check(this->_call(
453 this->api().
Sourcefv, name_type(src), enum_type(attr), v.data()));
461 constexpr
auto operator()(
464 span<int_type> v)
const noexcept {
465 return this->_chkcall(name_type(src), enum_type(attr), v.data());
473 constexpr
auto operator()(
476 span<float_type> v)
const noexcept {
477 return this->_chkcall(name_type(src), enum_type(attr), v.data());
487 const auto n = name_type(buf);
488 return this->_chkcall(name_type(src), 1, &n);
492 operator()(
source_name src, span<const name_type> bufs)
const noexcept {
493 return this->_chkcall(
494 name_type(src), size_type(bufs.size()), bufs.data());
496 } source_queue_buffers;
504 auto n = name_type(buf);
505 return this->_chkcall(name_type(src), 1, &n);
509 operator()(
source_name src, span<name_type> bufs)
const noexcept {
510 return this->_chkcall(
511 name_type(src), size_type(bufs.size()), bufs.data());
513 } source_unqueue_buffers;
516 struct : derived_func {
517 using derived_func::derived_func;
519 explicit constexpr
operator bool()
const noexcept {
524 constexpr
auto operator()(
source_name src)
const noexcept {
526 this->_call(this->api().
SourcePlay, name_type(src)));
529 constexpr
auto operator()(span<const name_type> srcs)
const noexcept {
530 return this->_check(this->_call(
531 this->api().
SourcePlayv, size_type(srcs.size()), srcs.data()));
536 struct : derived_func {
537 using derived_func::derived_func;
539 explicit constexpr
operator bool()
const noexcept {
544 constexpr
auto operator()(
source_name src)
const noexcept {
546 this->_call(this->api().
SourcePause, name_type(src)));
549 constexpr
auto operator()(span<const name_type> srcs)
const noexcept {
550 return this->_check(this->_call(
551 this->api().
SourcePausev, size_type(srcs.size()), srcs.data()));
556 struct : derived_func {
557 using derived_func::derived_func;
559 explicit constexpr
operator bool()
const noexcept {
564 constexpr
auto operator()(
source_name src)
const noexcept {
566 this->_call(this->api().
SourceStop, name_type(src)));
569 constexpr
auto operator()(span<const name_type> srcs)
const noexcept {
570 return this->_check(this->_call(
571 this->api().
SourceStopv, size_type(srcs.size()), srcs.data()));
576 struct : derived_func {
577 using derived_func::derived_func;
579 explicit constexpr
operator bool()
const noexcept {
584 constexpr
auto operator()(
source_name src)
const noexcept {
589 constexpr
auto operator()(span<const name_type> srcs)
const noexcept {
590 return this->_check(this->_call(
591 this->api().
SourceRewindv, size_type(srcs.size()), srcs.data()));
600 return this->_chkcall(enum_type(query))
604 constexpr
auto operator()()
const noexcept {
605 return this->_fake_empty_c_str().cast_to(
612 return get_string(query).transformed([separator](
auto src) {
613 return split_into_string_list(src, separator);
618 auto get_extensions() noexcept {
625 [](
auto src) {
return split_into_string_list(src,
' '); });
635 #endif // OALPLUS_AL_API_API_HPP
al_api_function< void(name_type, enum_type, const float_type *), nullptr > Sourcefv
Definition: c_api.hpp:396
al_api_function< void(name_type), nullptr > SourceRewind
Definition: c_api.hpp:418
al_api_function< void(name_type, enum_type, int_type *), nullptr > GetBufferiv
Definition: c_api.hpp:300
al_api_function< void(enum_type, const int_type *), nullptr > Listeneriv
Definition: c_api.hpp:211
al_api_function< void(name_type, enum_type, float_type *), nullptr > GetBufferfv
Definition: c_api.hpp:328
auto release() noexcept -> Handle
Releases the underlying handle value.
Definition: handle.hpp:134
al_api_function< void(enum_type, const float_type *), nullptr > Listenerfv
Definition: c_api.hpp:239
al_api_function< void(size_type, name_type *), nullptr > GenSources
Definition: c_api.hpp:335
al_api_function< void(name_type, enum_type, const float_type *), nullptr > Bufferfv
Definition: c_api.hpp:321
static constexpr auto extract(api_result_value< Result, api_result_validity::never > &) noexcept -> Result &
Overload of extract for api_result_value.
Definition: c_api_wrap.hpp:270
al_api_function< void(size_type, const name_type *), nullptr > SourcePausev
Definition: c_api.hpp:451
Typed enumeration for AL string query constants.
Definition: enum_types.hpp:50
al_api_function< void(size_type, const name_type *), nullptr > DeleteEffects
Definition: c_api.hpp:473
Typed enumeration for AL listener attribute constants.
Definition: enum_types.hpp:62
al_api_function< void(size_type, name_type *), nullptr > GenBuffers
Definition: c_api.hpp:253
Non-owning wrapper for C-API opaque handle types.
Definition: handle.hpp:26
al_api_function< void(name_type), nullptr > SourceStop
Definition: c_api.hpp:413
al_api_function< void(size_type, name_type *), nullptr > GenEffects
Definition: c_api.hpp:469
al_api_function< void(name_type, enum_type, int_type, int_type, int_type), nullptr > Source3i
Definition: c_api.hpp:361
Class wrapping the functions from the AL API.
Definition: api.hpp:26
al_api_function< bool_type(name_type), nullptr > IsAuxiliaryEffectSlot
Definition: c_api.hpp:573
al_api_function< enum_type(), nullptr > GetError
Definition: c_api.hpp:95
al_api_function< void(enum_type, float_type), nullptr > Listenerf
Definition: c_api.hpp:225
static auto finally(Func func) -> func_on_scope_exit< Func >
Function constructing on-scope-exit actions.
Definition: scope_exit.hpp:144
al_api_function< void(size_type, const name_type *), nullptr > SourceRewindv
Definition: c_api.hpp:444
al_api_function< void(enum_type, float_type *), nullptr > GetListenerfv
Definition: c_api.hpp:246
al_api_function< void(name_type, enum_type, float_type, float_type, float_type), nullptr > Source3f
Definition: c_api.hpp:389
al_api_function< void(name_type), nullptr > SourcePlay
Definition: c_api.hpp:408
al_api_function< void(size_type, name_type *), nullptr > GenFilters
Definition: c_api.hpp:516
al_api_function< void(enum_type, int_type), nullptr > Listeneri
Definition: c_api.hpp:197
al_api_function< void(enum_type, int_type *), nullptr > GetListeneriv
Definition: c_api.hpp:218
al_api_function< const char_type *(enum_type), nullptr > GetString
Definition: c_api.hpp:177
al_api_function< void(size_type, name_type *), nullptr > GenAuxiliaryEffectSlots
Definition: c_api.hpp:564
al_api_function< void(enum_type, float_type, float_type, float_type), nullptr > Listener3f
Definition: c_api.hpp:232
al_api_function< void(size_type, const name_type *), nullptr > DeleteSources
Definition: c_api.hpp:342
al_api_function< bool_type(name_type), nullptr > IsFilter
Definition: c_api.hpp:524
al_api_function< void(size_type, const name_type *), nullptr > DeleteFilters
Definition: c_api.hpp:520
Typed enumeration for AL buffer attribute constants.
Definition: enum_types.hpp:69
Typed enumeration for AL source attribute constants.
Definition: enum_types.hpp:82
al_api_function< bool_type(name_type), nullptr > IsEffect
Definition: c_api.hpp:477
al_api_function< void(size_type, const name_type *), nullptr > SourcePlayv
Definition: c_api.hpp:430
al_api_function< bool_type(name_type), nullptr > IsBuffer
Definition: c_api.hpp:265
al_api_function< void(name_type, enum_type, const int_type *), nullptr > Sourceiv
Definition: c_api.hpp:368
al_api_function< void(enum_type, int_type, int_type, int_type), nullptr > Listener3i
Definition: c_api.hpp:204
al_api_function< void(name_type, size_type, const name_type *), nullptr > SourceQueueBuffers
Definition: c_api.hpp:458
Owning wrapper for C-API opaque handle types.
Definition: handle.hpp:98
al_api_function< void(name_type, size_type, name_type *), nullptr > SourceUnqueueBuffers
Definition: c_api.hpp:465
Template type used mostly for function type-tag dispatching.
Definition: type_identity.hpp:19
al_api_function< void(name_type, enum_type, float_type), nullptr > Sourcef
Definition: c_api.hpp:382
al_api_function< void(name_type, enum_type, int_type *), nullptr > GetSourceiv
Definition: c_api.hpp:375
AL-related code is placed in this namespace.
Definition: oalplus.hpp:11
al_api_function< void(name_type, enum_type, float_type, float_type, float_type), nullptr > Buffer3f
Definition: c_api.hpp:314
al_api_function< void(size_type, const name_type *), nullptr > SourceStopv
Definition: c_api.hpp:437
al_api_function< void(name_type, enum_type, int_type), nullptr > Sourcei
Definition: c_api.hpp:354
al_api_function< void(name_type, enum_type, int_type, int_type, int_type), nullptr > Buffer3i
Definition: c_api.hpp:286
al_api_function< void(name_type, enum_type, float_type *), nullptr > GetSourcefv
Definition: c_api.hpp:403
al_api_function< void(name_type), nullptr > SourcePause
Definition: c_api.hpp:423
al_api_function< bool_type(name_type), nullptr > IsSource
Definition: c_api.hpp:347
al_api_function< void(size_type, const name_type *), nullptr > DeleteBuffers
Definition: c_api.hpp:260
al_api_function< void(name_type, enum_type, int_type), nullptr > Bufferi
Definition: c_api.hpp:279
al_api_function< void(name_type, enum_type, const int_type *), nullptr > Bufferiv
Definition: c_api.hpp:293
Class wrapping the C-functions from the AL API.
Definition: c_api.hpp:31
al_api_function< void(name_type, enum_type, float_type), nullptr > Bufferf
Definition: c_api.hpp:307
al_api_function< void(size_type, const name_type *), nullptr > DeleteAuxiliaryEffectSlots
Definition: c_api.hpp:569