]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/soundmgr_openal.cxx
MingW/MSYS fix
[simgear.git] / simgear / sound / soundmgr_openal.cxx
index 1966259aeee97ee155d9df5078232fbc4cf3c5f3..bfdda68210b1e660c8e68e238890e3adb595125a 100644 (file)
 # include <AL/alc.h>
 #endif
 
-#if defined (__APPLE__) 
+#if defined (__APPLE__)
 // any C++ header file undefines isinf and isnan
 // so this should be included before <iostream>
 inline int (isinf)(double r) { return isinf(r); }
 inline int (isnan)(double r) { return isnan(r); } 
 #endif
 
-#if defined(__MINGW32__)
-#define isnan(x) _isnan(x)
+#if defined (__FreeBSD__)
+#  if __FreeBSD_version < 500000
+     extern "C" {
+       inline int isnan(double r) { return !(r <= 0 || r >= 0); }
+     }
+#  endif
 #endif
 
 #include STL_IOSTREAM
@@ -53,6 +57,9 @@ inline int (isnan)(double r) { return isnan(r); }
 
 #include "soundmgr_openal.hxx"
 
+#if defined(__MINGW32__)
+#define isnan(x) _isnan(x)
+#endif
 
 //
 // Sound Manager
@@ -65,7 +72,8 @@ SGSoundMgr::SGSoundMgr() {
 
     // initialize OpenAL
     alutInit( 0, NULL );
-    alGetError();
+    atexit(alutExit);
+
     if ( alGetError() == AL_NO_ERROR) {
         working = true;
     } else {
@@ -88,6 +96,7 @@ SGSoundMgr::SGSoundMgr() {
     listener_ori[4] = 1.0;
     listener_ori[5] = 0.0;
 
+    alListenerf( AL_GAIN, 0.0f );
     alListenerfv( AL_POSITION, listener_pos );
     alListenerfv( AL_VELOCITY, listener_vel );
     alListenerfv( AL_ORIENTATION, listener_ori );
@@ -115,8 +124,6 @@ SGSoundMgr::~SGSoundMgr() {
        SGSoundSample *sample = sample_current->second;
        delete sample;
     }
-
-    alutExit();
 }