Clean up some sound buffer allocation/deallocation issues.
This commit is contained in:
parent
aadb3cb94f
commit
944a82b576
9 changed files with 36 additions and 18 deletions
|
@ -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"));
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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] );
|
||||
|
|
|
@ -25,11 +25,18 @@
|
|||
|
||||
|
||||
// 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 );
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue