13
0

Consistent _nth_ API call 0-based index

This commit is contained in:
Robin Gareus 2021-05-26 02:33:31 +02:00
parent c444a81f1a
commit d839e9cf14
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 7 additions and 8 deletions

View File

@ -338,7 +338,7 @@ public:
boost::shared_ptr<RouteList> get_routes_with_internal_returns() const;
boost::shared_ptr<RouteList> get_routes_with_regions_at (samplepos_t const) const;
boost::shared_ptr<AudioTrack> get_nth_audio_track (int nth) const;
boost::shared_ptr<AudioTrack> get_nth_audio_track (uint32_t) const;
uint32_t nstripables (bool with_monitor = false) const;
uint32_t nroutes() const { return routes.reader()->size(); }

View File

@ -348,7 +348,7 @@ Session::import_pt_rest (PTFFormat& ptf)
/* Get all playlists of all tracks and Playlist::freeze() all tracks */
assert (ntr == nth + 1);
for (i = 1; i <= ntr; i++) {
for (i = 0; i < ntr; ++i) {
existing_track = get_nth_audio_track (i);
boost::shared_ptr<Playlist> playlist = existing_track->playlist();

View File

@ -6225,20 +6225,19 @@ Session::route_removed_from_route_group (RouteGroup* rg, boost::weak_ptr<Route>
}
boost::shared_ptr<AudioTrack>
Session::get_nth_audio_track (int nth) const
Session::get_nth_audio_track (uint32_t nth) const
{
boost::shared_ptr<RouteList> rl = routes.reader ();
rl->sort (Stripable::Sorter ());
for (RouteList::const_iterator r = rl->begin(); r != rl->end(); ++r) {
if (!boost::dynamic_pointer_cast<AudioTrack> (*r)) {
boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack> (*r);
if (!at) {
continue;
}
if (--nth > 0) {
continue;
if (nth-- == 0) {
return at;
}
return boost::dynamic_pointer_cast<AudioTrack> (*r);
}
return boost::shared_ptr<AudioTrack> ();
}