]> git.jsancho.org Git - lugaru.git/blob - Source/Audio/openal_wrapper.hpp
379949fd6e0d3f88c1cbe3006b05d4e64aa7c40b
[lugaru.git] / Source / Audio / openal_wrapper.hpp
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file)
4
5 This file is part of Lugaru.
6
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef _OPENAL_WRAPPER_HPP_
22 #define _OPENAL_WRAPPER_HPP_
23
24 #include "Math/XYZ.hpp"
25 #include "Platform/Platform.hpp"
26
27 #ifdef __APPLE__
28 #include <OpenAL/al.h>
29 #include <OpenAL/alc.h>
30 #else
31 #include <AL/al.h>
32 #include <AL/alc.h>
33 #endif
34
35 #include <ogg/ogg.h>
36 #include <vorbis/vorbisfile.h>
37
38 #ifdef _WIN32
39 #include <malloc.h>
40 #endif
41
42 #if 0 /* this should only be enable if OPENAL doesn't provide AL_API on all platforms */
43 #if (!defined(WIN32) && !defined(_WIN32) && !defined(__WIN32__) && !defined(_WIN64) && !defined(_WIN32_WCE) && !defined(_XBOX)) || (defined(__GNUC__) && defined(WIN32))
44 #ifndef __cdecl
45 #define __cdecl
46 #endif
47 #ifndef __stdcall
48 #define __stdcall
49 #endif
50 #endif
51
52 #if defined(_WIN32_WCE)
53 #define AL_API _cdecl
54 #define F_CALLBACKAPI _cdecl
55 #else
56 #define AL_API __stdcall
57 #define F_CALLBACKAPI __stdcall
58 #endif
59
60 #ifdef DLL_EXPORTS
61 #define DLL_API __declspec(dllexport)
62 #else
63 #if defined(__LCC__) || defined(__MINGW32__) || defined(__CYGWIN32__)
64 #define DLL_API AL_API
65 #else
66 #define DLL_API
67 #endif /* __LCC__ ||  __MINGW32__ || __CYGWIN32__ */
68 #endif /* DLL_EXPORTS */
69 #endif /* if 0 */
70
71 typedef struct OPENAL_SAMPLE OPENAL_SAMPLE;
72 typedef OPENAL_SAMPLE OPENAL_STREAM;
73 typedef struct OPENAL_DSPUNIT OPENAL_DSPUNIT;
74
75 #define OPENAL_LOOP_OFF 0x00000001    /* For non looping samples. */
76 #define OPENAL_LOOP_NORMAL 0x00000002 /* For forward looping samples. */
77 #define OPENAL_HW3D 0x00001000        /* Attempts to make samples use 3d hardware acceleration. (if the card supports it) */
78 #define OPENAL_2D 0x00002000          /* Tells software (not hardware) based sample not to be included in 3d processing. */
79 #define OPENAL_FREE -1                /* value to play on any free channel, or to allocate a sample in a free sample slot. */
80 #define OPENAL_ALL -3                 /* for a channel index , this flag will affect ALL channels available!  Not supported by every function. */
81
82 #ifdef __cplusplus
83 extern "C" {
84 #endif
85
86 #undef AL_API
87 #define AL_API
88
89 AL_API void OPENAL_3D_Listener_SetAttributes(const float* pos, const float* vel, float fx, float fy, float fz, float tx, float ty, float tz);
90 AL_API signed char OPENAL_3D_SetAttributes(int channel, const float* pos);
91 AL_API signed char OPENAL_3D_SetAttributes_(int channel, const XYZ& pos);
92 AL_API signed char OPENAL_Init(int mixrate, int maxsoftwarechannels, unsigned int flags);
93 AL_API void OPENAL_Close();
94 AL_API OPENAL_SAMPLE* OPENAL_Sample_Load(int index, const char* name_or_data, unsigned int mode, int offset, int length);
95 AL_API void OPENAL_Sample_Free(OPENAL_SAMPLE* sptr);
96 AL_API signed char OPENAL_SetFrequency(int channel, bool slomo = false);
97 AL_API signed char OPENAL_SetVolume(int channel, int vol);
98 AL_API signed char OPENAL_SetPaused(int channel, signed char paused);
99 AL_API void OPENAL_SetSFXMasterVolume(int volume);
100 AL_API signed char OPENAL_StopSound(int channel);
101 AL_API signed char OPENAL_Stream_SetMode(OPENAL_STREAM* stream, unsigned int mode);
102 AL_API void OPENAL_Update();
103 void PlaySoundEx(int chan, OPENAL_SAMPLE* sptr, OPENAL_DSPUNIT* dsp, signed char startpaused);
104 void PlayStreamEx(int chan, OPENAL_SAMPLE* sptr, OPENAL_DSPUNIT* dsp, signed char startpaused);
105
106 #ifdef __cplusplus
107 }
108 #endif
109
110 #endif