Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/audio
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/audio.cc14
1 files changed, 14 insertions, 0 deletions
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];