From e685db34cb94e4bef564da4afdaa7a18b1819c09 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 3 Aug 2008 17:58:10 +0000 Subject: documentation, extra sound warnings, network bytes/sec --- src/audio/audio.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/audio') diff --git a/src/audio/audio.cc b/src/audio/audio.cc index 94f4d23..50d15c8 100644 --- a/src/audio/audio.cc +++ b/src/audio/audio.cc @@ -30,6 +30,14 @@ void init() // create the audio context audio_context = alcCreateContext(audio_device ,0); + + if (!audio_context) { + alcCloseDevice(audio_device); + audio_device = 0; + con_warn << "Could not create audio context!"; + return; + } + alcMakeContextCurrent(audio_context); // clear errors @@ -100,6 +108,9 @@ void play(const char *name) void update_source(size_t source_index, math::Vector3f const & location, math::Vector3f const & velocity, float pitch, float gain) { + if (!audio_context) + return; + ALuint source = Sources::source(source_index); alSourcefv(source, AL_POSITION, location.ptr()); //alSourcefv(source, AL_VELOCITY, velocity.ptr()); @@ -127,6 +138,9 @@ void 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) { + if (!audio_context) + return; + alListenerfv(AL_POSITION, location.ptr()); ALfloat orientation[6]; -- cgit v1.2.3