diff options
author | David Robillard <d@drobilla.net> | 2006-08-29 21:21:48 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-08-29 21:21:48 +0000 |
commit | 82232f06ba3eea4a2b4342ad91fab552f4044402 (patch) | |
tree | d517cb47c017f51e2ecd9450624b86eb70d9f97b /libs/ardour/reverse.cc | |
parent | 25d1670a61d19e795227b939a98be9cf5a050c67 (diff) |
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
Diffstat (limited to 'libs/ardour/reverse.cc')
-rw-r--r-- | libs/ardour/reverse.cc | 25 |
1 files changed, 13 insertions, 12 deletions
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<AudioRegion> 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<AudioSource*>(*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<AudioSource> asrc(boost::dynamic_pointer_cast<AudioSource>(*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<AudioSource> asrc(boost::dynamic_pointer_cast<AudioSource>(*si)); + asrc->mark_for_remove (); } } |