Use auto_ptr when calling SGSoundSample
This commit is contained in:
parent
7d6631d9a6
commit
e2678830ba
3 changed files with 11 additions and 9 deletions
|
@ -237,8 +237,10 @@ void FGATC::Render(string& msg, const float volume,
|
|||
// >>> Beware: must pass a (new) object to the (add) method,
|
||||
// >>> because the (remove) method is going to do a (delete)
|
||||
// >>> whether that's what you want or not.
|
||||
std::auto_ptr<unsigned char> ptr;
|
||||
ptr.reset((unsigned char*) buf.c_str());
|
||||
SGSoundSample *simple =
|
||||
new SGSoundSample((unsigned char*) buf.c_str(), buf.length(), 8000);
|
||||
new SGSoundSample(ptr, buf.length(), 8000);
|
||||
// TODO - at the moment the volume can't be changed
|
||||
// after the transmission has started.
|
||||
simple->set_volume(volume);
|
||||
|
|
|
@ -41,9 +41,9 @@ bool FGBeacon::init() {
|
|||
int len;
|
||||
unsigned char *ptr;
|
||||
|
||||
unsigned char *inner_buf = new unsigned char[ INNER_SIZE ] ;
|
||||
unsigned char *middle_buf = new unsigned char[ MIDDLE_SIZE ] ;
|
||||
unsigned char *outer_buf = new unsigned char[ OUTER_SIZE ] ;
|
||||
std::auto_ptr<unsigned char>inner_buf( new unsigned char[ INNER_SIZE ] );
|
||||
std::auto_ptr<unsigned char>middle_buf( new unsigned char[ MIDDLE_SIZE ] );
|
||||
std::auto_ptr<unsigned char>outer_buf( new unsigned char[ OUTER_SIZE ] );
|
||||
|
||||
// Make inner marker beacon sound
|
||||
len= (int)(INNER_DIT_LEN / 2.0 );
|
||||
|
@ -51,7 +51,7 @@ bool FGBeacon::init() {
|
|||
make_tone( inner_dit, INNER_FREQ, len, INNER_DIT_LEN,
|
||||
TRANSITION_BYTES );
|
||||
|
||||
ptr = inner_buf;
|
||||
ptr = inner_buf.get();
|
||||
for ( i = 0; i < 6; ++i ) {
|
||||
memcpy( ptr, inner_dit, INNER_DIT_LEN );
|
||||
ptr += INNER_DIT_LEN;
|
||||
|
@ -73,7 +73,7 @@ bool FGBeacon::init() {
|
|||
make_tone( middle_dah, MIDDLE_FREQ, len, MIDDLE_DAH_LEN,
|
||||
TRANSITION_BYTES );
|
||||
|
||||
ptr = middle_buf;
|
||||
ptr = middle_buf.get();
|
||||
memcpy( ptr, middle_dit, MIDDLE_DIT_LEN );
|
||||
ptr += MIDDLE_DIT_LEN;
|
||||
memcpy( ptr, middle_dah, MIDDLE_DAH_LEN );
|
||||
|
@ -88,7 +88,7 @@ bool FGBeacon::init() {
|
|||
make_tone( outer_dah, OUTER_FREQ, len, OUTER_DAH_LEN,
|
||||
TRANSITION_BYTES );
|
||||
|
||||
ptr = outer_buf;
|
||||
ptr = outer_buf.get();
|
||||
memcpy( ptr, outer_dah, OUTER_DAH_LEN );
|
||||
ptr += OUTER_DAH_LEN;
|
||||
memcpy( ptr, outer_dah, OUTER_DAH_LEN );
|
||||
|
|
|
@ -219,10 +219,10 @@ SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) {
|
|||
length += 2 * SPACE_SIZE;
|
||||
|
||||
// 2. Allocate space for the message
|
||||
unsigned char *buffer = new unsigned char[length];
|
||||
std::auto_ptr<unsigned char>buffer( new unsigned char[length] );
|
||||
|
||||
// 3. Assemble the message;
|
||||
unsigned char *buf_ptr = buffer;
|
||||
unsigned char *buf_ptr = buffer.get();
|
||||
|
||||
for ( i = 0; i < (int)id.length(); ++i ) {
|
||||
if ( idptr[i] >= 'A' && idptr[i] <= 'Z' ) {
|
||||
|
|
Loading…
Add table
Reference in a new issue