diff options
author | Ben Loftis <ben@harrisonconsoles.com> | 2018-11-15 09:33:54 -0600 |
---|---|---|
committer | Ben Loftis <ben@harrisonconsoles.com> | 2019-08-01 12:11:31 -0500 |
commit | edde5d64a2630c6d79239b92f2fe428022626dde (patch) | |
tree | 4f7f9c05924dc3e6759ecead705e0606767c848c | |
parent | 77950c36c5532b0696dc89f108fcc18af9fd08f8 (diff) |
(Source List) Clean up the natural_position implementation (libardour part).
-rw-r--r-- | libs/ardour/analyser.cc | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/audiofilesource.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/caimportable.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/coreaudiosource.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/silentfilesource.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/sndfileimportable.h | 6 | ||||
-rw-r--r-- | libs/ardour/ardour/sndfilesource.h | 6 | ||||
-rw-r--r-- | libs/ardour/ardour/source.h | 10 | ||||
-rw-r--r-- | libs/ardour/ardour/srcfilesource.h | 2 | ||||
-rw-r--r-- | libs/ardour/audio_track.cc | 2 | ||||
-rw-r--r-- | libs/ardour/audioregion.cc | 2 | ||||
-rw-r--r-- | libs/ardour/audiosource.cc | 4 | ||||
-rw-r--r-- | libs/ardour/disk_writer.cc | 13 | ||||
-rw-r--r-- | libs/ardour/file_source.cc | 2 | ||||
-rw-r--r-- | libs/ardour/filter.cc | 2 | ||||
-rw-r--r-- | libs/ardour/import.cc | 4 | ||||
-rw-r--r-- | libs/ardour/luabindings.cc | 2 | ||||
-rw-r--r-- | libs/ardour/midi_source.cc | 4 | ||||
-rw-r--r-- | libs/ardour/region_factory.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session.cc | 4 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 2 | ||||
-rw-r--r-- | libs/ardour/sndfilesource.cc | 50 | ||||
-rw-r--r-- | libs/ardour/source.cc | 37 | ||||
-rw-r--r-- | session_utils/fix_bbtppq.cc | 2 |
24 files changed, 91 insertions, 74 deletions
diff --git a/libs/ardour/analyser.cc b/libs/ardour/analyser.cc index 457291f72f..d524059c67 100644 --- a/libs/ardour/analyser.cc +++ b/libs/ardour/analyser.cc @@ -97,7 +97,7 @@ Analyser::work () boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src); - if (afs && afs->length(afs->timeline_position())) { + if (afs && afs->length(afs->natural_position())) { Glib::Threads::Mutex::Lock lm (analysis_active_lock); analyse_audio_file_source (afs); } diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h index 6a3e2569ce..9b4b5eecc7 100644 --- a/libs/ardour/ardour/audiofilesource.h +++ b/libs/ardour/ardour/audiofilesource.h @@ -99,7 +99,7 @@ protected: int init (const std::string& idstr, bool must_exist); - virtual void set_header_timeline_position () = 0; + virtual void set_header_natural_position () = 0; virtual void handle_header_position_change () {} int move_dependents_to_trash(); diff --git a/libs/ardour/ardour/caimportable.h b/libs/ardour/ardour/caimportable.h index 23fc1782ed..044ebc9b39 100644 --- a/libs/ardour/ardour/caimportable.h +++ b/libs/ardour/ardour/caimportable.h @@ -43,7 +43,6 @@ class LIBARDOUR_API CAImportableSource : public ImportableSource { samplecnt_t length() const; samplecnt_t samplerate() const; void seek (samplepos_t pos); - samplepos_t natural_position() const { return 0; } bool clamped_at_unity () const { return false; } protected: diff --git a/libs/ardour/ardour/coreaudiosource.h b/libs/ardour/ardour/coreaudiosource.h index f61c6bb984..73951f52d4 100644 --- a/libs/ardour/ardour/coreaudiosource.h +++ b/libs/ardour/ardour/coreaudiosource.h @@ -46,7 +46,7 @@ class LIBARDOUR_API CoreAudioSource : public AudioFileSource { uint32_t channel_count () const { return n_channels; } int flush_header () {return 0;}; - void set_header_timeline_position () {}; + void set_header_natural_position () {}; bool clamped_at_unity () const { return false; } void flush () {} diff --git a/libs/ardour/ardour/silentfilesource.h b/libs/ardour/ardour/silentfilesource.h index 79dc8b0a50..a36c2d4c2a 100644 --- a/libs/ardour/ardour/silentfilesource.h +++ b/libs/ardour/ardour/silentfilesource.h @@ -59,7 +59,7 @@ protected: samplecnt_t write_unlocked (Sample */*dst*/, samplecnt_t /*cnt*/) { return 0; } - void set_header_timeline_position () {} + void set_header_natural_position () {} int read_peaks_with_fpp (PeakData *peaks, samplecnt_t npeaks, samplepos_t /*start*/, samplecnt_t /*cnt*/, double /*samples_per_pixel*/, samplecnt_t /*fpp*/) const { diff --git a/libs/ardour/ardour/sndfileimportable.h b/libs/ardour/ardour/sndfileimportable.h index cbb34508d4..4225cbad64 100644 --- a/libs/ardour/ardour/sndfileimportable.h +++ b/libs/ardour/ardour/sndfileimportable.h @@ -37,9 +37,9 @@ public: uint32_t channels() const; samplecnt_t length() const; samplecnt_t samplerate() const; - void seek (samplepos_t pos); - samplepos_t natural_position() const; - bool clamped_at_unity () const; + void seek (samplepos_t pos); + bool clamped_at_unity () const; + samplepos_t natural_position () const; protected: SF_INFO sf_info; diff --git a/libs/ardour/ardour/sndfilesource.h b/libs/ardour/ardour/sndfilesource.h index 788ac4773b..8a91c6364e 100644 --- a/libs/ardour/ardour/sndfilesource.h +++ b/libs/ardour/ardour/sndfilesource.h @@ -60,8 +60,6 @@ class LIBARDOUR_API SndFileSource : public AudioFileSource { int flush_header (); void flush (); - samplepos_t natural_position () const; - samplepos_t last_capture_start_sample() const; void mark_capture_start (samplepos_t); void mark_capture_end (); @@ -81,7 +79,7 @@ class LIBARDOUR_API SndFileSource : public AudioFileSource { void close (); void set_path (const std::string& p); - void set_header_timeline_position (); + void set_header_natural_position (); samplecnt_t read_unlocked (Sample *dst, samplepos_t start, samplecnt_t cnt) const; samplecnt_t write_unlocked (Sample *dst, samplecnt_t cnt); @@ -111,7 +109,7 @@ class LIBARDOUR_API SndFileSource : public AudioFileSource { Sample* xfade_buf; samplecnt_t crossfade (Sample* data, samplecnt_t cnt, int dir); - void set_timeline_position (samplepos_t); + void set_natural_position (samplepos_t); samplecnt_t destructive_write_unlocked (Sample *dst, samplecnt_t cnt); samplecnt_t nondestructive_write_unlocked (Sample *dst, samplecnt_t cnt); void handle_header_position_change (); diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index d6ed19b610..25581b2007 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -74,8 +74,6 @@ public: void set_take_id (std::string id) { _take_id =id; } const std::string& take_id () const { return _take_id; } - virtual samplepos_t natural_position() const { return 0; } - void mark_for_remove(); virtual void mark_streaming_write_started (const Lock& lock) {} @@ -104,8 +102,9 @@ public: std::string get_transients_path() const; int load_transients (const std::string&); - samplepos_t timeline_position() const { return _timeline_position; } - virtual void set_timeline_position (samplepos_t pos); + virtual samplepos_t natural_position() const { return _natural_position; } + virtual void set_natural_position (samplepos_t pos); + bool have_natural_position() const { return _have_natural_position; } void set_allow_remove_if_empty (bool yn); @@ -129,7 +128,8 @@ public: Flag _flags; time_t _timestamp; std::string _take_id; - samplepos_t _timeline_position; + samplepos_t _natural_position; + samplepos_t _have_natural_position; bool _analysed; mutable Glib::Threads::Mutex _lock; mutable Glib::Threads::Mutex _analysis_lock; diff --git a/libs/ardour/ardour/srcfilesource.h b/libs/ardour/ardour/srcfilesource.h index a7d23912ec..9123317c3c 100644 --- a/libs/ardour/ardour/srcfilesource.h +++ b/libs/ardour/ardour/srcfilesource.h @@ -38,7 +38,7 @@ public: int update_header (samplepos_t /*when*/, struct tm&, time_t) { return 0; } int flush_header () { return 0; } void flush () { } - void set_header_timeline_position () {}; + void set_header_natural_position () {}; void set_length (samplecnt_t /*len*/) {}; float sample_rate () const { return _session.nominal_sample_rate(); } diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index e9b7434c0c..f1199c3d8b 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -441,7 +441,7 @@ AudioTrack::freeze_me (InterThreadInfo& itt) PropertyList plist; plist.add (Properties::start, 0); - plist.add (Properties::length, srcs[0]->length(srcs[0]->timeline_position())); + plist.add (Properties::length, srcs[0]->length(srcs[0]->natural_position())); plist.add (Properties::name, region_name); plist.add (Properties::whole_file, true); diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 86b801e434..b9c728d10f 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -462,7 +462,7 @@ AudioRegion::master_read_at (Sample *buf, Sample* /*mixdown_buffer*/, float* /*g assert (cnt >= 0); return read_from_sources ( - _master_sources, _master_sources.front()->length (_master_sources.front()->timeline_position()), + _master_sources, _master_sources.front()->length (_master_sources.front()->natural_position()), buf, position, cnt, chan_n ); } diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index ecb4358d70..fa2d1972ce 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -267,7 +267,7 @@ AudioSource::initialize_peakfile (const string& audio_path, const bool in_sessio /* we found it in the peaks dir, so check it out */ - if (statbuf.st_size == 0 || (statbuf.st_size < (off_t) ((length(_timeline_position) / _FPP) * sizeof (PeakData)))) { + if (statbuf.st_size == 0 || (statbuf.st_size < (off_t) ((length(_natural_position) / _FPP) * sizeof (PeakData)))) { DEBUG_TRACE(DEBUG::Peaks, string_compose("Peakfile %1 is empty\n", _peakpath)); _peaks_built = false; } else { @@ -1066,7 +1066,7 @@ samplecnt_t AudioSource::available_peaks (double zoom_factor) const { if (zoom_factor < _FPP) { - return length(_timeline_position); // peak data will come from the audio file + return length(_natural_position); // peak data will come from the audio file } /* peak data comes from peakfile, but the filesize might not represent diff --git a/libs/ardour/disk_writer.cc b/libs/ardour/disk_writer.cc index e0dcb42453..0073fabec9 100644 --- a/libs/ardour/disk_writer.cc +++ b/libs/ardour/disk_writer.cc @@ -328,7 +328,7 @@ void DiskWriter::non_realtime_locate (samplepos_t position) { if (_midi_write_source) { - _midi_write_source->set_timeline_position (position); + _midi_write_source->set_natural_position (position); } DiskIOProcessor::non_realtime_locate (position); @@ -1219,9 +1219,7 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo char buf[128]; strftime (buf, sizeof(buf), "%F %H.%M.%S", &when); as->set_take_id ( buf ); - - Source::SourcePropertyChanged(as); - + if (Config->get_auto_analyse_audio()) { Analyser::queue_source_for_analysis (as, true); } @@ -1232,6 +1230,11 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo if (_midi_write_source) { midi_srcs.push_back (_midi_write_source); } + + (*chan)->write_source->stamp (twhen); + + /* "re-announce the source to the world */ + Source::SourcePropertyChanged ((*chan)->write_source); } @@ -1261,7 +1264,7 @@ DiskWriter::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abo midi_srcs.push_back (_midi_write_source); - _midi_write_source->set_timeline_position (capture_info.front()->start); + _midi_write_source->set_natural_position (capture_info.front()->start); _midi_write_source->set_captured_for (_name); char buf[128]; diff --git a/libs/ardour/file_source.cc b/libs/ardour/file_source.cc index 37af5b8c38..2757b9275a 100644 --- a/libs/ardour/file_source.cc +++ b/libs/ardour/file_source.cc @@ -116,8 +116,6 @@ FileSource::removable () const int FileSource::init (const string& pathstr, bool must_exist) { - _timeline_position = 0; - if (Stateful::loading_state_version < 3000) { if (!find_2X (_session, _type, pathstr, must_exist, _file_is_new, _channel, _path)) { throw MissingSource (pathstr, _type); diff --git a/libs/ardour/filter.cc b/libs/ardour/filter.cc index 96e7cfa3d7..65c5a25271 100644 --- a/libs/ardour/filter.cc +++ b/libs/ardour/filter.cc @@ -119,7 +119,7 @@ Filter::finish (boost::shared_ptr<Region> region, SourceList& nsrcs, string regi boost::shared_ptr<SMFSource> smfs = boost::dynamic_pointer_cast<SMFSource>(*si); if (smfs) { - smfs->set_timeline_position (region->position()); + smfs->set_natural_position (region->position()); smfs->flush (); } diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index 083037b9fa..6c74773c71 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -184,7 +184,7 @@ static bool create_mono_sources_for_writing (const vector<string>& new_paths, Session& sess, uint32_t samplerate, vector<boost::shared_ptr<Source> >& newfiles, - samplepos_t timeline_position) + samplepos_t natural_position) { for (vector<string>::const_iterator i = new_paths.begin(); i != new_paths.end(); ++i) { @@ -212,7 +212,7 @@ create_mono_sources_for_writing (const vector<string>& new_paths, boost::shared_ptr<AudioFileSource> afs; if ((afs = boost::dynamic_pointer_cast<AudioFileSource>(source)) != 0) { - afs->set_timeline_position(timeline_position); + afs->set_natural_position (natural_position); } } return true; diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index fde6d594e9..bbc81bb243 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -1285,7 +1285,7 @@ LuaBindings::common (lua_State* L) .addFunction ("writable", &Source::writable) .addFunction ("has_been_analysed", &Source::has_been_analysed) .addFunction ("can_be_analysed", &Source::can_be_analysed) - .addFunction ("timeline_position", &Source::timeline_position) + .addFunction ("timeline_position", &Source::natural_position) /* duplicate */ .addFunction ("use_count", &Source::use_count) .addFunction ("used", &Source::used) .addFunction ("ancestor_name", &Source::ancestor_name) diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc index ba344991f6..55b8004101 100644 --- a/libs/ardour/midi_source.cc +++ b/libs/ardour/midi_source.cc @@ -352,7 +352,7 @@ MidiSource::mark_write_starting_now (samplecnt_t position, because it is not RT-safe. */ - set_timeline_position(position); + set_natural_position (position); _capture_length = capture_length; _capture_loop_length = loop_length; @@ -417,7 +417,7 @@ MidiSource::write_to (const Lock& lock, boost::shared_ptr<MidiSource> newsrc, Te { Lock newsrc_lock (newsrc->mutex ()); - newsrc->set_timeline_position (_timeline_position); + newsrc->set_natural_position (_natural_position); newsrc->copy_interpolation_from (this); newsrc->copy_automation_state_from (this); diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc index ea46c6d471..c641ddefda 100644 --- a/libs/ardour/region_factory.cc +++ b/libs/ardour/region_factory.cc @@ -194,7 +194,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs, if ((other = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) { - // XXX use me in caller where plist is setup, this is start i think srcs.front()->length (srcs.front()->timeline_position()) + // XXX use me in caller where plist is setup, this is start i think srcs.front()->length (srcs.front()->natural_position()) ret = boost::shared_ptr<Region> (new AudioRegion (other, srcs)); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 4bb8742ed0..d78602a87a 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -6274,7 +6274,7 @@ Session::write_one_track (Track& track, samplepos_t start, samplepos_t end, if (!endpoint || for_export) { ev.set_time(ev.time() - position); } - ms->append_event_samples(lock, ev, ms->timeline_position()); + ms->append_event_samples(lock, ev, ms->natural_position()); } } } @@ -6328,7 +6328,7 @@ Session::write_one_track (Track& track, samplepos_t start, samplepos_t end, PropertyList plist; plist.add (Properties::start, 0); - plist.add (Properties::length, srcs.front()->length(srcs.front()->timeline_position())); + plist.add (Properties::length, srcs.front()->length(srcs.front()->natural_position())); plist.add (Properties::name, region_name_from_path (srcs.front()->name(), true)); result = RegionFactory::create (srcs, plist); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index e02fefc3b6..72b3a869c7 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -3411,7 +3411,7 @@ Session::cleanup_sources (CleanupReport& rep) * capture files. */ - if (!i->second->used() && (i->second->length(i->second->timeline_position()) > 0)) { + if (!i->second->used() && (i->second->length(i->second->natural_position()) > 0)) { dead_sources.push_back (i->second); i->second->drop_references (); } diff --git a/libs/ardour/sndfilesource.cc b/libs/ardour/sndfilesource.cc index ac10f94ae1..35e91ba65a 100644 --- a/libs/ardour/sndfilesource.cc +++ b/libs/ardour/sndfilesource.cc @@ -350,7 +350,7 @@ SndFileSource::init_sndfile () if (destructive()) { xfade_buf = new Sample[xfade_samples]; - _timeline_position = header_position_offset; + _natural_position = header_position_offset; } AudioFileSource::HeaderPositionOffsetChanged.connect_same_thread (header_position_connection, boost::bind (&SndFileSource::handle_header_position_change, this)); @@ -447,15 +447,22 @@ SndFileSource::open () if (_file_is_new && _length == 0 && writable() && !bwf_info_exists) { /* newly created files will not have a BWF header at this point in time. - * Import will have called Source::set_timeline_position() if one exists + * Import will have called Source::set_natural_position() if one exists * in the original. */ - header_position_offset = _timeline_position; + header_position_offset = _natural_position; } - /* Set our timeline position to either the time reference from a BWF header or the current - start of the session. - */ - set_timeline_position (bwf_info_exists ? _broadcast_info->get_time_reference() : header_position_offset); + if (destructive()) { + /* Set our timeline position to either the time reference from a BWF header or the current + start of the session. + */ + set_natural_position (bwf_info_exists ? _broadcast_info->get_time_reference() : header_position_offset); + } else { + /* If a BWF header exists, set our _natural_position from it */ + if (bwf_info_exists) { + set_natural_position (_broadcast_info->get_time_reference()); + } + } if (_length != 0 && !bwf_info_exists) { delete _broadcast_info; @@ -668,7 +675,7 @@ SndFileSource::destructive_write_unlocked (Sample* data, samplecnt_t cnt) _capture_end = false; /* move to the correct location place */ - file_pos = capture_start_sample - _timeline_position; + file_pos = capture_start_sample - _natural_position; // split cnt in half samplecnt_t subcnt = cnt / 2; @@ -700,7 +707,7 @@ SndFileSource::destructive_write_unlocked (Sample* data, samplecnt_t cnt) _capture_end = false; /* move to the correct location place */ - file_pos = capture_start_sample - _timeline_position; + file_pos = capture_start_sample - _natural_position; if (crossfade (data, cnt, 1) != cnt) { return 0; @@ -742,7 +749,7 @@ SndFileSource::destructive_write_unlocked (Sample* data, samplecnt_t cnt) int SndFileSource::update_header (samplepos_t when, struct tm& now, time_t tnow) { - set_timeline_position (when); + set_natural_position (when); if (_flags & Broadcast) { if (setup_broadcast_info (when, now, tnow)) { @@ -810,20 +817,20 @@ SndFileSource::setup_broadcast_info (samplepos_t /*when*/, struct tm& now, time_ /* now update header position taking header offset into account */ - set_header_timeline_position (); + set_header_natural_position (); return 0; } void -SndFileSource::set_header_timeline_position () +SndFileSource::set_header_natural_position () { if (!(_flags & Broadcast)) { return; } assert (_broadcast_info); - _broadcast_info->set_time_reference (_timeline_position); + _broadcast_info->set_time_reference (_natural_position); if (_sndfile == 0 || !_broadcast_info->write_to_file (_sndfile)) { error << string_compose (_("cannot set broadcast info for audio file %1 (%2); dropping broadcast info for this file"), @@ -855,12 +862,6 @@ SndFileSource::write_float (Sample* data, samplepos_t sample_pos, samplecnt_t cn return cnt; } -samplepos_t -SndFileSource::natural_position() const -{ - return _timeline_position; -} - void SndFileSource::clear_capture_marks () { @@ -873,7 +874,7 @@ void SndFileSource::mark_capture_start (samplepos_t pos) { if (destructive()) { - if (pos < _timeline_position) { + if (pos < _natural_position) { _capture_start = false; } else { _capture_start = true; @@ -1031,8 +1032,8 @@ SndFileSource::handle_header_position_change () error << string_compose(_("Filesource: start time is already set for existing file (%1): Cannot change start time."), _path ) << endmsg; //in the future, pop up a dialog here that allows user to regenerate file with new start offset } else if (writable()) { - _timeline_position = header_position_offset; - set_header_timeline_position (); //this will get flushed if/when the file is recorded to + _natural_position = header_position_offset; + set_header_natural_position (); //this will get flushed if/when the file is recorded to } } } @@ -1056,14 +1057,14 @@ SndFileSource::setup_standard_crossfades (Session const & s, samplecnt_t rate) } void -SndFileSource::set_timeline_position (samplepos_t pos) +SndFileSource::set_natural_position (samplepos_t pos) { // destructive track timeline postion does not change // except at instantion or when header_position_offset // (session start) changes if (!destructive()) { - AudioFileSource::set_timeline_position (pos); + AudioFileSource::set_natural_position (pos); } } @@ -1149,4 +1150,3 @@ SndFileSource::set_path (const string& p) { FileSource::set_path (p); } - diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc index 003fd35fe1..236a0052dd 100644 --- a/libs/ardour/source.cc +++ b/libs/ardour/source.cc @@ -59,8 +59,9 @@ Source::Source (Session& s, DataType type, const string& name, Flag flags) : SessionObject(s, name) , _type(type) , _flags(flags) - , _timeline_position(0) - , _use_count (0) + , _natural_position(0) + , _have_natural_position (false) + , _use_count (0) , _level (0) { _analysed = false; @@ -72,7 +73,8 @@ Source::Source (Session& s, const XMLNode& node) : SessionObject(s, "unnamed source") , _type(DataType::AUDIO) , _flags (Flag (Writable|CanRename)) - , _timeline_position(0) + , _natural_position(0) + , _have_natural_position (false) , _use_count (0) , _level (0) { @@ -111,7 +113,12 @@ Source::get_state () node->set_property ("id", id()); if (_timestamp != 0) { - node->set_property ("timestamp", (int64_t)_timestamp); + int64_t t = _timestamp; + node->set_property ("timestamp", t); + } + + if (_have_natural_position) { + node->set_property ("natural-position", _natural_position); } return *node; @@ -135,13 +142,25 @@ Source::set_state (const XMLNode& node, int version) int64_t t; if (node.get_property ("timestamp", t)) { - _timestamp = t; + _timestamp = (time_t) t; + } + + samplepos_t ts; + if (node.get_property ("natural-position", ts)) { + _natural_position = ts; + _have_natural_position = true; + } else if (node.get_property ("timeline-position", ts)) { + /* some older versions of ardour might have stored this with + this property name. + */ + _natural_position = ts; + _have_natural_position = true; } if (!node.get_property (X_("flags"), _flags)) { _flags = Flag (0); } - + if (!node.get_property (X_("take-id"), _take_id)) { _take_id = ""; } @@ -273,9 +292,10 @@ Source::mark_for_remove () } void -Source::set_timeline_position (samplepos_t pos) +Source::set_natural_position (samplepos_t pos) { - _timeline_position = pos; + _natural_position = pos; + _have_natural_position = true; } void @@ -332,4 +352,3 @@ Source::writable () const { return (_flags & Writable) && _session.writable(); } - diff --git a/session_utils/fix_bbtppq.cc b/session_utils/fix_bbtppq.cc index d8a04a120c..a7119bd5f9 100644 --- a/session_utils/fix_bbtppq.cc +++ b/session_utils/fix_bbtppq.cc @@ -76,7 +76,7 @@ write_bbt_source_to_source (boost::shared_ptr<MidiSource> bbt_source, boost::sh bbt_source->model()->set_percussive (old_percussive); source->mark_streaming_write_completed (source_lock); - source->set_timeline_position (bbt_source->timeline_position()); + source->set_natural_position (bbt_source->natural_position()); return true; } |