From 82232f06ba3eea4a2b4342ad91fab552f4044402 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 29 Aug 2006 21:21:48 +0000 Subject: Merged with trunk R861 Possible new bugs - not very thoroughly tested, but at least functional at first glance git-svn-id: svn://localhost/ardour2/branches/midi@870 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/reverse.cc | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'libs/ardour/reverse.cc') diff --git a/libs/ardour/reverse.cc b/libs/ardour/reverse.cc index b981ff0722..15f90fec45 100644 --- a/libs/ardour/reverse.cc +++ b/libs/ardour/reverse.cc @@ -43,10 +43,10 @@ Reverse::~Reverse () } int -Reverse::run (AudioRegion& region) +Reverse::run (boost::shared_ptr region) { - AudioRegion::SourceList nsrcs; - AudioRegion::SourceList::iterator si; + SourceList nsrcs; + SourceList::iterator si; const jack_nframes_t blocksize = 256 * 1048; Sample buf[blocksize]; jack_nframes_t fpos; @@ -61,8 +61,8 @@ Reverse::run (AudioRegion& region) goto out; } - fend = region.start() + region.length(); - fstart = region.start(); + fend = region->start() + region->length(); + fstart = region->start(); if (blocksize < fend) { fpos =max(fstart, fend - blocksize); @@ -70,7 +70,7 @@ Reverse::run (AudioRegion& region) fpos = fstart; } - to_read = min (region.length(), blocksize); + to_read = min (region->length(), blocksize); /* now read it backwards */ @@ -78,12 +78,11 @@ Reverse::run (AudioRegion& region) uint32_t n; - for (n = 0, si = nsrcs.begin(); n < region.n_channels(); ++n, ++si) { - AudioSource* const asrc = dynamic_cast(*si); + for (n = 0, si = nsrcs.begin(); n < region->n_channels(); ++n, ++si) { /* read it in */ - if (region.audio_source (n).read (buf, fpos, to_read) != to_read) { + if (region->audio_source (n)->read (buf, fpos, to_read) != to_read) { goto out; } @@ -95,7 +94,9 @@ Reverse::run (AudioRegion& region) /* write it out */ - if (asrc->write (buf, to_read) != to_read) { + boost::shared_ptr asrc(boost::dynamic_pointer_cast(*si)); + + if (asrc && asrc->write (buf, to_read) != to_read) { goto out; } } @@ -117,8 +118,8 @@ Reverse::run (AudioRegion& region) if (ret) { for (si = nsrcs.begin(); si != nsrcs.end(); ++si) { - (*si)->mark_for_remove (); - delete *si; + boost::shared_ptr asrc(boost::dynamic_pointer_cast(*si)); + asrc->mark_for_remove (); } } -- cgit v1.2.3