diff --git a/simgear/sound/sample.cxx b/simgear/sound/sample.cxx index 2ff503a6..c1a46a85 100644 --- a/simgear/sound/sample.cxx +++ b/simgear/sound/sample.cxx @@ -79,14 +79,19 @@ std::string SGSoundSampleInfo::random_string() // SGSoundSample // -// constructor -SGSoundSample::SGSoundSample(const char *file, const SGPath& currentDir) : +// Constructor +SGSoundSample::SGSoundSample(const SGPath& file) : _is_file(true) { - SGPath p = simgear::ResourceManager::instance()->findPath(file, currentDir); - _refname = p.utf8Str(); + _refname = file.utf8Str(); } +// Delegating constructor that goes through the ResourceManager +SGSoundSample::SGSoundSample(const string& file, const SGPath& dir) : + SGSoundSample( + simgear::ResourceManager::instance()->findPath(file, dir)) +{ } + // constructor SGSoundSample::SGSoundSample( std::unique_ptr& data, int len, int freq, int format ) diff --git a/simgear/sound/sample.hxx b/simgear/sound/sample.hxx index 804fe549..eb4f52fe 100644 --- a/simgear/sound/sample.hxx +++ b/simgear/sound/sample.hxx @@ -30,6 +30,8 @@ #ifndef _SG_SAMPLE_HXX #define _SG_SAMPLE_HXX 1 +#include + #include #include #include "soundmgr.hxx" @@ -259,11 +261,19 @@ public: virtual ~SGSoundSample () = default; /** - * Constructor - * @param file File name of sound + * Constructor that uses the specified path as is + * @param file Path to sound file Buffer data is freed by the sample group */ - SGSoundSample(const char *file, const SGPath& currentDir); + explicit SGSoundSample(const SGPath& file); + + /** + * Constructor that goes through ResourceManager::findPath() + * @param file File name of sound + @param dir “Context” argument for ResourceManager::findPath() + Buffer data is freed by the sample group + */ + SGSoundSample(const std::string& file, const SGPath& dir); /** * Constructor.