]> git.mxchange.org Git - flightgear.git/blobdiff - src/Sound/soundmgr.cxx
Erik Hofman:
[flightgear.git] / src / Sound / soundmgr.cxx
index eb2f41fd7461f10386f3b176de39d0bf2951e521..fb805428d0037c3b25346ccba52852d4ea6ed65d 100644 (file)
@@ -41,8 +41,7 @@
 // constructor
 FGSimpleSound::FGSimpleSound( string file )
   : pitch(1.0),
-    volume(1.0),
-    requests(0)
+    volume(1.0)
 {
     SGPath slfile( globals->get_fg_root() );
     slfile.append( file );
@@ -55,8 +54,7 @@ FGSimpleSound::FGSimpleSound( string file )
 
 FGSimpleSound::FGSimpleSound( unsigned char *buffer, int len )
   : pitch(1.0),
-    volume(1.0),
-    requests(0)
+    volume(1.0)
 {
     sample = new slSample ( buffer, len );
     pitch_envelope = new slEnvelope( 1, SL_SAMPLE_ONE_SHOT );
@@ -74,14 +72,12 @@ FGSimpleSound::~FGSimpleSound() {
 
 void FGSimpleSound::play( slScheduler *sched, bool looped ) {
     
-    requests++;
-
     // make sure sound isn't already playing
     if ( sample->getPlayCount() > 0 ) {
-        return;
+       sched->stopSample(sample);
+    //   return;
     }
 
-    // sched->stopSample(sample);
     if ( looped ) {
         sched->loopSample(sample);
     } else {
@@ -94,18 +90,6 @@ void FGSimpleSound::play( slScheduler *sched, bool looped ) {
 
 void FGSimpleSound::stop( slScheduler *sched, bool quick ) {
 
-    if ( quick ) {
-        requests = 0;
-    } else {
-        if ( --requests < 0 ) {
-            requests = 0;
-        }
-    }
-
-    if ( requests > 0 ) {
-       return;
-    }
-
     sched->stopSample( sample );
 }
 
@@ -230,6 +214,20 @@ void FGSoundMgr::update(int dt) {
 }
 
 
+void
+FGSoundMgr::pause ()
+{
+  audio_sched->pauseSample(0, 0);
+}
+
+
+void
+FGSoundMgr::resume ()
+{
+  audio_sched->resumeSample(0, 0);
+}
+
+
 // add a sound effect, return true if successful
 bool FGSoundMgr::add( FGSimpleSound *sound, const string& refname ) {