]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/soundmgr_openal.cxx
Pigeons remaining fix for the soundmanager crashes.
[simgear.git] / simgear / sound / soundmgr_openal.cxx
index 971bea6d2c4d1582ce2f20d5c955c40da8d8977d..2d7c53a92d839558ed32d6d5136180afbf3117b9 100644 (file)
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
+
 #include <simgear/compiler.h>
 
 #if defined(__APPLE__)
@@ -87,8 +91,13 @@ SGSoundMgr::SGSoundMgr() {
         SG_LOG( SG_GENERAL, SG_ALERT, "Audio initialization failed!" );
         SG_LOG( SG_GENERAL, SG_ALERT, "   "+string(alutGetErrorString(error)));
         working = false;
+        context = 0;
+    }
+    else
+    {
+        working = true;
+        context = alcGetCurrentContext();
     }
-    context = alcGetCurrentContext();
 #else
     if ( (dev = alcOpenDevice( NULL )) != NULL
             && ( context = alcCreateContext( dev, NULL )) != NULL ) {
@@ -218,8 +227,6 @@ bool SGSoundMgr::remove( const string &refname ) {
     if ( sample_it != samples.end() ) {
        // first stop the sound from playing (so we don't bomb the
        // audio scheduler)
-       SGSoundSample *sample = sample_it->second;
-        delete sample;
         samples.erase( sample_it );
 
         // cout << "sndmgr: removed -> " << refname << endl;