nomlib
Loading...
Searching...
No Matches
OpenAL.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28******************************************************************************/
29#ifndef NOMLIB_OPENAL_HEADERS
30#define NOMLIB_OPENAL_HEADERS
31
32#include "nomlib/config.hpp"
33
34#if defined(NOM_USE_CREATIVE_OPENAL) || defined(NOM_USE_OPENAL_SOFT)
35 // Use OpenAL-soft distributed SDK headers
36 #include <AL/al.h>
37 #include <AL/alc.h>
38 #include <AL/alext.h>
39#elif defined(NOM_PLATFORM_OSX) && defined(NOM_USE_APPLE_OPENAL)
40 // Use Apple's distributed OpenAL SDK headers
41 #include <OpenAL/al.h>
42 #include <OpenAL/alc.h>
43 #include <OpenAL/MacOSX_OALExtensions.h>
44#else // As per the header inclusion path that FindOpenAL.cmake gives us
45 #include <al.h>
46 #include <alc.h>
47 #include <alext.h>
48#endif
49
50// OpenAL error checking macro for all but the audio context error handling
51// The OpenAL function call is wrapped inside of this macro that needs
52// checking.
53#define AL_CHECK_ERR(Function) \
54 ( Function, al_err(NOM_FUNC, __FILE__, __LINE__) )
55
56// OpenAL error checking macro for audio context error handling
57// The OpenAL function call is wrapped inside of this macro that needs
58// checking. This macro additionally requires the OpenAL device handle to be
59// given.
60#define ALC_CHECK_ERR(Function, device) \
61 ( Function, alc_err(NOM_FUNC, __FILE__, __LINE__, device) )
62
63// Clear the error state of OpenAL -- this must be done right before a
64// AL_CHECK_ERR macro is used.
65#define AL_CLEAR_ERR() alGetError();
66
67// Clear the error state of OpenAL (context specific) -- this must be done
68// right before a ALC_CHECK_ERR macro is used.
69#define ALC_CLEAR_ERR(device) alcGetError(device);
70
71// #define AL_CLEAR_ERR()
72// #define ALC_CLEAR_ERR()
73// #define AL_CHECK_ERR()
74// #define ALC_CHECK_ERR()
75
76// namespace nom {
77// namespace priv {
78
79NOM_EXPORT
80ALenum al_err(const std::string& func, const std::string& file, uint32_t line);
81
82NOM_EXPORT
83ALenum alc_err(const std::string& func, const std::string& file, uint32_t line,
84 ALCdevice* dev = nullptr);
85
86// } // namespace priv
87// } // namespace nom
88
89// namespace nom {
90// namespace audio {
91
92// enum AudioError
93// {
94// ERR_NO_ERROR = 0,
95// ERR_SYSTEM_CALL_FAILURE,
96// ERR_OUT_OF_MEMORY,
97// ERR_INVALID_OPERATION,
98// };
99
100// struct err_t
101// {
102// uint32 error_code = 0;
103// };
104
105// // uint32 err(err_t* err);
106// uint32 err();
107// const char* err_str(uint32 errno);
108
109// void set_err(uint32 errno);
110// void set_err(err_t* err);
111
112// } // namespace audio
113// } // namespace nom
114
115#endif // NOMLIB_OPENAL_HEADERS defined
116