From 77786e8e9b60fc0c25ac87aca896dac3626d2563 Mon Sep 17 00:00:00 2001 From: Automatic Release Builder Date: Mon, 5 Oct 2020 14:21:37 +0100 Subject: [PATCH] XMLSound: Avoid using exceptions for missing file Reducing how noisy our exception reporting is, by using simple return value from SGXMLSound::init. --- simgear/sound/xmlsound.cxx | 8 +++++--- simgear/sound/xmlsound.hxx | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/simgear/sound/xmlsound.cxx b/simgear/sound/xmlsound.cxx index 89331390..b358b2a6 100644 --- a/simgear/sound/xmlsound.cxx +++ b/simgear/sound/xmlsound.cxx @@ -84,7 +84,7 @@ SGXmlSound::~SGXmlSound() _pitch.clear(); } -void +bool SGXmlSound::init( SGPropertyNode *root, SGPropertyNode *node, SGSampleGroup *sgrp, @@ -315,8 +315,8 @@ SGXmlSound::init( SGPropertyNode *root, string soundFileStr = node->getStringValue("path", ""); _sample = new SGSoundSample(soundFileStr.c_str(), path); if (!_sample->file_path().exists()) { - throw sg_io_exception("XML sound: couldn't find file: '" + soundFileStr + "'"); - return; + SG_LOG(SG_SOUND, SG_WARN, "XML sound: couldn't find file: '" + soundFileStr + "'"); + return false; } _sample->set_relative_position( offset_pos ); @@ -328,6 +328,8 @@ SGXmlSound::init( SGPropertyNode *root, _sample->set_volume( v ); _sample->set_pitch( p ); _sgrp->add( _sample, _name ); + + return true; } void diff --git a/simgear/sound/xmlsound.hxx b/simgear/sound/xmlsound.hxx index 8b24acc6..11bbfcc4 100644 --- a/simgear/sound/xmlsound.hxx +++ b/simgear/sound/xmlsound.hxx @@ -107,7 +107,7 @@ public: * @param avionics A pointer to the pre-initialized avionics sample group. * @param path The path where the audio files remain. */ - virtual void init( SGPropertyNode *root, + virtual bool init( SGPropertyNode *root, SGPropertyNode *child, SGSampleGroup *sgrp, SGSampleGroup *avionics,