Add support for newly introduced class ARDOUR::DSPLoadCalculator (when building with...
[ardour.git] / libs / ardour / session_state.cc
index a921747ac2cde57947ef0f06b9363155d463bcd0..bb4a8265ef393e9182d5b1c16aa439f00a533ac3 100644 (file)
@@ -66,6 +66,7 @@
 #include "pbd/boost_debug.h"
 #include "pbd/basename.h"
 #include "pbd/controllable_descriptor.h"
+#include "pbd/debug.h"
 #include "pbd/enumwriter.h"
 #include "pbd/error.h"
 #include "pbd/file_utils.h"
@@ -129,6 +130,8 @@ using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
 
+#define DEBUG_UNDO_HISTORY(msg) DEBUG_TRACE (PBD::DEBUG::UndoHistory, string_compose ("%1: %2\n", __LINE__, msg));
+
 void
 Session::pre_engine_init (string fullpath)
 {
@@ -2526,6 +2529,16 @@ Session::add_commands (vector<Command*> const & cmds)
        }
 }
 
+void
+Session::add_command (Command* const cmd)
+{
+       assert (_current_trans);
+       DEBUG_UNDO_HISTORY (
+           string_compose ("Current Undo Transaction %1, adding command: %2",
+                           _current_trans->name (),
+                           cmd->name ()));
+       _current_trans->add_command (cmd);
+}
 void
 Session::begin_reversible_command (const string& name)
 {
@@ -2545,10 +2558,17 @@ Session::begin_reversible_command (GQuark q)
        */
 
        if (_current_trans == 0) {
+               DEBUG_UNDO_HISTORY (string_compose (
+                   "Begin Reversible Command, new transaction: %1", g_quark_to_string (q)));
+
                /* start a new transaction */
                assert (_current_trans_quarks.empty ());
                _current_trans = new UndoTransaction();
                _current_trans->set_name (g_quark_to_string (q));
+       } else {
+               DEBUG_UNDO_HISTORY (
+                   string_compose ("Begin Reversible Command, current transaction: %1",
+                                   _current_trans->name ()));
        }
 
        _current_trans_quarks.push_front (q);
@@ -2558,6 +2578,8 @@ void
 Session::abort_reversible_command ()
 {
        if (_current_trans != 0) {
+               DEBUG_UNDO_HISTORY (
+                   string_compose ("Abort Reversible Command: %1", _current_trans->name ()));
                _current_trans->clear();
                delete _current_trans;
                _current_trans = 0;
@@ -2574,18 +2596,34 @@ Session::commit_reversible_command (Command *cmd)
        struct timeval now;
 
        if (cmd) {
+               DEBUG_UNDO_HISTORY (
+                   string_compose ("Current Undo Transaction %1, adding command: %2",
+                                   _current_trans->name (),
+                                   cmd->name ()));
                _current_trans->add_command (cmd);
        }
 
+       DEBUG_UNDO_HISTORY (
+           string_compose ("Commit Reversible Command, current transaction: %1",
+                           _current_trans->name ()));
+
        _current_trans_quarks.pop_front ();
 
        if (!_current_trans_quarks.empty ()) {
+               DEBUG_UNDO_HISTORY (
+                   string_compose ("Commit Reversible Command, transaction is not "
+                                   "top-level, current transaction: %1",
+                                   _current_trans->name ()));
                /* the transaction we're committing is not the top-level one */
                return;
        }
 
        if (_current_trans->empty()) {
                /* no commands were added to the transaction, so just get rid of it */
+               DEBUG_UNDO_HISTORY (
+                   string_compose ("Commit Reversible Command, No commands were "
+                                   "added to current transaction: %1",
+                                   _current_trans->name ()));
                delete _current_trans;
                _current_trans = 0;
                return;
@@ -2889,17 +2927,18 @@ Session::cleanup_sources (CleanupReport& rep)
                                        */
                                        
                                        RegionFactory::remove_regions_using_source (i->second);
-                                       sources.erase (i);
                                        
                                        // also remove source from all_sources
                                        
                                        for (set<string>::iterator j = all_sources.begin(); j != all_sources.end(); ++j) {
                                                spath = Glib::path_get_basename (*j);
-                                               if ( spath == i->second->name () ) {
+                                               if (spath == i->second->name()) {
                                                        all_sources.erase (j);
                                                        break;
                                                }
                                        }
+
+                                       sources.erase (i);
                                }
                        }
                }
@@ -3008,12 +3047,12 @@ Session::cleanup_sources (CleanupReport& rep)
                /* see if there an easy to find peakfile for this file, and remove it.
                 */
 
-                string base = basename_nosuffix (*x);
+                string base = Glib::path_get_basename (*x);
                 base += "%A"; /* this is what we add for the channel suffix of all native files,
                                  or for the first channel of embedded files. it will miss
                                  some peakfiles for other channels
                               */
-               string peakpath = peak_path (base);
+               string peakpath = construct_peak_filepath (base);
 
                if (Glib::file_test (peakpath.c_str(), Glib::FILE_TEST_EXISTS)) {
                        if (::g_unlink (peakpath.c_str()) != 0) {