From bf14e49ea4e45ff923de1f926a5f60ec7df9bbd8 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Mon, 9 Nov 2015 19:22:06 -0500 Subject: [PATCH] Create OpenAL sound sources asychronously --- src/audio/sfx_manager.cpp | 3 +++ src/audio/sfx_manager.hpp | 1 + src/audio/sfx_openal.cpp | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/audio/sfx_manager.cpp b/src/audio/sfx_manager.cpp index fb66679be..6682508b1 100644 --- a/src/audio/sfx_manager.cpp +++ b/src/audio/sfx_manager.cpp @@ -378,7 +378,10 @@ void* SFXManager::mainLoop(void *obj) case SFX_MUSIC_DEFAULT_VOLUME: { current->m_music_information->setDefaultVolume(); + break; } + case SFX_CREATE_SOURCE: + current->m_sfx->init(); break; default: assert("Not yet supported."); } delete current; diff --git a/src/audio/sfx_manager.hpp b/src/audio/sfx_manager.hpp index 299d5a31a..d9bfbf515 100644 --- a/src/audio/sfx_manager.hpp +++ b/src/audio/sfx_manager.hpp @@ -88,6 +88,7 @@ public: SFX_MUSIC_WAITING, SFX_MUSIC_DEFAULT_VOLUME, SFX_EXIT, + SFX_CREATE_SOURCE }; // SFXCommands /** diff --git a/src/audio/sfx_openal.cpp b/src/audio/sfx_openal.cpp index 1357a3965..59023e878 100644 --- a/src/audio/sfx_openal.cpp +++ b/src/audio/sfx_openal.cpp @@ -58,7 +58,8 @@ SFXOpenAL::SFXOpenAL(SFXBuffer* buffer, bool positional, float volume, // will not be used anyway. if (SFXManager::get()->sfxAllowed()) { - init(); + SFXManager::get()->queue(SFXManager::SFX_CREATE_SOURCE, this); + //init(); } } // SFXOpenAL