LV2 support.
[ardour.git] / libs / ardour / audio_diskstream.cc
index 184ea8d998bf4c04d5d467ca0a8a7e89433190ea..32335d4938b69ab6f8ba40b2b2436f662a65eed5 100644 (file)
@@ -267,7 +267,7 @@ AudioDiskstream::use_new_playlist ()
 {
        string newname;
        boost::shared_ptr<AudioPlaylist> playlist;
-
+       
        if (!in_set_state && destructive()) {
                return 0;
        }
@@ -760,14 +760,14 @@ AudioDiskstream::process (nframes_t transport_frame, nframes_t nframes, nframes_
                if (rec_nframes == 0 && _actual_speed != 1.0f && _actual_speed != -1.0f) {
                        
                        uint64_t phase = last_phase;
-                       uint64_t phi_delta;
+                       int64_t phi_delta;
                        nframes_t i = 0;
 
                        // Linearly interpolate into the alt buffer
                        // using 40.24 fixp maths (swh)
 
                        if (phi != target_phi) {
-                               phi_delta = (target_phi - phi) / nframes;
+                               phi_delta = ((int64_t)(target_phi - phi)) / nframes;
                        } else {
                                phi_delta = 0;
                        }
@@ -792,7 +792,7 @@ AudioDiskstream::process (nframes_t transport_frame, nframes_t nframes, nframes_
                                chaninfo->current_playback_buffer = chaninfo->speed_buffer;
                        }
 
-                       playback_distance = i + 1;
+                       playback_distance = i; // + 1;
                        last_phase = (phase & 0xFFFFFF);
 
                } else {
@@ -847,10 +847,18 @@ AudioDiskstream::commit (nframes_t nframes)
        }
        
        if (_slaved) {
-               need_butler = c->front()->playback_buf->write_space() >= c->front()->playback_buf->bufsize() / 2;
+               if (_io && _io->active()) {
+                       need_butler = c->front()->playback_buf->write_space() >= c->front()->playback_buf->bufsize() / 2;
+               } else {
+                       need_butler = false;
+               }
        } else {
-               need_butler = c->front()->playback_buf->write_space() >= disk_io_chunk_frames
-                       || c->front()->capture_buf->read_space() >= disk_io_chunk_frames;
+               if (_io && _io->active()) {
+                       need_butler = c->front()->playback_buf->write_space() >= disk_io_chunk_frames
+                               || c->front()->capture_buf->read_space() >= disk_io_chunk_frames;
+               } else {
+                       need_butler = c->front()->capture_buf->read_space() >= disk_io_chunk_frames;
+               }
        }
 
        if (commit_should_unlock) {
@@ -1963,6 +1971,7 @@ AudioDiskstream::set_state (const XMLNode& node)
        if (nchans > _n_channels) {
 
                add_channel (nchans - _n_channels);
+               IO::MoreOutputs(_n_channels);
 
        } else if (nchans < _n_channels) {
 
@@ -2012,8 +2021,6 @@ AudioDiskstream::set_state (const XMLNode& node)
           up of the IO that owns this DS (::non_realtime_input_change())
        */
                
-       in_set_state = false;
-
        return 0;
 }