40 m_device = alcOpenDevice(
nullptr);
46 m_context = alcCreateContext(m_device,
nullptr);
52 if(alcMakeContextCurrent(m_context) != ALC_TRUE) {
62 for(
auto &streamFile: m_streamFiles) {
63 auto& future = streamFile.second;
66 m_streamFiles.clear();
72 m_audioEnabled =
false;
74 alcMakeContextCurrent(
nullptr);
77 alcDestroyContext(m_context);
82 alcCloseDevice(m_device);
92 if(now - lastUpdate < POLL_DELAY)
99 for(
auto it = m_streamFiles.begin(); it != m_streamFiles.end();) {
101 auto& future = it->second;
103 if(future.is_ready()) {
106 source->setSoundFile(sound);
109 it = m_streamFiles.erase(it);
115 for(
auto it = m_sources.begin(); it != m_sources.end();) {
121 it = m_sources.erase(it);
126 for(
auto it : m_channels) {
131 alcProcessContext(m_context);
137 if(m_audioEnabled == enable)
140 m_audioEnabled = enable;
153 auto it = m_buffers.find(filename);
154 if(it != m_buffers.end())
161 if(!soundFile || soundFile->
getSize() > MAX_CACHE_SIZE)
166 m_buffers[filename] = buffer;
186 soundSource->
setName(filename);
195 m_sources.push_back(soundSource);
203 if(!m_channels[channel])
205 return m_channels[channel];
215 for(
auto it : m_channels) {
220 SoundSourcePtr SoundManager::createSoundSource(
const std::string& filename)
225 auto it = m_buffers.find(filename);
226 if(it != m_buffers.end()) {
228 source->setBuffer(it->second);
230 #if defined __linux && !defined OPENGL_ES
239 streamSource->setRelative(
true);
240 streamSource->setPosition(
Point(-128, 0));
241 combinedSource->addSource(streamSource);
246 }
catch(std::exception& e) {
254 streamSource->setRelative(
true);
255 streamSource->setPosition(
Point(128,0));
256 combinedSource->addSource(streamSource);
260 }
catch(std::exception& e) {
266 source = combinedSource;
272 }
catch(std::exception& e) {
277 source = streamSource;
280 }
catch(std::exception& e) {
298 alcMakeContextCurrent(m_context);