Add option to limit automatable control parmaters
[ardour.git] / libs / ardour / auditioner.cc
index 58c7cd8c8f52221b80c44b0535c40bd27992d739..4903fe4181c795fd0e82b2cf16c040b43102131c 100644 (file)
@@ -220,7 +220,7 @@ Auditioner::data_type () const {
 }
 
 int
-Auditioner::roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, int declick, bool& need_butler)
+Auditioner::roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, bool& need_butler)
 {
        Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
        if (!lm.locked()) {
@@ -231,9 +231,6 @@ Auditioner::roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_s
 
        BufferSet& bufs = _session.get_route_buffers (n_process_buffers());
 
-       _silent = false;
-       _amp->apply_gain_automation(false);
-
        if (_queue_panic) {
                MidiBuffer& mbuf (bufs.get_midi (0));
                _queue_panic = false;
@@ -247,7 +244,7 @@ Auditioner::roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_s
                }
        }
 
-       process_output_buffers (bufs, start_sample, end_sample, nframes, declick, !_session.transport_stopped());
+       process_output_buffers (bufs, start_sample, end_sample, nframes, !_session.transport_stopped(), true);
 
        /* note: auditioner never writes to disk, so we don't care about the
         * disk writer status (it's buffers will always have no data in them).
@@ -380,6 +377,11 @@ Auditioner::audition_region (boost::shared_ptr<Region> region)
                offset = the_region->sync_offset (dir);
        }
 
+       if (length == 0) {
+               error << _("Cannot audition empty file.") << endmsg;
+               return;
+       }
+
        /* can't audition from a negative sync point */
 
        if (dir < 0) {
@@ -423,13 +425,20 @@ Auditioner::play_audition (samplecnt_t nframes)
                /* process audio */
                this_nframes = min (nframes, length - current_sample + _import_position);
 
-               if ((ret = roll (this_nframes, current_sample, current_sample + nframes, false, need_butler)) != 0) {
+               if (this_nframes > 0 && 0 != (ret = roll (this_nframes, current_sample, current_sample + this_nframes, need_butler))) {
                        silence (nframes);
                        return ret;
                }
 
                current_sample += this_nframes;
 
+               if (this_nframes < nframes) {
+                       if (this_nframes > 0) {
+                               _session.engine().split_cycle (this_nframes);
+                       }
+                       silence (nframes - this_nframes);
+               }
+
        } else {
                silence (nframes);
        }