]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/soundmgr.cxx
Removed old remnants of plib-1.2.x support. We haven't officially supported
[flightgear.git] / src / Sound / soundmgr.cxx
index b0154535de30867d1a72ef12f0c89604b932649c..3bf3ea0e84aa8774210b15de55ffa9b3bcac7f86 100644 (file)
@@ -31,6 +31,8 @@
 
 #include "soundmgr.hxx"
 
+#define FG_SOUND_SAFETY_MULT 3
+#define FG_MAX_SOUND_SAFETY ( 1.0 / FG_SOUND_SAFETY_MULT )
 
 // constructor
 FGSimpleSound::FGSimpleSound( string file ) {
@@ -62,6 +64,8 @@ FGSimpleSound::~FGSimpleSound() {
 // constructor
 FGSoundMgr::FGSoundMgr() {
     audio_sched = new slScheduler( 8000 );
+    audio_sched -> setMaxConcurrent ( 6 ); 
+
     audio_mixer = new smMixer;
 
     SG_LOG( SG_GENERAL, SG_INFO,
@@ -71,6 +75,7 @@ FGSoundMgr::FGSoundMgr() {
 }
 
 // destructor
+
 FGSoundMgr::~FGSoundMgr() {
     sound_map_iterator current = sounds.begin();
     sound_map_iterator end = sounds.end();
@@ -86,12 +91,12 @@ FGSoundMgr::~FGSoundMgr() {
 
 
 // initialize the sound manager
-bool FGSoundMgr::init() {
+void FGSoundMgr::init() {
     last.stamp();
-    safety = 0.5;
+    safety = FG_MAX_SOUND_SAFETY;
 
-    audio_mixer -> setMasterVolume ( 80 ) ;  /* 80% of max volume. */
-    audio_sched -> setSafetyMargin ( 2 * safety ) ;
+    // audio_mixer -> setMasterVolume ( 80 ) ;  /* 80% of max volume. */
+    audio_sched -> setSafetyMargin ( FG_SOUND_SAFETY_MULT * safety ) ;
 
     sound_map_iterator current = sounds.begin();
     sound_map_iterator end = sounds.end();
@@ -102,16 +107,21 @@ bool FGSoundMgr::init() {
     }
     sounds.clear();
 
-    if ( audio_sched->not_working() ) {
-       return false;
-    } else {
-       return true;
-    }
+}
+
+void FGSoundMgr::bind ()
+{
+  // no properties yet
+}
+
+void FGSoundMgr::unbind ()
+{
+  // no properties yet
 }
 
 
 // run the audio scheduler
-bool FGSoundMgr::update() {
+void FGSoundMgr::update(int dt) {
     SGTimeStamp current;
     current.stamp();
 
@@ -123,18 +133,14 @@ bool FGSoundMgr::update() {
     } else {
        safety = safety * 0.99 + elapsed * 0.01;
     }
-    if ( safety > 0.5 ) {
-       safety = 0.5;
+    if ( safety > FG_MAX_SOUND_SAFETY ) {
+       safety = FG_MAX_SOUND_SAFETY;
     }
-    cout << "safety = " << safety << endl;
-    audio_sched -> setSafetyMargin ( 2 * safety ) ;
+    // cout << "safety = " << safety << endl;
+    audio_sched -> setSafetyMargin ( FG_SOUND_SAFETY_MULT * safety ) ;
 
-    if ( !audio_sched->not_working() ) {
+    if ( !audio_sched->not_working() )
        audio_sched -> update();
-       return true;
-    } else {
-       return false;
-    }
 }
 
 
@@ -166,22 +172,6 @@ bool FGSoundMgr::remove( const string& refname ) {
                                        NULL,
                                        SL_VOLUME_ENVELOPE );
 
-#if defined ( PLIB_1_2_X )
-       // if PLIB_1_2_X, 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();
@@ -192,7 +182,6 @@ bool FGSoundMgr::remove( const string& refname ) {
         sounds.erase( it );
 
        return true;
-#endif
    } else {
        return false;
     }