Make Session::audible_frame() return a (more) correct answer when the transport has...
[ardour.git] / libs / ardour / session.cc
index 5c9ee380c99da5db7890763de5e3eeb14e797c4e..4ac6f9ebbc5ed965a3dad9149987db5d5ab6c20e 100644 (file)
@@ -1104,17 +1104,20 @@ Session::audible_frame () const
 
                /* MOVING */
 
-               /* check to see if we have passed the first guaranteed
+               /* Check to see if we have passed the first guaranteed
                   audible frame past our last start position. if not,
                   return that last start point because in terms
                   of audible frames, we have not moved yet.
+
+                  `Start position' in this context means the time we last
+                  either started or changed transport direction.
                */
 
                if (_transport_speed > 0.0f) {
 
                        if (!play_loop || !have_looped) {
-                               if (tf < _last_roll_location + offset) {
-                                       return _last_roll_location;
+                               if (tf < _last_roll_or_reversal_location + offset) {
+                                       return _last_roll_or_reversal_location;
                                }
                        }
 
@@ -1126,8 +1129,8 @@ Session::audible_frame () const
 
                        /* XXX wot? no backward looping? */
 
-                       if (tf > _last_roll_location - offset) {
-                               return _last_roll_location;
+                       if (tf > _last_roll_or_reversal_location - offset) {
+                               return _last_roll_or_reversal_location;
                        } else {
                                /* backwards */
                                ret += offset;
@@ -1461,7 +1464,7 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m
 
                        auto_connect_route (track, existing_inputs, existing_outputs);
 
-                       track->midi_diskstream()->non_realtime_input_change();
+                       track->non_realtime_input_change();
                        if (route_group) {
                                route_group->add (track);
                        }
@@ -1630,7 +1633,7 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod
                                route_group->add (track);
                        }
 
-                       track->audio_diskstream()->non_realtime_input_change();
+                       track->non_realtime_input_change();
 
                        track->DiskstreamChanged.connect_same_thread (*this, boost::bind (&Session::resort_routes, this));
                        track->set_remote_control_id (control_id);
@@ -2424,6 +2427,7 @@ Session::add_source (boost::shared_ptr<Source> source)
        }
 
        if (result.second) {
+               source->DropReferences.connect_same_thread (*this, boost::bind (&Session::remove_source, this, boost::weak_ptr<Source> (source)));
                set_dirty();
        }
 
@@ -3327,7 +3331,7 @@ Session::write_one_track (AudioTrack& track, nframes_t start, nframes_t end,
        boost::shared_ptr<AudioFileSource> fsource;
        uint32_t x;
        char buf[PATH_MAX+1];
-       ChanCount nchans(track.audio_diskstream()->n_channels());
+       ChanCount nchans(track.n_channels());
        nframes_t position;
        nframes_t this_chunk;
        nframes_t to_do;