diff options
author | David Robillard <d@drobilla.net> | 2009-10-20 02:14:53 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-10-20 02:14:53 +0000 |
commit | ed3b46e03bb06e8f0f1624c27fb72244fac23538 (patch) | |
tree | fab02c695794c0719d3bf382bb1adb1fb7258d88 /libs/ardour/diskstream.cc | |
parent | 22fd9aec55587a50c427fff8f5e800afcef6ac69 (diff) |
Factor out more duplicated code.
git-svn-id: svn://localhost/ardour2/branches/3.0@5819 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/diskstream.cc')
-rw-r--r-- | libs/ardour/diskstream.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc index 0b4c98eaa3..aaeb15a995 100644 --- a/libs/ardour/diskstream.cc +++ b/libs/ardour/diskstream.cc @@ -594,3 +594,48 @@ Diskstream::route_going_away () { _io.reset (); } + +void +Diskstream::calculate_record_range(OverlapType ot, sframes_t transport_frame, nframes_t nframes, + nframes_t& rec_nframes, nframes_t& rec_offset) +{ + switch (ot) { + case OverlapNone: + rec_nframes = 0; + break; + + case OverlapInternal: + /* ---------- recrange + |---| transrange + */ + rec_nframes = nframes; + rec_offset = 0; + break; + + case OverlapStart: + /* |--------| recrange + -----| transrange + */ + rec_nframes = transport_frame + nframes - first_recordable_frame; + if (rec_nframes) { + rec_offset = first_recordable_frame - transport_frame; + } + break; + + case OverlapEnd: + /* |--------| recrange + |-------- transrange + */ + rec_nframes = last_recordable_frame - transport_frame; + rec_offset = 0; + break; + + case OverlapExternal: + /* |--------| recrange + -------------- transrange + */ + rec_nframes = last_recordable_frame - first_recordable_frame; + rec_offset = first_recordable_frame - transport_frame; + break; + } +} |