Performance improvement
Avoid frequently creating/dropping an identical sound sample, when the nav radio signal is flickering. Always keep most recent sound when signal is lost (only stop it/turn volume off).
This commit is contained in:
parent
6b1391e404
commit
cc40660206
2 changed files with 13 additions and 2 deletions
|
@ -524,6 +524,8 @@ void FGKR_87::search() {
|
||||||
xyz = adf->cart();
|
xyz = adf->cart();
|
||||||
|
|
||||||
if ( _sgr->exists( "adf-ident" ) ) {
|
if ( _sgr->exists( "adf-ident" ) ) {
|
||||||
|
// stop is required! -- remove alone wouldn't stop immediately
|
||||||
|
_sgr->stop( "adf-ident" );
|
||||||
_sgr->remove( "adf-ident" );
|
_sgr->remove( "adf-ident" );
|
||||||
}
|
}
|
||||||
SGSoundSample *sound;
|
SGSoundSample *sound;
|
||||||
|
|
|
@ -70,7 +70,15 @@ void AudioIdent::setVolumeNorm( double volumeNorm )
|
||||||
|
|
||||||
void AudioIdent::setIdent( const std::string & ident, double volumeNorm )
|
void AudioIdent::setIdent( const std::string & ident, double volumeNorm )
|
||||||
{
|
{
|
||||||
if( _ident == ident ) {
|
// Signal may flicker very frequently (due to our realistic newnavradio...).
|
||||||
|
// Avoid recreating identical sound samples all the time, instead turn off
|
||||||
|
// volume when signal is lost, and save the most recent sample.
|
||||||
|
if (ident.empty())
|
||||||
|
volumeNorm = 0;
|
||||||
|
|
||||||
|
if(( _ident == ident )||
|
||||||
|
(volumeNorm == 0)) // don't bother with sounds when volume is OFF anyway...
|
||||||
|
{
|
||||||
if( false == _ident.empty() )
|
if( false == _ident.empty() )
|
||||||
setVolumeNorm( volumeNorm );
|
setVolumeNorm( volumeNorm );
|
||||||
return;
|
return;
|
||||||
|
@ -88,6 +96,7 @@ void AudioIdent::setIdent( const std::string & ident, double volumeNorm )
|
||||||
sound->set_volume( volumeNorm );
|
sound->set_volume( volumeNorm );
|
||||||
if (!_sgr->add( sound, _fx_name )) {
|
if (!_sgr->add( sound, _fx_name )) {
|
||||||
SG_LOG(SG_SOUND, SG_WARN, "Failed to add sound '" << _fx_name << "' for ident '" << ident << "'" );
|
SG_LOG(SG_SOUND, SG_WARN, "Failed to add sound '" << _fx_name << "' for ident '" << ident << "'" );
|
||||||
|
delete sound;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue