]> git.mxchange.org Git - flightgear.git/commitdiff
Attempt to detect and work around plib-1.2.0 audio bugs.
authorcurt <curt>
Fri, 9 Mar 2001 20:17:54 +0000 (20:17 +0000)
committercurt <curt>
Fri, 9 Mar 2001 20:17:54 +0000 (20:17 +0000)
acconfig.h
src/Include/config.h.in
src/Sound/soundmgr.cxx

index e4ee7662aa02f8fd4ff0c7c4f27ee4749463d6d4..6d925ea8b3485b3b56fc5f88130d962ea4c16700 100644 (file)
@@ -54,6 +54,9 @@
 /* Define to enable plib joystick support (recommended) */
 #undef ENABLE_PLIB_JOYSTICK
    
+/* Define to enable plib joystick support (recommended) */
+#undef PLIB_AUDIO_IS_BROKEN
+   
 /* Define to eliminate all trace of debugging messages such as for a 
    release build */
 #undef FG_NDEBUG
index 13044e031b1abee6c1c9891332449e8b711b9bb2..f291938dd4e38e0716f015e18293a13775bf3e56 100644 (file)
 #undef ENABLE_PLIB_JOYSTICK
 
    
+/* Define to enable plib joystick support (recommended) */
+#undef PLIB_AUDIO_IS_BROKEN
+
+   
 /* Define to eliminate all trace of debugging messages such as for a 
    release build */
 #undef FG_NDEBUG
index 6ec0ed1de8770d48138baefcf05409b317c7d3b8..a868dd13c50494f7c42165624c48f0163000c561 100644 (file)
@@ -128,6 +128,24 @@ bool FGSoundMgr::add( FGSimpleSound *sound, const string& refname  ) {
 
 // remove a sound effect, return true if successful
 bool FGSoundMgr::remove( const string& refname ) {
+
+#if defined ( PLIB_AUDIO_IS_BROKEN )
+    // if PLIB_AUDIO_IS_BROKEN, we can't reliably remove sounds that
+    // are currently being played. :-( So, let's just not remove them
+    // and return false.  The effects of this are that the sound
+    // sample will continue to finish playing (or continue to loop
+    // forever.)  And the sound sample will remain registered in the
+    // plib audio system.  This is a memory leak, and eventually this
+    // could cause us to max out the total number of allowed sound
+    // samples in plib, but what are you going to do?  Hopefully the
+    // plib team will do a new stable relase with these problems
+    // fixed.
+
+    cout << "plib broken audio, skipping remove" << endl;
+
+    return false;
+#endif
+
     sound_map_iterator it = sounds.find( refname );
     if ( it != sounds.end() ) {
        // first stop the sound from playing (so we don't bomb the
@@ -145,6 +163,22 @@ bool FGSoundMgr::remove( const string& refname ) {
                                        NULL,
                                        SL_VOLUME_ENVELOPE );
 
+#if defined ( PLIB_AUDIO_IS_BROKEN )
+       // if PLIB_AUDIO_IS_BROKEN, we can't reliably remove sounds
+       // that are currently being played. :-( So, let's just not
+       // remove them and return false.  The effects of this are that
+       // the sound sample will continue to finish playing (or
+       // continue to loop forever.)  And the sound sample will
+       // remain registered in the plib audio system.  This is a
+       // memory leak, and eventually this could cause us to max out
+       // the total number of allowed sound samples in plib, but what
+       // are you going to do?  Hopefully the plib team will do a new
+       // stable relase with these problems fixed.
+
+       cout << "plib broken audio, skipping actual remove" << endl;
+
+       return false;
+#else
        // must call audio_sched->update() after stopping the sound
        // but before deleting it.
        audio_sched -> update();
@@ -155,6 +189,7 @@ bool FGSoundMgr::remove( const string& refname ) {
         sounds.erase( it );
 
        return true;
+#endif
    } else {
        return false;
     }