remove Glib::ustring from libardour; allow any characters except '/' and '\' in paths...
[ardour.git] / libs / ardour / source.cc
index a8c4262a66ea9e4f487e8f221ce30f03a1e3e829..6ab907ba169861826872028e0015e23e8f0ff551 100644 (file)
 
 using namespace std;
 using namespace ARDOUR;
+using namespace PBD;
 
 Source::Source (Session& s, DataType type, const string& name, Flag flags)
        : SessionObject(s, name)
        , _type(type)
        , _flags(flags)
        , _timeline_position(0)
+        , _use_count (0)
 {
        _analysed = false;
        _timestamp = 0;
@@ -62,6 +64,7 @@ Source::Source (Session& s, const XMLNode& node)
        , _type(DataType::AUDIO)
        , _flags (Flag (Writable|CanRename))
        , _timeline_position(0)
+        , _use_count (0)
 {
        _timestamp = 0;
        _analysed = false;
@@ -75,10 +78,9 @@ Source::Source (Session& s, const XMLNode& node)
 
 Source::~Source ()
 {
-       DEBUG_TRACE (DEBUG::Destruction, string_compose ("Source %1 destructor\n", _name));
+       DEBUG_TRACE (DEBUG::Destruction, string_compose ("Source %1 destructor %2\n", _name, this));
 }
 
-
 void
 Source::fix_writable_flags ()
 {
@@ -270,3 +272,23 @@ Source::set_allow_remove_if_empty (bool yn)
        }
 }
 
+void
+Source::inc_use_count ()
+{
+        g_atomic_int_inc (&_use_count);
+}
+
+void
+Source::dec_use_count ()
+{
+#ifndef NDEBUG
+        gint oldval = g_atomic_int_exchange_and_add (&_use_count, -1);
+        if (oldval <= 0) {
+                cerr << "Bad use dec for " << name() << endl;
+                abort ();
+        }
+        assert (oldval > 0);
+#else 
+        g_atomic_int_exchange_and_add (&_use_count, -1);
+#endif
+}