1
0
Fork 0

Adapt to SG 952d071c0 (SGSoundSample ctor now takes std::unique_ptr by value)

The aforementioned SG change[1] was done in line with Herb Sutter's
writing at [2] in order to clearly express sink semantics.

[1] 952d071c08/
[2] https://herbsutter.com/2013/06/05/gotw-91-solution-smart-pointer-parameters/
This commit is contained in:
Florent Rougon 2022-11-08 14:06:11 +01:00
parent 56f60c381f
commit 0deaec870a
3 changed files with 15 additions and 7 deletions

View file

@ -16,6 +16,9 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include <utility>
#include "VoiceSynthesizer.hxx" #include "VoiceSynthesizer.hxx"
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
@ -127,7 +130,7 @@ SGSoundSample * FLITEVoiceSynthesizer::synthesize(const std::string & text, doub
reinterpret_cast<unsigned char*>( data ), reinterpret_cast<unsigned char*>( data ),
free free
}; };
return new SGSoundSample(buf, return new SGSoundSample(std::move(buf),
count * sizeof(short), count * sizeof(short),
rate, rate,
SG_SAMPLE_MONO16); SG_SAMPLE_MONO16);

View file

@ -19,8 +19,9 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// //
#include <stdlib.h> #include <cstdlib>
#include <cstring> #include <cstring>
#include <utility>
#include "beacon.hxx" #include "beacon.hxx"
@ -68,7 +69,8 @@ bool FGBeacon::init() {
} }
try { try {
inner = new SGSoundSample( inner_buf, INNER_SIZE, BYTES_PER_SECOND ); inner = new SGSoundSample( std::move(inner_buf),
INNER_SIZE, BYTES_PER_SECOND );
inner->set_reference_dist( 10.0 ); inner->set_reference_dist( 10.0 );
inner->set_max_dist( 20.0 ); inner->set_max_dist( 20.0 );
@ -88,7 +90,8 @@ bool FGBeacon::init() {
ptr += MIDDLE_DIT_LEN; ptr += MIDDLE_DIT_LEN;
memcpy( ptr, middle_dah, MIDDLE_DAH_LEN ); memcpy( ptr, middle_dah, MIDDLE_DAH_LEN );
middle = new SGSoundSample( middle_buf, MIDDLE_SIZE, BYTES_PER_SECOND); middle = new SGSoundSample( std::move(middle_buf),
MIDDLE_SIZE, BYTES_PER_SECOND );
middle->set_reference_dist( 10.0 ); middle->set_reference_dist( 10.0 );
middle->set_max_dist( 20.0 ); middle->set_max_dist( 20.0 );
@ -103,7 +106,8 @@ bool FGBeacon::init() {
ptr += OUTER_DAH_LEN; ptr += OUTER_DAH_LEN;
memcpy( ptr, outer_dah, OUTER_DAH_LEN ); memcpy( ptr, outer_dah, OUTER_DAH_LEN );
outer = new SGSoundSample( outer_buf, OUTER_SIZE, BYTES_PER_SECOND ); outer = new SGSoundSample( std::move(outer_buf), OUTER_SIZE,
BYTES_PER_SECOND );
outer->set_reference_dist( 10.0 ); outer->set_reference_dist( 10.0 );
outer->set_max_dist( 20.0 ); outer->set_max_dist( 20.0 );
} catch ( sg_io_exception &e ) { } catch ( sg_io_exception &e ) {

View file

@ -26,8 +26,9 @@
#include <simgear/sound/sample.hxx> #include <simgear/sound/sample.hxx>
#include <cstdlib>
#include <cstring> #include <cstring>
#include <stdlib.h> #include <utility>
static const char DI = '1'; static const char DI = '1';
static const char DIT = '1'; static const char DIT = '1';
@ -235,7 +236,7 @@ SGSoundSample *FGMorse::make_ident( const std::string& id, const int freq ) {
buf_ptr += SPACE_SIZE; buf_ptr += SPACE_SIZE;
// 4. create the simple sound and return // 4. create the simple sound and return
SGSoundSample *sample = new SGSoundSample( buffer, length, SGSoundSample *sample = new SGSoundSample( std::move(buffer), length,
BYTES_PER_SECOND ); BYTES_PER_SECOND );
sample->set_reference_dist( 10.0 ); sample->set_reference_dist( 10.0 );