]> git.mxchange.org Git - flightgear.git/commitdiff
Clean up some sound buffer allocation/deallocation issues.
authorcurt <curt>
Mon, 10 May 2004 21:24:30 +0000 (21:24 +0000)
committercurt <curt>
Mon, 10 May 2004 21:24:30 +0000 (21:24 +0000)
src/ATC/AIPlane.cxx
src/ATC/ATC.cxx
src/ATC/ATCVoice.cxx
src/FDM/ExternalPipe/ExternalPipe.cxx
src/Main/main.cxx
src/Network/atc610x.cxx
src/Sound/beacon.cxx
src/Sound/beacon.hxx
src/Sound/morse.cxx

index a7f021c61279d1ec66875b2bd604fb776d920655..272f4e73b12ec07982938f097b7774386a59e9db 100644 (file)
@@ -189,7 +189,7 @@ void FGAIPlane::Render(string refname, bool repeating) {
                int len;
                unsigned char* buf = vPtr->WriteMessage((char*)pending_transmission.c_str(), len, voice);
                if(voice) {
-                       SGSoundSample* simple = new SGSoundSample(buf, len, 8000);
+                       SGSoundSample* simple = new SGSoundSample(buf, len, 8000, false);
                        // TODO - at the moment the volume is always set off comm1 
                        // and can't be changed after the transmission has started.
                        simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume"));
index f17700c675e38e9934bd8160c321607284364c3e..47f9bba3119b46e6d0909a15814fca196204ddde 100644 (file)
@@ -223,7 +223,8 @@ void FGATC::Render(string msg, string refname, bool repeating) {
                int len;
                unsigned char* buf = vPtr->WriteMessage((char*)msg.c_str(), len, voice);
                if(voice) {
-                       SGSoundSample* simple = new SGSoundSample(buf, len, 8000);
+                       SGSoundSample *simple
+                            = new SGSoundSample(buf, len, 8000, false);
                        // TODO - at the moment the volume is always set off comm1 
                        // and can't be changed after the transmission has started.
                        simple->set_volume(5.0 * fgGetDouble("/radios/comm[0]/volume"));
index ab88ea0fdbd4cf3b3efa936762f0473ab385911f..82721f420a9881d4dc703e0d3e84666013ba55fb 100644 (file)
@@ -37,7 +37,8 @@ FGATCVoice::FGATCVoice() {
 }
 
 FGATCVoice::~FGATCVoice() {
-    // delete SoundData;
+    free( rawSoundData );
+    delete SoundData;
 }
 
 // Load the two voice files - one containing the raw sound data (.wav) and one containing the word positions (.vce).
index fb4d0daea53a744850a48b489236181d6adc7b95..dd2920db48f05dc029364a859f24f11ccbf23ed8 100644 (file)
@@ -206,7 +206,7 @@ void FGExternalPipe::init() {
     }
     last_cg_offset = cg_offset;
 
-    SG_LOG( SG_IO, SG_INFO, "before sending reset command." );
+    SG_LOG( SG_IO, SG_ALERT, "before sending reset command." );
 
     if( fgGetBool("/sim/presets/onground") ) {
         sprintf( cmd, "reset=ground" );
@@ -215,7 +215,7 @@ void FGExternalPipe::init() {
     }
     result = write_fifo( '1', pd1, cmd, strlen(cmd) );
 
-    SG_LOG( SG_IO, SG_INFO, "Remote FDM init() finished." );
+    SG_LOG( SG_IO, SG_ALERT, "Remote FDM init() finished." );
 #endif
 }
 
index 3650513856ca7600b7dacb491de20d96fc37ae23..f3f2191cb562ee1ff98b50289c603c78f15c3541 100644 (file)
@@ -1291,6 +1291,7 @@ static void fgMainLoop( void ) {
     sgVec3 source_pos_offset;
     sgSubVec3( source_pos_offset,
                view_location->get_view_pos(), acmodel_loc->get_view_pos() );
+    // cout << "pos all = " << source_pos_offset[0] << " " << source_pos_offset[1] << " " << source_pos_offset[2] << endl;
     globals->get_soundmgr()->set_source_pos_all( source_pos_offset );
 
     // set the velocity
@@ -1298,12 +1299,14 @@ static void fgMainLoop( void ) {
     sgSubVec3( source_vel, source_pos_offset, last_pos_offset );
     sgScaleVec3( source_vel, delta_time_sec );
     sgCopyVec3( last_pos_offset, source_pos_offset );
+    // cout << "vel = " << source_vel[0] << " " << source_vel[1] << " " << source_vel[2] << endl;
     globals->get_soundmgr()->set_source_vel_all( source_vel );
 
     // Right now we make a simplifying assumption that the listener is
     // always positioned at the origin.
     sgVec3 listener_pos;
     sgSetVec3( listener_pos, 0.0, 0.0, 0.0 );
+    // cout << "listener = " << listener_pos[0] << " " << listener_pos[1] << " " << listener_pos[2] << endl;
     globals->get_soundmgr()->set_listener_pos( listener_pos );
 #endif
 
index cf592db738cdc914499c86a22d4a2701ddec7c62..b16b331212b0992538b7a0352f8eb94ea8a4cbc3 100644 (file)
@@ -1768,14 +1768,14 @@ bool FGATC610x::do_switches() {
 
     // master switches
     fgSetBool( "/controls/engines/engine[0]/master-bat",
-               switch_matrix[board][5][1] );
+               switch_matrix[board][4][1] );
     fgSetBool( "/controls/engines/engine[1]/master-bat",
-               switch_matrix[board][5][1] );
+               switch_matrix[board][4][1] );
 
     fgSetBool( "/controls/engines/engine[0]/master-alt",
-               switch_matrix[board][4][1] );
+               switch_matrix[board][5][1] );
     fgSetBool( "/controls/engines/engine[1]/master-alt",
-               switch_matrix[board][4][1] );
+               switch_matrix[board][5][1] );
 
     fgSetBool( "/controls/switches/master-avionics",
                switch_matrix[board][0][3] );
index 24424c14a033ce8e4ad68addbaa1f96bcdfd3539..7b797a3a7dc8b4778a45e672776db809da707ce5 100644 (file)
 
 
 // constructor
-FGBeacon::FGBeacon() {
+FGBeacon::FGBeacon() :
+    inner(NULL),
+    middle(NULL),
+    outer(NULL)
+{
 }
 
 // destructor
 FGBeacon::~FGBeacon() {
+    delete inner;
+    delete middle;
+    delete outer;
 }
 
 
@@ -39,6 +46,10 @@ bool FGBeacon::init() {
     int len;
     unsigned char *ptr;
 
+    unsigned char inner_buf[ INNER_SIZE ] ;
+    unsigned char middle_buf[ MIDDLE_SIZE ] ;
+    unsigned char outer_buf[ OUTER_SIZE ] ;
+
     // Make inner marker beacon sound
     len= (int)(INNER_DIT_LEN / 2.0 );
     unsigned char inner_dit[INNER_DIT_LEN];
@@ -51,7 +62,7 @@ bool FGBeacon::init() {
        ptr += INNER_DIT_LEN;
     }
 
-    inner = new SGSoundSample( inner_buf, INNER_SIZE, BYTES_PER_SECOND );
+    inner = new SGSoundSample( inner_buf, INNER_SIZE, BYTES_PER_SECOND, false );
     inner->set_reference_dist( 10.0 );
     inner->set_max_dist( 20.0 );
 
@@ -71,7 +82,8 @@ bool FGBeacon::init() {
     ptr += MIDDLE_DIT_LEN;
     memcpy( ptr, middle_dah, MIDDLE_DAH_LEN );
 
-    middle = new SGSoundSample( middle_buf, MIDDLE_SIZE, BYTES_PER_SECOND );
+    middle = new SGSoundSample( middle_buf, MIDDLE_SIZE, BYTES_PER_SECOND,
+                                false );
     middle->set_reference_dist( 10.0 );
     middle->set_max_dist( 20.0 );
 
@@ -86,7 +98,7 @@ bool FGBeacon::init() {
     ptr += OUTER_DAH_LEN;
     memcpy( ptr, outer_dah, OUTER_DAH_LEN );
 
-    outer = new SGSoundSample( outer_buf, OUTER_SIZE, BYTES_PER_SECOND );
+    outer = new SGSoundSample( outer_buf, OUTER_SIZE, BYTES_PER_SECOND, false );
     outer->set_reference_dist( 10.0 );
     outer->set_max_dist( 20.0 );
 
index 6d680762239f3daf536d7186e3586103bb253256..def92896e7f66f9e312118450a513fda0feccc2a 100644 (file)
@@ -96,10 +96,6 @@ class FGBeacon {
 
 private:
 
-    unsigned char inner_buf[ INNER_SIZE ] ;
-    unsigned char middle_buf[ MIDDLE_SIZE ] ;
-    unsigned char outer_buf[ OUTER_SIZE ] ;
-
     SGSoundSample *inner;
     SGSoundSample *middle;
     SGSoundSample *outer;
index d2f9fc639017125413642faf26147a3d0f2d87e4..e88b2242aa6ae669eeea6aa058f3f8194a6925cb 100644 (file)
@@ -261,7 +261,12 @@ SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) {
 
     // 4. create the simple sound and return
     SGSoundSample *sample = new SGSoundSample( buffer, length,
-                                               BYTES_PER_SECOND );
+                                               BYTES_PER_SECOND,
+                                               false );
+
+    // clean up the buffer
+    delete [] buffer;
+
     sample->set_reference_dist( 10.0 );
     sample->set_max_dist( 20.0 );