From: ehofman <ehofman>
Date: Tue, 25 Oct 2005 18:05:23 +0000 (+0000)
Subject: Oops, ALUT 1.0 requires a little more work than expected.
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=65a880e9fa4b3d9ef7e7e9b234237ff58198ecfd;p=simgear.git

Oops, ALUT 1.0 requires a little more work than expected.
---

diff --git a/simgear/sound/sample_openal.cxx b/simgear/sound/sample_openal.cxx
index c616bdc8..c182e829 100644
--- a/simgear/sound/sample_openal.cxx
+++ b/simgear/sound/sample_openal.cxx
@@ -107,8 +107,9 @@ SGSoundSample::SGSoundSample( const char *path, const char *file,
 
   buffer = alutCreateBufferFromFile(samplepath.c_str());
   if (buffer == AL_NONE) {
+     ALenum error = alutGetError ();
      print_openal_error("constructor (alutCreateBufferFromFile)");
-     throw sg_exception("Failed to load wav file.");
+     throw sg_exception("Failed to load wav file: "+string(alutGetErrorString (error)));
   }
 
 #else
diff --git a/simgear/sound/soundmgr_openal.cxx b/simgear/sound/soundmgr_openal.cxx
index 7d97d95c..534c4430 100644
--- a/simgear/sound/soundmgr_openal.cxx
+++ b/simgear/sound/soundmgr_openal.cxx
@@ -80,6 +80,16 @@ SGSoundMgr::SGSoundMgr() {
     SG_LOG( SG_GENERAL, SG_INFO, "Initializing OpenAL sound manager" );
 
     // initialize OpenAL
+#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1
+    if (!alutInit(NULL, NULL))
+    {
+        ALenum error = alutGetError ();
+        SG_LOG( SG_GENERAL, SG_ALERT, "Audio initialization failed!" );
+        SG_LOG( SG_GENERAL, SG_ALERT, "   "+string(alutGetErrorString(error)));
+        working = false;
+    }
+    context = alcGetCurrentContext();
+#else
     if ( (dev = alcOpenDevice( NULL )) != NULL
             && ( context = alcCreateContext( dev, NULL )) != NULL ) {
         working = true;
@@ -89,6 +99,7 @@ SGSoundMgr::SGSoundMgr() {
         context = 0;
 	SG_LOG( SG_GENERAL, SG_ALERT, "Audio initialization failed!" );
     }
+#endif
 
     listener_pos[0] = 0.0;
     listener_pos[1] = 0.0;
@@ -124,8 +135,12 @@ SGSoundMgr::SGSoundMgr() {
 
 SGSoundMgr::~SGSoundMgr() {
 
+#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1
+    alutExit ();
+#else
     if (context)
         alcDestroyContext( context );
+#endif
     //
     // Remove the samples from the sample manager.
     //