Tweak colouring in the processor list.
[ardour.git] / libs / ardour / sndfilesource.cc
index 0b67cd789eb8bf50e86b75c37442a528eeef1f1b..fa2e761d8edd327171e054c4ecb0e9718f5ca47b 100644 (file)
@@ -44,7 +44,7 @@
 using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
-using Glib::ustring;
+using std::string;
 
 gain_t* SndFileSource::out_coefficient = 0;
 gain_t* SndFileSource::in_coefficient = 0;
@@ -67,8 +67,9 @@ SndFileSource::SndFileSource (Session& s, const XMLNode& node)
 }
 
 /** Files created this way are never writable or removable */
-SndFileSource::SndFileSource (Session& s, const ustring& path, int chn, Flag flags)
+SndFileSource::SndFileSource (Session& s, const string& path, int chn, Flag flags)
        : 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)))
 {
        _channel = chn;
@@ -81,10 +82,10 @@ SndFileSource::SndFileSource (Session& s, const ustring& path, int chn, Flag fla
 }
 
 /** This constructor is used to construct new files, not open existing ones. */
-SndFileSource::SndFileSource (Session& s, const ustring& path, 
-               SampleFormat sfmt, HeaderFormat hf, nframes_t rate, Flag flags)
+SndFileSource::SndFileSource (Session& s, const string& path, const string& origin,
+                              SampleFormat sfmt, HeaderFormat hf, framecnt_t rate, Flag flags)
        : Source(s, DataType::AUDIO, path, flags)
-       , AudioFileSource (s, path, flags, sfmt, hf)
+       , AudioFileSource (s, path, origin, flags, sfmt, hf)
 {
        int fmt = 0;
 
@@ -178,7 +179,7 @@ SndFileSource::SndFileSource (Session& s, const ustring& path,
 void
 SndFileSource::init_sndfile ()
 {
-       ustring file;
+       string file;
 
        // lets try to keep the object initalizations here at the top
        xfade_buf = 0;
@@ -217,6 +218,8 @@ SndFileSource::open ()
                   so we don't want to see this message.
                */
 
+                cerr << "failed to open " << _path << " with name " << _name << endl;
+
                error << string_compose(_("SndFileSource: cannot open file \"%1\" for %2 (%3)"),
                                        _path, (writable() ? "read+write" : "reading"), errbuf) << endmsg;
 #endif
@@ -318,7 +321,7 @@ SndFileSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) con
                }
 
                if (_info.channels == 1) {
-                       nframes_t ret = sf_read_float (sf, dst, file_cnt);
+                       framecnt_t ret = sf_read_float (sf, dst, file_cnt);
                        _read_data_count = ret * sizeof(float);
                        if (ret != file_cnt) {
                                char errbuf[256];
@@ -417,8 +420,8 @@ SndFileSource::destructive_write_unlocked (Sample* data, framecnt_t cnt)
                file_pos = capture_start_frame - _timeline_position;
 
                // split cnt in half
-               nframes_t subcnt = cnt / 2;
-               nframes_t ofilepos = file_pos;
+               framecnt_t subcnt = cnt / 2;
+               framecnt_t ofilepos = file_pos;
 
                // fade in
                if (crossfade (data, subcnt, 1) != subcnt) {
@@ -487,7 +490,7 @@ SndFileSource::destructive_write_unlocked (Sample* data, framecnt_t cnt)
 }
 
 int
-SndFileSource::update_header (sframes_t when, struct tm& now, time_t tnow)
+SndFileSource::update_header (framepos_t when, struct tm& now, time_t tnow)
 {
        set_timeline_position (when);
 
@@ -521,7 +524,7 @@ SndFileSource::flush_header ()
 }
 
 int
-SndFileSource::setup_broadcast_info (sframes_t /*when*/, struct tm& now, time_t /*tnow*/)
+SndFileSource::setup_broadcast_info (framepos_t /*when*/, struct tm& now, time_t /*tnow*/)
 {
        if (!writable()) {
                warning << string_compose (_("attempt to store broadcast info in a non-writable audio file source (%1)"), _path) << endmsg;
@@ -532,7 +535,7 @@ SndFileSource::setup_broadcast_info (sframes_t /*when*/, struct tm& now, time_t
                return 0;
        }
 
-       _broadcast_info->set_originator_ref (_session);
+       _broadcast_info->set_originator_ref_from_session (_session);
        _broadcast_info->set_origination_time (&now);
 
        /* now update header position taking header offset into account */
@@ -631,8 +634,9 @@ SndFileSource::clear_capture_marks ()
        _capture_end = false;
 }
 
+/** @param pos Capture start position in session frames */
 void
-SndFileSource::mark_capture_start (sframes_t pos)
+SndFileSource::mark_capture_start (framepos_t pos)
 {
        if (destructive()) {
                if (pos < _timeline_position) {
@@ -775,7 +779,7 @@ SndFileSource::crossfade (Sample* data, framecnt_t cnt, int fade_in)
        return cnt;
 }
 
-sframes_t
+framepos_t
 SndFileSource::last_capture_start_frame () const
 {
        if (destructive()) {
@@ -800,7 +804,7 @@ SndFileSource::handle_header_position_change ()
 }
 
 void
-SndFileSource::setup_standard_crossfades (Session const & s, nframes_t rate)
+SndFileSource::setup_standard_crossfades (Session const & s, framecnt_t rate)
 {
        /* This static method is assumed to have been called by the Session
           before any DFS's are created.
@@ -818,7 +822,7 @@ SndFileSource::setup_standard_crossfades (Session const & s, nframes_t rate)
 }
 
 void
-SndFileSource::set_timeline_position (int64_t pos)
+SndFileSource::set_timeline_position (framepos_t pos)
 {
        // destructive track timeline postion does not change
        // except at instantion or when header_position_offset
@@ -830,7 +834,7 @@ SndFileSource::set_timeline_position (int64_t pos)
 }
 
 int
-SndFileSource::get_soundfile_info (const ustring& path, SoundFileInfo& info, string& error_msg)
+SndFileSource::get_soundfile_info (const string& path, SoundFileInfo& info, string& error_msg)
 {
        SNDFILE *sf;
        SF_INFO sf_info;
@@ -889,3 +893,13 @@ SndFileSource::file_closed ()
        
        touch_peakfile ();
 }
+
+void
+SndFileSource::set_path (const string& p)
+{
+        FileSource::set_path (p);
+
+        if (_descriptor) {
+                _descriptor->set_path (_path);
+        }
+}