From: curt Date: Fri, 9 Mar 2001 20:17:54 +0000 (+0000) Subject: Attempt to detect and work around plib-1.2.0 audio bugs. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=55e881b83d9035b31e1d94c7b321998603349ca9;p=flightgear.git Attempt to detect and work around plib-1.2.0 audio bugs. --- diff --git a/acconfig.h b/acconfig.h index e4ee7662a..6d925ea8b 100644 --- a/acconfig.h +++ b/acconfig.h @@ -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 diff --git a/src/Include/config.h.in b/src/Include/config.h.in index 13044e031..f291938dd 100644 --- a/src/Include/config.h.in +++ b/src/Include/config.h.in @@ -38,6 +38,10 @@ #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 diff --git a/src/Sound/soundmgr.cxx b/src/Sound/soundmgr.cxx index 6ec0ed1de..a868dd13c 100644 --- a/src/Sound/soundmgr.cxx +++ b/src/Sound/soundmgr.cxx @@ -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; }