X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fsndfilesource.cc;h=6b019f6fd04925970ffef209b9425f81590d13eb;hb=be0da8ff5c1a3bfbdf0a2934a79aeeed26ade3bc;hp=cf75cffba3efeac06ef379ec70188461a73e20e9;hpb=2e3a84b15afb749fbbfd05d765badb53434188b0;p=ardour.git diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index cf75cffba3..6b019f6fd0 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -30,6 +30,10 @@ #include #include +#ifdef PLATFORM_WINDOWS +#include +#endif +#include #include #include "ardour/sndfilesource.h" @@ -56,9 +60,18 @@ const Source::Flag SndFileSource::default_writable_flags = Source::Flag ( SndFileSource::SndFileSource (Session& s, const XMLNode& node) : Source(s, node) , AudioFileSource (s, node) + , _descriptor (0) + , _broadcast_info (0) + , _capture_start (false) + , _capture_end (false) + , file_pos (0) + , xfade_buf (0) { init_sndfile (); + assert (Glib::file_test (_path, Glib::FILE_TEST_EXISTS)); + existence_check (); + if (open()) { throw failed_constructor (); } @@ -69,11 +82,20 @@ SndFileSource::SndFileSource (Session& s, const string& path, int chn, Flag flag : Source(s, DataType::AUDIO, path, flags) /* note that the origin of an external file is itself */ , AudioFileSource (s, path, Flag (flags & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy))) + , _descriptor (0) + , _broadcast_info (0) + , _capture_start (false) + , _capture_end (false) + , file_pos (0) + , xfade_buf (0) { _channel = chn; init_sndfile (); + assert (Glib::file_test (_path, Glib::FILE_TEST_EXISTS)); + existence_check (); + if (open()) { throw failed_constructor (); } @@ -84,11 +106,20 @@ SndFileSource::SndFileSource (Session& s, const string& path, const string& orig SampleFormat sfmt, HeaderFormat hf, framecnt_t rate, Flag flags) : Source(s, DataType::AUDIO, path, flags) , AudioFileSource (s, path, origin, flags, sfmt, hf) + , _descriptor (0) + , _broadcast_info (0) + , _capture_start (false) + , _capture_end (false) + , file_pos (0) + , xfade_buf (0) { int fmt = 0; init_sndfile (); + assert (!Glib::file_test (_path, Glib::FILE_TEST_EXISTS)); + existence_check (); + _file_is_new = true; switch (hf) { @@ -155,24 +186,12 @@ SndFileSource::SndFileSource (Session& s, const string& path, const string& orig void SndFileSource::init_sndfile () { - string file; - - _descriptor = 0; - - // lets try to keep the object initalizations here at the top - xfade_buf = 0; - _broadcast_info = 0; - /* although libsndfile says we don't need to set this, valgrind and source code shows us that we do. */ memset (&_info, 0, sizeof(_info)); - _capture_start = false; - _capture_end = false; - file_pos = 0; - if (destructive()) { xfade_buf = new Sample[xfade_frames]; _timeline_position = header_position_offset;