Fix periodic backup saves
[ardour.git] / libs / ardour / session.cc
index eb55e55508b92c964821d516be21489391a3bc4a..d61a53cd523dd4913fd16f03319d6852438a655f 100644 (file)
@@ -1,21 +1,31 @@
 /*
-    Copyright (C) 1999-2010 Paul Davis
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+ * Copyright (C) 1999-2019 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2006-2007 Jesse Chappell <jesse@essej.net>
+ * Copyright (C) 2006-2009 Sampo Savolainen <v2@iki.fi>
+ * Copyright (C) 2006-2015 David Robillard <d@drobilla.net>
+ * Copyright (C) 2006-2016 Tim Mayberry <mojofunk@gmail.com>
+ * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2008-2009 Hans Baier <hansfbaier@googlemail.com>
+ * Copyright (C) 2012-2019 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2013-2017 Nick Mainsbridge <mainsbridge@gmail.com>
+ * Copyright (C) 2014-2019 Ben Loftis <ben@harrisonconsoles.com>
+ * Copyright (C) 2015 GZharun <grygoriiz@wavesglobal.com>
+ * Copyright (C) 2016-2018 Len Ovens <len@ovenwerks.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
 #include <stdint.h>
 
@@ -2078,10 +2088,6 @@ Session::disable_record (bool rt_context, bool force)
                }
 
                RecordStateChanged (); /* emit signal */
-
-               if (!rt_context) {
-                       remove_pending_capture_state ();
-               }
        }
 }
 
@@ -4824,6 +4830,25 @@ Session::remove_last_capture ()
        return 0;
 }
 
+void
+Session::get_last_capture_sources (std::list<boost::shared_ptr<Source> >& srcs)
+{
+       boost::shared_ptr<RouteList> rl = routes.reader ();
+       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
+               boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
+               if (!tr) {
+                       continue;
+               }
+
+               list<boost::shared_ptr<Source> >& l = tr->last_capture_sources();
+
+               if (!l.empty()) {
+                       srcs.insert (srcs.end(), l.begin(), l.end());
+                       l.clear ();
+               }
+       }
+}
+
 /* Source Management */
 
 void
@@ -5381,8 +5406,8 @@ Session::create_midi_source_by_stealing_name (boost::shared_ptr<Track> track)
 bool
 Session::playlist_is_active (boost::shared_ptr<Playlist> playlist)
 {
-       Glib::Threads::Mutex::Lock lm (playlists->lock);
-       for (SessionPlaylists::List::iterator i = playlists->playlists.begin(); i != playlists->playlists.end(); i++) {
+       Glib::Threads::Mutex::Lock lm (_playlists->lock);
+       for (SessionPlaylists::List::iterator i = _playlists->playlists.begin(); i != _playlists->playlists.end(); i++) {
                if ( (*i) == playlist ) {
                        return true;
                }
@@ -6163,7 +6188,7 @@ Session::write_one_track (Track& track, samplepos_t start, samplepos_t end,
                goto out;
        }
 
-       legal_playlist_name = legalize_for_path (playlist->name());
+       legal_playlist_name = "(bounce)" + legalize_for_path (playlist->name());
 
        for (uint32_t chan_n = 0; chan_n < diskstream_channels.n(data_type); ++chan_n) {
 
@@ -6255,7 +6280,7 @@ Session::write_one_track (Track& track, samplepos_t start, samplepos_t end,
                                        if (!endpoint || for_export) {
                                                ev.set_time(ev.time() - position);
                                        }
-                                       ms->append_event_samples(lock, ev, ms->timeline_position());
+                                       ms->append_event_samples(lock, ev, ms->natural_position());
                                }
                        }
                }
@@ -6309,10 +6334,11 @@ Session::write_one_track (Track& track, samplepos_t start, samplepos_t end,
                PropertyList plist;
 
                plist.add (Properties::start, 0);
-               plist.add (Properties::length, srcs.front()->length(srcs.front()->timeline_position()));
+               plist.add (Properties::whole_file, true);
+               plist.add (Properties::length, srcs.front()->length(srcs.front()->natural_position()));
                plist.add (Properties::name, region_name_from_path (srcs.front()->name(), true));
 
-               result = RegionFactory::create (srcs, plist);
+               result = RegionFactory::create (srcs, plist, true);
 
        }
 
@@ -6452,6 +6478,11 @@ Session::nstripables (bool with_monitor) const
        return rv;
 }
 
+bool
+Session::plot_process_graph (std::string const& file_name) const {
+       return _process_graph ? _process_graph->plot (file_name) : false;
+}
+
 void
 Session::add_automation_list(AutomationList *al)
 {