return rstr;
}
+SGPath SGSoundSample::file_path() const
+{
+ if (!_is_file) {
+ return SGPath();
+ }
+
+ return SGPath(_refname);
+}
+
+
#include <simgear/structure/SGSharedPtr.hxx>
#include <simgear/math/SGMath.hxx>
+class SGPath;
+
/**
* manages everything we need to know for an individual audio sample
*/
*/
inline bool is_file() const { return _is_file; }
+ SGPath file_path() const;
+
/**
* Test if this audio sample configuration has changed since the last call.
* Calling this function will reset the flag so calling it a second
if ( sample->is_file() ) {
int freq, format;
size_t size;
- bool res;
-
- res = load(sample_name, &sample_data, &format, &size, &freq);
- if (res == false) return buffer;
+ try {
+ bool res = load(sample_name, &sample_data, &format, &size, &freq);
+ if (res == false) return buffer;
+ } catch (sg_exception& e) {
+ SG_LOG(SG_GENERAL, SG_ALERT, "failed to load sound buffer:" << e.getFormattedMessage());
+ return NO_BUFFER;
+ }
+
sample->set_frequency( freq );
sample->set_format( format );
sample->set_size( size );
#include <simgear/debug/logstream.hxx>
#include <simgear/props/condition.hxx>
#include <simgear/math/SGMath.hxx>
-
+#include <simgear/structure/exception.hxx>
+#include <simgear/misc/sg_path.hxx>
#include "xmlsound.hxx"
_sgrp = sgrp;
}
_sample = new SGSoundSample( path.c_str(), node->getStringValue("path", ""));
+ if (!_sample->file_path().exists()) {
+ throw sg_io_exception("XML sound: couldn't find file: " + _sample->file_path().str());
+ }
+
_sample->set_relative_position( offset_pos );
_sample->set_direction( dir );
_sample->set_audio_cone( inner, outer, outer_gain );