]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/soundmgr_openal.cxx
Update the code a bit more, add a function to retreive the last error string and...
[simgear.git] / simgear / sound / soundmgr_openal.cxx
index 307303ffff74740a57bccdc0bf5492398166d104..c438a6531b3d29a208a5a2027ba9ea53e3c7f8dc 100644 (file)
@@ -5,7 +5,7 @@
 //
 // C++-ified by Curtis Olson, started March 2001.
 //
-// Copyright (C) 2001  Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 2001  Curtis L. Olson - http://www.flightgear.org/~curt
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -35,7 +35,7 @@
 # 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); }
@@ -46,6 +46,14 @@ inline int (isnan)(double r) { return isnan(r); }
 #define isnan(x) _isnan(x)
 #endif
 
+#if defined (__FreeBSD__)
+#  if __FreeBSD_version < 500000
+     extern "C" {
+       inline int isnan(double r) { return !(r <= 0 || r >= 0); }
+     }
+#  endif
+#endif
+
 #include STL_IOSTREAM
 
 #include <simgear/debug/logstream.hxx>
@@ -65,7 +73,8 @@ SGSoundMgr::SGSoundMgr() {
 
     // initialize OpenAL
     alutInit( 0, NULL );
-    alGetError();
+    atexit(alutExit);
+
     if ( alGetError() == AL_NO_ERROR) {
         working = true;
     } else {
@@ -88,6 +97,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 +125,6 @@ SGSoundMgr::~SGSoundMgr() {
        SGSoundSample *sample = sample_current->second;
        delete sample;
     }
-
-    alutExit();
 }