summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/source.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/ardour/source.h')
-rw-r--r--libs/ardour/ardour/source.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h
index bf92e5a6e4..16a762eb94 100644
--- a/libs/ardour/ardour/source.h
+++ b/libs/ardour/ardour/source.h
@@ -23,6 +23,8 @@
#include <string>
#include <set>
+#include <glib.h>
+
#include <boost/utility.hpp>
#include "pbd/statefuldestructible.h"
@@ -102,6 +104,15 @@ class Source : public SessionObject
Glib::Mutex& mutex() { return _lock; }
Flag flags() const { return _flags; }
+ void inc_use_count () { g_atomic_int_inc (&_use_count); }
+ void dec_use_count () {
+ gint oldval = g_atomic_int_exchange_and_add (&_use_count, -1);
+ assert (oldval > 0);
+ }
+
+ int use_count() const { return g_atomic_int_get (&_use_count); }
+ bool used() const { return use_count() > 0; }
+
protected:
DataType _type;
Flag _flags;
@@ -111,6 +122,7 @@ class Source : public SessionObject
mutable Glib::Mutex _lock;
mutable Glib::Mutex _analysis_lock;
Glib::Mutex _playlist_lock;
+ gint _use_count; /* atomic */
private:
void fix_writable_flags ();