// 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 );
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 );
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 {
void FGSimpleSound::stop( slScheduler *sched, bool quick ) {
- if ( quick ) {
- requests = 0;
- } else {
- if ( --requests < 0 ) {
- requests = 0;
- }
- }
-
- if ( requests > 0 ) {
- return;
- }
-
sched->stopSample( sample );
}
}
+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 ) {