Attempt to detect and work around plib-1.2.0 audio bugs.
This commit is contained in:
parent
95e27e8cb9
commit
55e881b83d
3 changed files with 42 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue