Go to the documentation of this file. 1 #ifndef OALPLUS_ALC_API_API_HPP
9 #define OALPLUS_ALC_API_API_HPP
19 #define OALPAFP(FUNC) decltype(c_api::FUNC), &c_api::FUNC
25 template <
typename ApiTraits>
29 using api_traits = ApiTraits;
34 using enum_type =
typename alc_types::enum_type;
35 using size_type =
typename alc_types::size_type;
36 using char_type =
typename alc_types::char_type;
37 using int_type =
typename alc_types::int_type;
39 template <
typename W, W c_api::*F,
typename Signature =
typename W::signature>
42 template <
typename W, W
c_api::*F,
typename RVC,
typename... Params>
43 class func<W, F, RVC(Params...)>
44 :
public wrapped_c_api_function<c_api, api_traits, nothing_t, W, F> {
45 using base = wrapped_c_api_function<c_api, api_traits, nothing_t, W, F>;
48 template <
typename Res>
49 constexpr
auto _check(device_handle dev, Res&& res)
const noexcept {
50 res.error_code(this->api().
GetError(dev));
51 return std::forward<Res>(res);
55 template <
typename... Args>
57 _chkcall(device_handle dev, Args&&... args)
const noexcept {
58 return this->_check(dev, this->_call(std::forward<Args>(args)...));
66 constexpr
auto operator()(Params... params)
const noexcept {
67 return this->_chkcall(_conv(params)...)
76 constexpr
auto operator()()
const noexcept {
77 return this->_chkcall(
nullptr,
nullptr);
81 return this->_chkcall(
nullptr,
c_str(name));
89 constexpr
auto operator()(device_handle dev)
const noexcept {
90 return this->_chkcall(dev, dev);
93 auto raii(device_handle dev) noexcept {
102 constexpr
auto operator()(device_handle dev)
const noexcept {
103 return this->_chkcall(dev, dev,
nullptr);
106 constexpr
auto operator()(
108 span<const int_type> attributes)
const noexcept {
109 return this->_chkcall(dev, dev, attributes.data());
118 operator()(device_handle dev, context_handle ctx)
const noexcept {
119 return this->_chkcall(dev, ctx);
122 auto raii(device_handle dev, context_handle ctx) noexcept {
132 operator()(device_handle dev, context_handle ctx)
const noexcept {
133 return this->_chkcall(dev, ctx);
136 constexpr
auto operator()(device_handle dev)
const noexcept {
137 return this->_chkcall(dev,
nullptr);
140 constexpr
auto operator()(context_handle ctx)
const noexcept {
141 return this->_chkcall(
nullptr, ctx);
144 constexpr
auto operator()()
const noexcept {
145 return this->_chkcall(
nullptr,
nullptr);
148 auto raii(device_handle dev) noexcept {
152 auto raii() noexcept {
155 } make_context_current;
161 constexpr
auto operator()(device_handle dev)
const noexcept {
162 return this->_chkcall(dev);
165 constexpr
auto operator()()
const noexcept {
166 return this->_chkcall(
nullptr);
168 } get_current_context;
178 ->_chkcall(dev, dev, enum_type(query), size_type(1), &result)
179 .replaced_with(result);
183 return (*
this)(
nullptr, query);
186 constexpr
auto operator()(
189 span<int_type> dst)
const noexcept {
190 return this->_chkcall(
191 dev, dev, enum_type(query), size_type(dst.size()), dst.data());
201 return this->_chkcall(dev, dev, enum_type(query))
206 return (*
this)(
nullptr, query);
209 constexpr
auto operator()(device_handle)
const noexcept {
210 return this->_fake_empty_c_str().cast_to(
219 char separator) noexcept {
220 return get_string(dev, query).transformed([separator](
auto src) {
221 return split_into_string_list(src, separator);
226 auto get_extensions(device_handle dev) noexcept {
227 #ifdef ALC_EXTENSIONS
230 return get_string(dev)
233 [](
auto src) {
return split_into_string_list(src,
' '); });
237 auto get_default_device_specifier() noexcept {
238 #ifdef ALC_DEFAULT_DEVICE_SPECIFIER
242 return get_string(
nullptr);
247 auto get_device_specifiers() noexcept {
248 #ifdef ALC_DEVICE_SPECIFIER
251 return get_string(
nullptr)
254 [](
auto src) {
return split_into_string_list(src,
'\0'); });
258 auto get_capture_default_device_specifier() noexcept {
259 #ifdef ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER
263 return get_string(
nullptr);
268 auto get_capture_device_specifiers() noexcept {
269 #ifdef ALC_CAPTURE_DEVICE_SPECIFIER
273 return get_string(
nullptr)
276 [](
auto src) {
return split_into_string_list(src,
'\0'); });
286 #endif // OALPLUS_ALC_API_API_HPP
alc_api_function< context_type *(device_type *, const int_type *), nullptr > CreateContext
Definition: c_api.hpp:164
static constexpr auto c_str(memory::basic_span< C, P, S > s) -> std::enable_if_t< std::is_convertible_v< memory::basic_span< C, P, S >, basic_string_span< C, P, S >>, basic_c_str< C, P, S >>
Functions that construct a basic_c_str from a basic_string_span.
Definition: string_span.hpp:226
Class wrapping the functions from the ALC API.
Definition: api.hpp:26
Class wrapping the C-functions from the ALC API.
Definition: c_api.hpp:31
Class representing "none" / "nothing" values.
Definition: nothing.hpp:17
alc_api_function< context_type *(), nullptr > GetCurrentContext
Definition: c_api.hpp:191
alc_api_function< bool_type(device_type *), nullptr > CloseDevice
Definition: c_api.hpp:129
alc_api_function< void(device_type *, enum_type, size_type, int_type *), nullptr > GetIntegerv
Definition: c_api.hpp:150
alc_api_function< const char_type *(device_type *, enum_type), nullptr > GetString
Definition: c_api.hpp:143
static auto finally(Func func) -> func_on_scope_exit< Func >
Function constructing on-scope-exit actions.
Definition: scope_exit.hpp:144
alc_api_function< bool_type(context_type *), nullptr > MakeContextCurrent
Definition: c_api.hpp:186
alc_api_function< device_type *(const char_type *), nullptr > OpenDevice
Definition: c_api.hpp:111
Template type used mostly for function type-tag dispatching.
Definition: type_identity.hpp:19
AL-related code is placed in this namespace.
Definition: oalplus.hpp:11
alc_api_function< void(context_type *), nullptr > DestroyContext
Definition: c_api.hpp:179
Typed enumeration for ALC integer query constants.
Definition: enum_types.hpp:39
alc_api_function< enum_type(device_type *), nullptr > GetError
Definition: c_api.hpp:90
Typed enumeration for ALC string query constants.
Definition: enum_types.hpp:32