X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSound%2Fmorse.cxx;h=942b637a5a2ae46ecf1687994fdd2e82983ce386;hb=fde1a925feb8ccc50e88e3fbe72a0863625de2a5;hp=92b671bca4471ee7def602724f47361f756c8af3;hpb=e8db3a514a3b24bb7b5e8d1395ce078c768981ab;p=flightgear.git diff --git a/src/Sound/morse.cxx b/src/Sound/morse.cxx index 92b671bca..942b637a5 100644 --- a/src/Sound/morse.cxx +++ b/src/Sound/morse.cxx @@ -168,10 +168,6 @@ bool FGMorse::cust_init(const int freq ) { // make a SGSoundSample morse code transmission for the specified string SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) { - if (globals->get_soundmgr()->is_working() == false) { - return 0; - } - char *idptr = (char *)id.c_str(); int length = 0; @@ -223,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]; + const unsigned char* buffer = (const unsigned char *)malloc(length); // 3. Assemble the message; - unsigned char *buf_ptr = buffer; + unsigned char *buf_ptr = (unsigned char*)buffer; for ( i = 0; i < (int)id.length(); ++i ) { if ( idptr[i] >= 'A' && idptr[i] <= 'Z' ) { @@ -265,12 +261,9 @@ SGSoundSample *FGMorse::make_ident( const string& id, const int freq ) { buf_ptr += SPACE_SIZE; // 4. create the simple sound and return - SGSoundSample *sample = new SGSoundSample( buffer, length, + SGSoundSample *sample = new SGSoundSample( &buffer, length, BYTES_PER_SECOND ); - // clean up the buffer - delete [] buffer; - sample->set_reference_dist( 10.0 ); sample->set_max_dist( 20.0 );