X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fsource.cc;h=74ca0afcd4bb932fe36605762cd43a7d7fe85f43;hb=f3e5450492109bb4fab898ae824e30ede28bf7b5;hp=0d32ea4a216ec6134dbb93281819747bd24ec8c5;hpb=b09ab546542040b1d468c9925c60bda2dfd80da8;p=ardour.git diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc index 0d32ea4a21..74ca0afcd4 100644 --- a/libs/ardour/source.cc +++ b/libs/ardour/source.cc @@ -34,6 +34,7 @@ #include #include +#include #include "i18n.h" @@ -42,18 +43,19 @@ using std::max; using namespace ARDOUR; -Source::Source (string name) +Source::Source (Session& s, string name) + : _session (s) { _name = name; - _id = ARDOUR::new_id(); - _use_cnt = 0; _timestamp = 0; + _in_use = 0; } -Source::Source (const XMLNode& node) +Source::Source (Session& s, const XMLNode& node) + : _session (s) { - _use_cnt = 0; _timestamp = 0; + _in_use = 0; if (set_state (node)) { throw failed_constructor(); @@ -62,6 +64,7 @@ Source::Source (const XMLNode& node) Source::~Source () { + notify_callbacks (); } XMLNode& @@ -71,7 +74,7 @@ Source::get_state () char buf[64]; node->add_property ("name", _name); - snprintf (buf, sizeof(buf)-1, "%" PRIu64, _id); + _id.print (buf, sizeof (buf)); node->add_property ("id", buf); if (_timestamp != 0) { @@ -94,7 +97,7 @@ Source::set_state (const XMLNode& node) } if ((prop = node.property ("id")) != 0) { - sscanf (prop->value().c_str(), "%" PRIu64, &_id); + _id = prop->value (); } else { return -1; } @@ -107,14 +110,23 @@ Source::set_state (const XMLNode& node) } void -Source::use () +Source::add_playlist (Playlist* pl) { - _use_cnt++; + _playlists.insert (pl); } void -Source::release () +Source::remove_playlist (Playlist* pl) { - if (_use_cnt) --_use_cnt; + std::set::iterator x; + + if ((x = _playlists.find (pl)) != _playlists.end()) { + _playlists.erase (x); + } } +uint32_t +Source::used () const +{ + return _playlists.size(); +}