summaryrefslogtreecommitdiff
path: root/libs/ardour/region.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-21 17:03:16 +0000
committerDavid Robillard <d@drobilla.net>2010-12-21 17:03:16 +0000
commitda89cd0c9b545c418fe2d6692844ff05779bb258 (patch)
tree6471696f49b6fedb07159bbf6e1389c0e48d0011 /libs/ardour/region.cc
parent71986da212b641b53c4583d0dca02cc87c758291 (diff)
Remove confuzzling offset_relative stuff from region construction (pre-properties "hangover").
This commit (in theory) only reorganizes code, not change actual functionality. RegionFactory now uses a distinct Region constructor for each case, which is a bit easier to wrap around. Note comment at region.cc:276, this case seems pretty weird to me (more hangover?). git-svn-id: svn://localhost/ardour2/branches/3.0@8320 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/region.cc')
-rw-r--r--libs/ardour/region.cc136
1 files changed, 78 insertions, 58 deletions
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index 6a2a6f1e30..5a89707495 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -245,14 +245,8 @@ Region::Region (const SourceList& srcs)
assert (_type == srcs.front()->type());
}
-/** Create a new Region from part of an existing one, starting at one of two places:
-
- if \a offset_relative is true, then the start within \a other is given by \a offset
- (i.e. relative to the start of \a other's sources, the start is \a offset + \a other.start()
-
- if @param offset_relative is false, then the start within the source is given \a offset.
-*/
-Region::Region (boost::shared_ptr<const Region> other, frameoffset_t offset, bool offset_relative)
+/** Create a new Region from an existing one */
+Region::Region (boost::shared_ptr<const Region> other)
: SessionObject(other->session(), other->name())
, _type (other->data_type())
, REGION_COPY_STATE (other)
@@ -276,70 +270,96 @@ Region::Region (boost::shared_ptr<const Region> other, frameoffset_t offset, boo
use_sources (other->_sources);
- if (!offset_relative) {
-
- /* not sure why we do this, but its a hangover from ardour before
- property lists. this would be nice to remove.
- */
-
- _position_lock_style = other->_position_lock_style;
- _first_edit = other->_first_edit;
-
- if (offset == 0) {
+ _position_lock_style = other->_position_lock_style;
+ _first_edit = other->_first_edit;
- _start = 0;
+ _start = 0; // It seems strange _start is not inherited here?
- /* sync pos is relative to start of file. our start-in-file is now zero,
- so set our sync position to whatever the the difference between
- _start and _sync_pos was in the other region.
+ /* sync pos is relative to start of file. our start-in-file is now zero,
+ so set our sync position to whatever the the difference between
+ _start and _sync_pos was in the other region.
- result is that our new sync pos points to the same point in our source(s)
- as the sync in the other region did in its source(s).
+ result is that our new sync pos points to the same point in our source(s)
+ as the sync in the other region did in its source(s).
- since we start at zero in our source(s), it is not possible to use a sync point that
- is before the start. reset it to _start if that was true in the other region.
- */
+ since we start at zero in our source(s), it is not possible to use a sync point that
+ is before the start. reset it to _start if that was true in the other region.
+ */
- if (other->sync_marked()) {
- if (other->_start < other->_sync_position) {
- /* sync pos was after the start point of the other region */
- _sync_position = other->_sync_position - other->_start;
- } else {
- /* sync pos was before the start point of the other region. not possible here. */
- _sync_marked = false;
- _sync_position = _start;
- }
- } else {
- _sync_marked = false;
- _sync_position = _start;
- }
+ if (other->sync_marked()) {
+ if (other->_start < other->_sync_position) {
+ /* sync pos was after the start point of the other region */
+ _sync_position = other->_sync_position - other->_start;
} else {
- /* XXX do something else ! */
- fatal << string_compose (_("programming error: %1"), X_("Region+offset constructor used with illegal combination of offset+relative"))
- << endmsg;
- /*NOTREACHED*/
+ /* sync pos was before the start point of the other region. not possible here. */
+ _sync_marked = false;
+ _sync_position = _start;
}
-
} else {
+ _sync_marked = false;
+ _sync_position = _start;
+ }
- _start = other->_start + offset;
-
- /* if the other region had a distinct sync point
- set, then continue to use it as best we can.
- otherwise, reset sync point back to start.
+ if (Profile->get_sae()) {
+ /* reset sync point to start if its ended up
+ outside region bounds.
*/
+
+ if (_sync_position < _start || _sync_position >= _start + _length) {
+ _sync_marked = false;
+ _sync_position = _start;
+ }
+ }
+
+ assert (_type == other->data_type());
+}
+
+/** Create a new Region from part of an existing one.
+
+ the start within \a other is given by \a offset
+ (i.e. relative to the start of \a other's sources, the start is \a offset + \a other.start()
+*/
+Region::Region (boost::shared_ptr<const Region> other, frameoffset_t offset)
+ : SessionObject(other->session(), other->name())
+ , _type (other->data_type())
+ , REGION_COPY_STATE (other)
+ , _last_length (other->_last_length)
+ , _last_position(other->_last_position) \
+ , _first_edit (EditChangesNothing)
+ , _read_data_count(0)
+ , _last_layer_op (0)
+ , _pending_explicit_relayer (false)
+
+{
+ register_properties ();
+
+ /* override state that may have been incorrectly inherited from the other region
+ */
+
+ _position = 0;
+ _locked = false;
+ _whole_file = false;
+ _hidden = false;
+
+ use_sources (other->_sources);
+
+ _start = other->_start + offset;
- if (other->sync_marked()) {
- if (other->_sync_position < _start) {
- _sync_marked = false;
- _sync_position = _start;
- } else {
- _sync_position = other->_sync_position;
- }
- } else {
+ /* if the other region had a distinct sync point
+ set, then continue to use it as best we can.
+ otherwise, reset sync point back to start.
+ */
+
+ if (other->sync_marked()) {
+ if (other->_sync_position < _start) {
_sync_marked = false;
_sync_position = _start;
+ } else {
+ _sync_position = other->_sync_position;
}
+ } else {
+ _sync_marked = false;
+ _sync_position = _start;
}
if (Profile->get_sae()) {