]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/soundmgr.cxx
This is step "1" of probably "many" in the process of separating out the
[flightgear.git] / src / Sound / soundmgr.cxx
index 2b7e25576c4dee1eb1686c4fe3eb14c3d7f2cfad..b303a11cdcfe8acf06b38fd16d24df29969c31d7 100644 (file)
@@ -125,6 +125,8 @@ FGSoundMgr::~FGSoundMgr() {
     sample_map_iterator sample_end = samples.end();
     for ( ; sample_current != sample_end; ++sample_current ) {
        sample_ref *sr = sample_current->second;
+
+        audio_sched->stopSample(sr->sample);
        delete sr->sample;
        delete sr;
     }
@@ -136,6 +138,9 @@ FGSoundMgr::~FGSoundMgr() {
     sound_map_iterator sound_end = sounds.end();
     for ( ; sound_current != sound_end; ++sound_current ) {
         FGSimpleSound *s = sound_current->second;
+
+        audio_sched->stopSample(s->get_sample());
+        delete s->get_sample();
         delete s;
     }
 
@@ -146,7 +151,6 @@ FGSoundMgr::~FGSoundMgr() {
 
 // initialize the sound manager
 void FGSoundMgr::init() {
-    last.stamp();
     safety = FG_MAX_SOUND_SAFETY;
 
     // audio_mixer -> setMasterVolume ( 80 ) ;  /* 80% of max volume. */
@@ -160,6 +164,8 @@ void FGSoundMgr::init() {
     sample_map_iterator sample_end = samples.end();
     for ( ; sample_current != sample_end; ++sample_current ) {
         sample_ref *sr = sample_current->second;
+
+        audio_sched->stopSample(sr->sample);
         delete sr->sample;
         delete sr;
     }
@@ -172,6 +178,8 @@ void FGSoundMgr::init() {
     sound_map_iterator sound_end = sounds.end();
     for ( ; sound_current != sound_end; ++sound_current ) {
        FGSimpleSound *s = sound_current->second;
+
+        audio_sched->stopSample(s->get_sample());
        delete s->get_sample();
        delete s;
     }
@@ -179,11 +187,13 @@ void FGSoundMgr::init() {
 
 }
 
+
 void FGSoundMgr::bind ()
 {
   // no properties yet
 }
 
+
 void FGSoundMgr::unbind ()
 {
   // no properties yet
@@ -191,18 +201,11 @@ void FGSoundMgr::unbind ()
 
 
 // run the audio scheduler
-void FGSoundMgr::update(double dt) {
-                               // FIXME: use dt supplied (seconds)
-    SGTimeStamp current;
-    current.stamp();
-
-    double elapsed = (double)(current - last) / 1000000.0;
-    last = current;
-
-    if ( elapsed > safety ) {
-       safety = elapsed;
+void FGSoundMgr::update( double dt ) {
+    if ( dt > safety ) {
+       safety = dt;
     } else {
-       safety = safety * 0.99 + elapsed * 0.01;
+       safety = safety * 0.99 + dt * 0.01;
     }
     if ( safety > FG_MAX_SOUND_SAFETY ) {
        safety = FG_MAX_SOUND_SAFETY;