diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-04-14 03:03:35 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-04-14 03:03:35 -0400 |
commit | 5764970709f15e85ec30c9cea89c318eb8114c58 (patch) | |
tree | 0e3ea92a0c26c3582ca31be5e9c48c3b4218aff4 /libs/ardour/sndfilesource.cc | |
parent | 062dd5b71d4aad9e8e83d51bf9277293cddaa2c2 (diff) |
more work on linking file existence and removability
Diffstat (limited to 'libs/ardour/sndfilesource.cc')
-rw-r--r-- | libs/ardour/sndfilesource.cc | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index 6bb0e46551..e0851602fc 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -31,6 +31,7 @@ #ifdef PLATFORM_WINDOWS #include <glibmm/convert.h> #endif +#include <glibmm/fileutils.h> #include <glibmm/miscutils.h> #include "ardour/sndfilesource.h" @@ -57,9 +58,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 (); } @@ -72,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 (); } @@ -89,11 +108,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) { @@ -160,24 +188,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; |