]> git.mxchange.org Git - flightgear.git/blobdiff - src/Instrumentation/marker_beacon.cxx
Canvas: Performance improvements.
[flightgear.git] / src / Instrumentation / marker_beacon.cxx
index 3a0d33819d24e28bc3607e73e571c6e7e2141f90..41b981536a6262e6da037e66b03e5523bda64518 100644 (file)
 #include <simgear/math/sg_random.h>
 #include <simgear/misc/sg_path.hxx>
 
-#include <Aircraft/aircraft.hxx>
 #include <Navaids/navlist.hxx>
 
 #include "marker_beacon.hxx"
+#include <Sound/beacon.hxx>
 
 #include <string>
 using std::string;
@@ -43,7 +43,6 @@ using std::string;
 // Constructor
 FGMarkerBeacon::FGMarkerBeacon(SGPropertyNode *node) :
     audio_vol(NULL),
-    need_update(true),
     outer_blink(false),
     middle_blink(false),
     inner_blink(false),
@@ -100,7 +99,7 @@ FGMarkerBeacon::init ()
 
     SGPropertyNode *node = fgGetNode(branch.c_str(), num, true );
     // Inputs
-    sound_pause = fgGetNode("/sim/sound/pause", false);
+    sound_working = fgGetNode("/sim/sound/working", true);
     lon_node = fgGetNode("/position/longitude-deg", true);
     lat_node = fgGetNode("/position/latitude-deg", true);
     alt_node = fgGetNode("/position/altitude-ft", true);
@@ -117,18 +116,21 @@ FGMarkerBeacon::init ()
     if (serviceable->getType() == simgear::props::NONE)
         serviceable->setBoolValue( true );
 
-    SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
+    SGSoundMgr *smgr = globals->get_soundmgr();
     _sgr = smgr->find("avionics", true);
     _sgr->tie_to_listener();
 
-    morse.init();
-    beacon.init();
-    blink.stamp();
+    reinit();
+}
 
+void
+FGMarkerBeacon::reinit ()
+{
+    blink.stamp();
     outer_marker = middle_marker = inner_marker = false;
+    _time_before_search_sec = 0.0;
 }
 
-
 void
 FGMarkerBeacon::bind ()
 {
@@ -162,8 +164,6 @@ FGMarkerBeacon::unbind ()
 void
 FGMarkerBeacon::update(double dt)
 {
-    need_update = false;
-
     // On timeout, scan again, this needs to run every iteration no
     // matter what the power or serviceable state.  If power is turned
     // off or the unit becomes unserviceable while a beacon sound is
@@ -176,7 +176,7 @@ FGMarkerBeacon::update(double dt)
     }
 
     if ( has_power() && serviceable->getBoolValue()
-            && !sound_pause->getBoolValue()) {
+            && sound_working->getBoolValue()) {
 
         // marker beacon blinking
         bool light_on = ( outer_blink || middle_blink || inner_blink );
@@ -318,7 +318,7 @@ void FGMarkerBeacon::search()
             // cout << "OUTER MARKER" << endl;
             if ( last_beacon != OUTER ) {
                 if ( ! _sgr->exists( current_sound_name ) ) {
-                    SGSoundSample *sound = beacon.get_outer();
+                    SGSoundSample *sound = FGBeacon::instance()->get_outer();
                     if ( sound ) {
                         _sgr->add( sound, current_sound_name );
                     }
@@ -337,7 +337,7 @@ void FGMarkerBeacon::search()
             // cout << "MIDDLE MARKER" << endl;
             if ( last_beacon != MIDDLE ) {
                 if ( ! _sgr->exists( current_sound_name ) ) {
-                    SGSoundSample *sound = beacon.get_middle();
+                    SGSoundSample *sound = FGBeacon::instance()->get_middle();
                     if ( sound ) {
                         _sgr->add( sound, current_sound_name );
                     }
@@ -356,7 +356,7 @@ void FGMarkerBeacon::search()
             // cout << "INNER MARKER" << endl;
             if ( last_beacon != INNER ) {
                 if ( ! _sgr->exists( current_sound_name ) ) {
-                    SGSoundSample *sound = beacon.get_inner();
+                    SGSoundSample *sound = FGBeacon::instance()->get_inner();
                     if ( sound ) {
                         _sgr->add( sound, current_sound_name );
                     }