From 272399e833ed84e44475c334f0d20c574badb481 Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 9 Sep 2022 12:04:45 +0100 Subject: [PATCH] XMLSound: report failures via the new system Ensure that misconfigured XML-sound files are traced to the aircraft --- simgear/sound/xmlsound.cxx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/simgear/sound/xmlsound.cxx b/simgear/sound/xmlsound.cxx index a0ac5cf0..07e0e73e 100644 --- a/simgear/sound/xmlsound.cxx +++ b/simgear/sound/xmlsound.cxx @@ -33,12 +33,13 @@ #include #include +#include #include -#include -#include -#include #include #include +#include +#include +#include #include "sample_group.hxx" #include "sample.hxx" @@ -123,10 +124,10 @@ SGXmlSound::init( SGPropertyNode *root, if (condition != nullptr) _condition = sgReadCondition(root, condition); - if (!_property && !_condition) - SG_LOG(SG_SOUND, SG_DEV_WARN, - " Neither a condition nor a property specified" - " in section: " << _name); + if (!_property && !_condition) { + simgear::reportFailure(simgear::LoadFailure::Misconfigured, simgear::ErrorCode::AudioFX, + "SGXmlSound: node:" + _name, path); + } _delay = node->getDoubleValue("delay-sec", 0.0); @@ -315,8 +316,9 @@ SGXmlSound::init( SGPropertyNode *root, string soundFileStr = node->getStringValue("path", ""); _sample = new SGSoundSample(soundFileStr.c_str(), path); if (!_sample->file_path().exists()) { - SG_LOG(SG_SOUND, SG_WARN, "XML sound: couldn't find file: '" + soundFileStr + "'"); - return false; + simgear::reportFailure(simgear::LoadFailure::NotFound, simgear::ErrorCode::AudioFX, + "SGXmlSound: node:" + _name + "; can't find:" + soundFileStr, path); + return false; } _sample->set_relative_position( offset_pos );