summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/source.h
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-06-23 20:14:07 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-06-23 20:14:07 +0000
commitf4401c59284258c6aa56707da64e3da32756329f (patch)
tree73679199ae43516347d607adad212c10612f7eb9 /libs/ardour/ardour/source.h
parentcac03dbeb6ebdcd406385dd14a746cb8c51dd5f8 (diff)
midway snapshot of work done on managing Region & Source lifetimes correctly. may fix missing MIDI file bug ; save empty playlists because they may be referred to by the history file ; undo commands auto-delete when objects they refer to die (currently not commands built from XML deserialization); Sources now know how many regions are using them for something, meaning that we know if we can delete the files holding any data for the source
git-svn-id: svn://localhost/ardour2/branches/3.0@7291 d708f5d6-7413-0410-9779-e7cbd77b26cf
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 ();