]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/soundmgr_openal.cxx
Mathias Fröhlich:
[simgear.git] / simgear / sound / soundmgr_openal.cxx
index 9b88e3d001ad6997bc329b94bbcbfd760a241613..971bea6d2c4d1582ce2f20d5c955c40da8d8977d 100644 (file)
@@ -37,8 +37,7 @@
 #  ifdef __GNUC__
 #    if ( __GNUC__ >= 3 ) && ( __GNUC_MINOR__ >= 3 )
 //  #        include <math.h>
-extern "C" int isnan (double);
-extern "C" int isinf (double);
+inline int (isnan)(double r) { return !(r <= 0 || r >= 0); }
 #    else
     // any C++ header file undefines isinf and isnan
     // so this should be included before <iostream>
@@ -81,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;
@@ -90,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;
@@ -125,17 +135,12 @@ SGSoundMgr::SGSoundMgr() {
 
 SGSoundMgr::~SGSoundMgr() {
 
+#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1
+    alutExit ();
+#else
     if (context)
         alcDestroyContext( context );
-    //
-    // Remove the samples from the sample manager.
-    //
-    sample_map_iterator sample_current = samples.begin();
-    sample_map_iterator sample_end = samples.end();
-    for ( ; sample_current != sample_end; ++sample_current ) {
-       SGSoundSample *sample = sample_current->second;
-       delete sample;
-    }
+#endif
 }
 
 
@@ -144,12 +149,6 @@ void SGSoundMgr::init() {
     //
     // Remove the samples from the sample manager.
     //
-    sample_map_iterator sample_current = samples.begin();
-    sample_map_iterator sample_end = samples.end();
-    for ( ; sample_current != sample_end; ++sample_current ) {
-        SGSoundSample *sample = sample_current->second;
-        delete sample;
-    }
     samples.clear();
 }