summaryrefslogtreecommitdiff
path: root/libs/ardour/region.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/region.cc')
-rw-r--r--libs/ardour/region.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index efaa104d35..a4a1584792 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -1654,3 +1654,33 @@ Region::set_start_internal (framecnt_t s)
{
_start = s;
}
+
+framepos_t
+Region::earliest_possible_position () const
+{
+ if (_start > _position) {
+ return 0;
+ } else {
+ return _position - _start;
+ }
+}
+
+framecnt_t
+Region::latest_possible_frame () const
+{
+ framecnt_t minlen = max_framecnt;
+
+ for (SourceList::const_iterator i = _sources.begin(); i != _sources.end(); ++i) {
+ /* non-audio regions have a length that may vary based on their
+ * position, so we have to pass it in the call.
+ */
+ minlen = min (minlen, (*i)->length (_position));
+ }
+
+ /* the latest possible last frame is determined by the current
+ * position, plus the shortest source extent past _start.
+ */
+
+ return _position + (minlen - _start) - 1;
+}
+