Somewhat uncertain fix to playhead misbehaviour in rewind.
[ardour.git] / libs / ardour / diskstream.cc
index 908e1db5c88ce7b9ff4ebdd85f65743e94cd44fd..df9d1a9b4df5c0dc84f747f1f93ab963c84c1b9f 100644 (file)
@@ -46,6 +46,8 @@
 #include "ardour/configuration.h"
 #include "ardour/audiofilesource.h"
 #include "ardour/send.h"
+#include "ardour/pannable.h"
+#include "ardour/panner_shell.h"
 #include "ardour/playlist.h"
 #include "ardour/cycle_timer.h"
 #include "ardour/region.h"
@@ -66,7 +68,7 @@ using namespace PBD;
  * default from configuration_vars.h).  0 is not a good value for
  * allocating buffer sizes..
  */
-ARDOUR::nframes_t Diskstream::disk_io_chunk_frames = 1024 * 256;
+ARDOUR::framecnt_t Diskstream::disk_io_chunk_frames = 1024 * 256;
 
 PBD::Signal0<void>                Diskstream::DiskOverrun;
 PBD::Signal0<void>                Diskstream::DiskUnderrun;
@@ -110,9 +112,6 @@ Diskstream::Diskstream (Session &sess, const string &name, Flag flag)
         , in_set_state (false)
         , _persistent_alignment_style (ExistingMaterial)
         , first_input_change (true)
-        , scrub_start (0)
-        , scrub_buffer_size (0)
-        , scrub_offset (0)
         , _flags (flag)
 
 {
@@ -157,9 +156,6 @@ Diskstream::Diskstream (Session& sess, const XMLNode& /*node*/)
         , in_set_state (false)
         , _persistent_alignment_style (ExistingMaterial)
         , first_input_change (true)
-        , scrub_start (0)
-        , scrub_buffer_size (0)
-        , scrub_offset (0)
         , _flags (Recordable)
 {
 }
@@ -194,10 +190,12 @@ Diskstream::handle_input_change (IOChange change, void * /*src*/)
 {
        Glib::Mutex::Lock lm (state_lock);
 
-       if (!(input_change_pending.type & change.type)) {
-               input_change_pending.type = IOChange::Type (input_change_pending.type | change.type);
-               _session.request_input_change_handling ();
-       }
+        if (change.type & IOChange::ConfigurationChanged) {
+                if (!(input_change_pending.type & change.type)) {
+                        input_change_pending.type = IOChange::Type (input_change_pending.type | change.type);
+                        _session.request_input_change_handling ();
+                }
+        }
 }
 
 void
@@ -236,7 +234,7 @@ Diskstream::realtime_set_speed (double sp, bool global)
 
        if (new_speed != _actual_speed) {
 
-               nframes_t required_wrap_size = (nframes_t) floor (_session.get_block_size() *
+               framecnt_t required_wrap_size = (framecnt_t) floor (_session.get_block_size() *
                                                                   fabs (new_speed)) + 1;
 
                if (required_wrap_size > wrap_buffer_size) {
@@ -327,7 +325,7 @@ Diskstream::get_captured_frames (uint32_t n) const
 }
 
 void
-Diskstream::set_roll_delay (ARDOUR::nframes_t nframes)
+Diskstream::set_roll_delay (ARDOUR::framecnt_t nframes)
 {
        _roll_delay = nframes;
 }
@@ -462,18 +460,23 @@ Diskstream::playlist_ranges_moved (list< Evoral::RangeMove<framepos_t> > const &
        }
 
        /* move panner automation */
-       boost::shared_ptr<Panner> p = _track->main_outs()->panner ();
-       if (p) {
-               for (uint32_t i = 0; i < p->npanners (); ++i) {
-                       boost::shared_ptr<AutomationList> pan_alist = p->streampanner(i).pan_control()->alist();
-                       XMLNode & before = pan_alist->get_state ();
-                       bool const things_moved = pan_alist->move_ranges (movements);
-                       if (things_moved) {
-                               _session.add_command (new MementoCommand<AutomationList> (
-                                                             *pan_alist.get(), &before, &pan_alist->get_state ()));
-                       }
-               }
-       }
+       boost::shared_ptr<Pannable> pannable = _track->pannable();
+        Evoral::ControlSet::Controls& c (pannable->controls());
+        
+        for (Evoral::ControlSet::Controls::iterator ci = c.begin(); ci != c.end(); ++ci) {
+                boost::shared_ptr<AutomationControl> ac = boost::dynamic_pointer_cast<AutomationControl>(ci->second);
+                if (!ac) {
+                        continue;
+                }
+                boost::shared_ptr<AutomationList> alist = ac->alist();
+                
+                XMLNode & before = alist->get_state ();
+                bool const things_moved = alist->move_ranges (movements);
+                if (things_moved) {
+                        _session.add_command (new MementoCommand<AutomationList> (
+                                                      *alist.get(), &before, &alist->get_state ()));
+                }
+        }
 
        /* move processor automation */
        _track->foreach_processor (boost::bind (&Diskstream::move_processor_automation, this, _1, movements_frames));
@@ -637,7 +640,7 @@ Diskstream::route_going_away ()
 
 void
 Diskstream::calculate_record_range(OverlapType ot, framepos_t transport_frame, framecnt_t nframes,
-                                  nframes_t& rec_nframes, nframes_t& rec_offset)
+                                  framecnt_t & rec_nframes, framecnt_t & rec_offset)
 {
        switch (ot) {
        case OverlapNone: