]> git.mxchange.org Git - simgear.git/commitdiff
Oops, ALUT 1.0 requires a little more work than expected.
authorehofman <ehofman>
Tue, 25 Oct 2005 18:05:23 +0000 (18:05 +0000)
committerehofman <ehofman>
Tue, 25 Oct 2005 18:05:23 +0000 (18:05 +0000)
simgear/sound/sample_openal.cxx
simgear/sound/soundmgr_openal.cxx

index c616bdc843725792ff406368827f7391c3ba0695..c182e829c041bc135e53ec970c3b0b12d8ea59ab 100644 (file)
@@ -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
index 7d97d95cc8e7a9ac2a07912e99b45542439fcf32..534c4430e4cb348c68866c15fcc6a0c0d1e71ab2 100644 (file)
@@ -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.
     //