summaryrefslogtreecommitdiff
path: root/libs/ardour/reverse.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/reverse.cc')
-rw-r--r--libs/ardour/reverse.cc25
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 ();
}
}