]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/xmlsound.cxx
Patch to avoid the problem of the socket resource not yet being available
[simgear.git] / simgear / sound / xmlsound.cxx
index 8958af9108375c2ff68104eee4353b6719baa034..2ca9cdfa8f2f6379726149264e0e4309033a8ad8 100644 (file)
@@ -32,7 +32,8 @@
 #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"
 
@@ -83,7 +84,7 @@ SGXmlSound::~SGXmlSound()
 void
 SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node,
                  SGSampleGroup *sgrp, SGSampleGroup *avionics,
-                 const string &path)
+                 const SGPath& currentDir)
 {
 
    //
@@ -271,7 +272,11 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node,
    } else {
       _sgrp = sgrp;
    }
-   _sample = new SGSoundSample( path.c_str(), node->getStringValue("path", ""));
+   _sample = new SGSoundSample(node->getStringValue("path", ""), currentDir);
+   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 );