nomlib
Loading...
Searching...
No Matches
ALAudioDevice.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014, 2015, 2016 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_AL_AUDIO_DEVICE_HEADERS
30#define NOMLIB_AL_AUDIO_DEVICE_HEADERS
31
32#include "nomlib/config.hpp"
33#include "nomlib/core/IObject.hpp"
34#include "nomlib/math/Point3.hpp"
35#include "nomlib/audio/audio_defs.hpp"
36#include "nomlib/audio/SoundFile.hpp"
37
38#include <vector>
39#include <functional>
40
41// Forward declarations
42struct ALCdevice_struct;
43struct ALCcontext_struct;
44
45namespace nom {
46namespace audio {
47
48class IOAudioEngine;
49struct AudioSpec;
50
51ALCdevice_struct* current_device();
52ALCcontext_struct* current_context();
53
54void free_audio_device(ALCdevice_struct* dev);
55void free_audio_context(ALCcontext_struct* ctx);
56
57void*
58process_addr(const char* token);
59
60// TODO(jeff): Verify if we should be using alIsExtensionPresent or
61// alcIsExtensionPresent for querying extensions, etc.
62
64bool extension_available(const char* key);
65
67// bool extension_available(const char* key, void* target);
68
69// TODO(jeff): Rename function -- something along the lines of
70// config_available..?
71// if err, return zero; if successful, return the key's value, a number greater
72// than zero.
73uint32 enum_available(const char* key);
74
75bool
76context_extension(const char* key, ALCdevice_struct* target);
77
78typedef std::vector<std::string> device_name_list;
79
80const char* default_output_device_name(ALCdevice_struct* target);
81const char* default_input_device_name(ALCdevice_struct* target);
82
83// TODO(jeff): Try to factor out the use of std::vector here
84device_name_list output_device_names(void* target);
85
86// TODO(jeff): Implement function
87device_name_list input_device_names(void* target);
88
89int refresh_rate(void* target);
90bool sync_context(void* target);
91
93int sample_rate(void* target);
94
96// void set_sample_rate(int sample_rate, void* target);
97
98int max_mono_sources(void* target);
99int max_stereo_sources(void* target);
100
102int max_sources(void* target);
103
105// void set_max_sources(int num_sources, void* target);
106
107bool cap(uint32 caps, uint32 key);
108void set_cap(uint32* caps, uint32 format);
109
111{
112 // ALAudioDevice
113 void* impl = nullptr;
114};
115
117// TODO(jeff): Private header..?
119{
121 ALCdevice_struct* dev = nullptr;
122
124 ALCcontext_struct* ctx = nullptr;
125
126 // IOAudioEngine* impl = nullptr;
127
128 const char* name = "ALAudioDevice";
129
130 // uint32 max_channels = 0;
131
132 uint32 capabilities = CAPS_UNDEFINED;
133
134 // real64 elapsed_ticks_ = 0.0f;
135
136 // typedef std::function<device_name_list()> input_devs_func;
137 typedef std::function<device_name_list(ALAudioDevice*)> output_devs_func;
138
139 output_devs_func enumerate_output_devices;
140 // input_devs_func enumerate_input_devices;
141};
142
144init_audio(const audio::AudioSpec* request, audio::AudioSpec* spec);
145
146// void shutdown_openal(ALAudioDevice* impl);
147void shutdown_audio(IOAudioEngine* impl);
148
149// const char* audio_device_name(IOAudioEngine* target);
150
154int num_audio_devices();
155
161// const char* audio_device(void* target);
162
163// real64 device_time(void* target);
164
165} // namespace audio
166} // namespace nom
167
168#endif // NOMLIB_AL_AUDIO_DEVICE_HEADERS defined
Abstract base class for an instance of the audio hardware interface.
ALCcontext_struct * ctx
Audio device context.
ALCdevice_struct * dev
Audio device handle.