major fixes to automation editing
[ardour.git] / libs / ardour / source.cc
index ad0d0f8a133a957d67d1c8e6ad20ea3bc9ca5b8e..74ca0afcd4bb932fe36605762cd43a7d7fe85f43 100644 (file)
@@ -34,6 +34,7 @@
 #include <pbd/pthread_utils.h>
 
 #include <ardour/source.h>
+#include <ardour/playlist.h>
 
 #include "i18n.h"
 
@@ -42,15 +43,19 @@ using std::max;
 
 using namespace ARDOUR;
 
-Source::Source (string name)
+Source::Source (Session& s, string name)
+       : _session (s)
 {
        _name = name;
        _timestamp = 0;
+       _in_use = 0;
 }
 
-Source::Source (const XMLNode& node) 
+Source::Source (Session& s, const XMLNode& node) 
+       : _session (s)
 {
        _timestamp = 0;
+       _in_use = 0;
 
        if (set_state (node)) {
                throw failed_constructor();
@@ -69,7 +74,7 @@ Source::get_state ()
        char buf[64];
 
        node->add_property ("name", _name);
-       _id.print (buf);
+       _id.print (buf, sizeof (buf));
        node->add_property ("id", buf);
 
        if (_timestamp != 0) {
@@ -104,3 +109,24 @@ Source::set_state (const XMLNode& node)
        return 0;
 }
 
+void
+Source::add_playlist (Playlist* pl)
+{
+       _playlists.insert (pl);
+}
+
+void
+Source::remove_playlist (Playlist* pl)
+{
+       std::set<Playlist*>::iterator x;
+
+       if ((x = _playlists.find (pl)) != _playlists.end()) {
+               _playlists.erase (x);
+       }
+}
+
+uint32_t
+Source::used () const
+{
+       return _playlists.size();
+}