From e9bb1dc2bf72a3d27304595717b18105590872ac Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 28 Apr 2015 16:00:35 +0200 Subject: [PATCH] tape-track diskstream fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to the change to use a 64bit timeline (int64 as opposed to previously [unsigned] pframes_t) many cases special to tape-tracks no longer work. e.g. region->length() can returns -1, rather than INT64_MAX. which breaks ‘overlap’ in Evoral::Coverage. which in turn breaks tape track’s use of ::find_next_region(). This commits begins the slow process to move away from relying on integer overflow to wrap negative numbers for tape tracks and restores basic functionality. Still various edge cases pertaining tape tracks remain. particularly when changing the session start-time and moving destructive regions. --- libs/ardour/audio_diskstream.cc | 46 ++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index 2d4d02f830..7e673c99d1 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -74,6 +74,10 @@ AudioDiskstream::AudioDiskstream (Session &sess, const string &name, Diskstream: in_set_state = true; use_new_playlist (); in_set_state = false; + + if (flag & Destructive) { + use_destructive_playlist (); + } } AudioDiskstream::AudioDiskstream (Session& sess, const XMLNode& node) @@ -331,10 +335,13 @@ AudioDiskstream::setup_destructive_playlist () PropertyList plist; plist.add (Properties::name, _name.val()); plist.add (Properties::start, 0); - plist.add (Properties::length, max_framepos - (max_framepos - srcs.front()->natural_position())); + plist.add (Properties::length, max_framepos - srcs.front()->natural_position()); boost::shared_ptr region (RegionFactory::create (srcs, plist)); _playlist->add_region (region, srcs.front()->natural_position()); + + /* apply region properties and update write sources */ + use_destructive_playlist(); } void @@ -346,7 +353,14 @@ AudioDiskstream::use_destructive_playlist () with the (presumed single, full-extent) region. */ - boost::shared_ptr rp = _playlist->find_next_region (_session.current_start_frame(), Start, 1); + boost::shared_ptr rp; + { + const RegionList& rl (_playlist->region_list().rlist()); + if (rl.size() > 0) { + assert((rl.size() == 1)); + rp = rl.front(); + } + } if (!rp) { reset_write_sources (false, true); @@ -2324,6 +2338,13 @@ AudioDiskstream::can_become_destructive (bool& requires_bounce) const return false; } + /* if no regions are present: easy */ + + if (_playlist->n_regions() == 0) { + requires_bounce = false; + return true; + } + /* is there only one region ? */ if (_playlist->n_regions() != 1) { @@ -2331,7 +2352,14 @@ AudioDiskstream::can_become_destructive (bool& requires_bounce) const return false; } - boost::shared_ptr first = _playlist->find_next_region (_session.current_start_frame(), Start, 1); + boost::shared_ptr first; + { + const RegionList& rl (_playlist->region_list().rlist()); + assert((rl.size() == 1)); + first = rl.front(); + + } + if (!first) { requires_bounce = false; return true; @@ -2340,12 +2368,24 @@ AudioDiskstream::can_become_destructive (bool& requires_bounce) const /* do the source(s) for the region cover the session start position ? */ if (first->position() != _session.current_start_frame()) { + // what is the idea here? why start() ?? if (first->start() > _session.current_start_frame()) { requires_bounce = true; return false; } } + /* currently RouteTimeAxisView::set_track_mode does not + * implement bounce. Existing regions cannot be converted. + * + * so let's make sure this region is already set up + * as tape-track (spanning the complete range) + */ + if (first->length() != max_framepos - first->position()) { + requires_bounce = true; + return false; + } + /* is the source used by only 1 playlist ? */ boost::shared_ptr afirst = boost::dynamic_pointer_cast (first);