]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATCDCL/AIPlane.cxx
Merge branch 'torsten/metar'
[flightgear.git] / src / ATCDCL / AIPlane.cxx
index 1db5820ec2d69cb02364c16de72623baf401d991..8fd67d13aeb190b837706c8996e27c339f068b90 100644 (file)
@@ -47,18 +47,18 @@ FGAIPlane::FGAIPlane() {
        _trackSet = false;
        _tgtRoll = 0.0;
        _rollSuspended = false;
-        _sgr = 0;
+
+       if ( !_sgr ) {
+               SGSoundMgr *smgr = globals->get_soundmgr();
+               _sgr = smgr->find("atc", true);
+                _sgr->tie_to_listener();
+       }
 }
 
 FGAIPlane::~FGAIPlane() {
 }
 
 void FGAIPlane::Update(double dt) {
-       if (!_sgr) {
-               SGSoundMgr *smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
-               if (smgr) _sgr = smgr->find("atc", true);
-       }
-
        if(_pending) {
                if(tuned_station) {
                        if(tuned_station->GetFreqClear()) {
@@ -195,12 +195,10 @@ void FGAIPlane::Render(const string& refname, const float volume, bool repeating
 #ifdef ENABLE_AUDIO_SUPPORT
        voice = (voiceOK && fgGetBool("/sim/sound/voice"));
        if(voice) {
-           string buf = vPtr->WriteMessage((char*)pending_transmission.c_str(), voice);
+            size_t len;
+           void* buf = vPtr->WriteMessage(pending_transmission, &len);
            if(voice && (volume > 0.05)) {
-               SGSoundSample* simple = 
-                   new SGSoundSample((unsigned char*)buf.c_str(), buf.length(), 8000 );
-                // TODO - at the moment the volume can't be changed 
-               // after the transmission has started.
+               SGSoundSample* simple = new SGSoundSample(&buf, len, 8000 );
                simple->set_volume(volume);
                _sgr->add(simple, refname);
                _sgr->play(refname, repeating);