From b9a97161e947995fc5c708a1e61b89785e08feef Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 30 Nov 2010 14:58:30 +0000 Subject: Corrected a problem in the sound initialization sequence. --- src/audio/audio.cc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/audio/audio.cc b/src/audio/audio.cc index d7f85d9..304174c 100644 --- a/src/audio/audio.cc +++ b/src/audio/audio.cc @@ -47,6 +47,8 @@ void init() } alcMakeContextCurrent(audio_context); + + con_debug << " device ^B" << alcGetString(audio_device, ALC_DEFAULT_DEVICE_SPECIFIER) << std::endl; // clear errors alGetError(); @@ -55,15 +57,13 @@ void init() Sources::init(); - //con_debug << " audio device ^B" << alcGetString(audio_device, ALC_DEFAULT_DEVICE_SPECIFIER) << std::endl; - + audio_initialized = true; + // the "no sound" sound load("ui/nosnd"); // console sound load("ui/console"); - - audio_initialized = true; } void reset() @@ -88,6 +88,9 @@ void reset() void load(const char *name) { + if (!audio_initialized) + return; + Buffers::load(std::string(name)); } @@ -116,7 +119,7 @@ void shutdown() size_t play(const char *name) { - if (!audio_context) + if (!audio_initialized) return 0; size_t buffer_index = Buffers::load(std::string(name)); @@ -143,7 +146,7 @@ size_t play(const char *name) size_t play(size_t source_index, size_t buffer_index, float pitch, float gain) { - if (!audio_context || !buffer_index) + if (!audio_initialized || !buffer_index) return 0; ALuint source = Sources::source(source_index); @@ -166,7 +169,7 @@ size_t play(size_t source_index, size_t buffer_index, float pitch, float gain) size_t loop(size_t source_index, size_t buffer_index, float pitch, float gain) { - if (!audio_context || !buffer_index) + if (!audio_initialized || !buffer_index) return 0; ALuint source = Sources::source(source_index); @@ -192,7 +195,7 @@ size_t loop(size_t source_index, size_t buffer_index, float pitch, float gain) size_t loop(size_t source_index, const char *name, float pitch, float gain) { - if (!audio_context) + if (!audio_initialized) return 0; size_t buffer_index = Buffers::load(std::string(name)); @@ -204,7 +207,7 @@ size_t loop(size_t source_index, const char *name, float pitch, float gain) void update_listener(math::Vector3f const &location, math::Axis const &axis, math::Vector3f const & velocity, float gain) { - if (!audio_context) + if (!audio_initialized) return; alListenerfv(AL_POSITION, location.ptr()); @@ -222,7 +225,7 @@ void update_listener(math::Vector3f const &location, math::Axis const &axis, mat void update_source(size_t source_index, math::Vector3f const & location, math::Vector3f const & velocity, float pitch, float gain) { - if (!audio_context) + if (!audio_initialized) return; ALuint source = Sources::source(source_index); @@ -234,7 +237,7 @@ void update_source(size_t source_index, math::Vector3f const & location, math::V bool is_playing(const size_t source_index) { - if (!audio_context) + if (!audio_initialized) return false; ALuint source = Sources::source(source_index); -- cgit v1.2.3