summaryrefslogtreecommitdiff
path: root/libs/ardour/session_state.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/session_state.cc')
-rw-r--r--libs/ardour/session_state.cc61
1 files changed, 44 insertions, 17 deletions
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 4cf3c2e425..9fb20973e2 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -273,6 +273,9 @@ Session::first_stage_init (string fullpath, string snapshot_name)
AudioDiskstream::AudioDiskstreamCreated.connect (mem_fun (*this, &Session::add_diskstream));
NamedSelection::NamedSelectionCreated.connect (mem_fun (*this, &Session::add_named_selection));
+ Controllable::Created.connect (mem_fun (*this, &Session::add_controllable));
+ Controllable::GoingAway.connect (mem_fun (*this, &Session::remove_controllable));
+
IO::MoreOutputs.connect (mem_fun (*this, &Session::ensure_passthru_buffers));
/* stop IO objects from doing stuff until we're ready for them */
@@ -1343,7 +1346,7 @@ Session::state(bool full_state)
AudioFileSource* fs;
- if ((fs = dynamic_cast<AudioFileSource*> ((*siter).second)) != 0) {
+ if ((fs = dynamic_cast<AudioFileSource*> (siter->second)) != 0) {
DestructiveFileSource* dfs = dynamic_cast<DestructiveFileSource*> (fs);
/* destructive file sources are OK if they are empty, because
@@ -1357,7 +1360,7 @@ Session::state(bool full_state)
}
}
- child->add_child_nocopy ((*siter).second->get_state());
+ child->add_child_nocopy (siter->second->get_state());
}
}
@@ -1370,7 +1373,7 @@ Session::state(bool full_state)
/* only store regions not attached to playlists */
- if ((*i).second->playlist() == 0) {
+ if (i->second->playlist() == 0) {
child->add_child_nocopy (i->second->state (true));
}
}
@@ -1730,12 +1733,10 @@ Session::load_regions (const XMLNode& node)
set_dirty();
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
-
if ((region = XMLRegionFactory (**niter, false)) == 0) {
error << _("Session: cannot create Region from XML description.") << endmsg;
}
}
-
return 0;
}
@@ -1743,7 +1744,6 @@ AudioRegion *
Session::XMLRegionFactory (const XMLNode& node, bool full)
{
const XMLProperty* prop;
- id_t s_id;
Source* source;
AudioSource* as;
AudioRegion::SourceList sources;
@@ -1766,9 +1766,9 @@ Session::XMLRegionFactory (const XMLNode& node, bool full)
}
}
- sscanf (prop->value().c_str(), "%" PRIu64, &s_id);
+ PBD::ID s_id (prop->value());
- if ((source = get_source (s_id)) == 0) {
+ if ((source = source_by_id (s_id)) == 0) {
error << string_compose(_("Session: XMLNode describing a AudioRegion references an unknown source id =%1"), s_id) << endmsg;
return 0;
}
@@ -1786,23 +1786,23 @@ Session::XMLRegionFactory (const XMLNode& node, bool full)
for (uint32_t n=1; n < nchans; ++n) {
snprintf (buf, sizeof(buf), X_("source-%d"), n);
if ((prop = node.property (buf)) != 0) {
- sscanf (prop->value().c_str(), "%" PRIu64, &s_id);
- if ((source = get_source (s_id)) == 0) {
- error << string_compose(_("Session: XMLNode describing a AudioRegion references an unknown source id =%1"), s_id) << endmsg;
+ PBD::ID id2 (prop->value());
+
+ if ((source = source_by_id (id2)) == 0) {
+ error << string_compose(_("Session: XMLNode describing a AudioRegion references an unknown source id =%1"), id2) << endmsg;
return 0;
}
as = dynamic_cast<AudioSource*>(source);
if (!as) {
- error << string_compose(_("Session: XMLNode describing a AudioRegion references a non-audio source id =%1"), s_id) << endmsg;
+ error << string_compose(_("Session: XMLNode describing a AudioRegion references a non-audio source id =%1"), id2) << endmsg;
return 0;
}
sources.push_back (as);
}
}
-
try {
return new AudioRegion (sources, node);
}
@@ -1820,7 +1820,7 @@ Session::get_sources_as_xml ()
Glib::Mutex::Lock lm (audio_source_lock);
for (AudioSourceList::iterator i = audio_sources.begin(); i != audio_sources.end(); ++i) {
- node->add_child_nocopy ((*i).second->get_state());
+ node->add_child_nocopy (i->second->get_state());
}
/* XXX get MIDI and other sources here */
@@ -2946,7 +2946,7 @@ Session::cleanup_sources (Session::cleanup_report& rep)
capture files.
*/
- if ((*i).second->use_cnt() == 0 && (*i).second->length() > 0) {
+ if (i->second->use_cnt() == 0 && i->second->length() > 0) {
dead_sources.push_back (i->second);
/* remove this source from our own list to avoid us
@@ -2973,7 +2973,7 @@ Session::cleanup_sources (Session::cleanup_report& rep)
tmp = r;
++tmp;
- ar = (*r).second;
+ ar = r->second;
for (uint32_t n = 0; n < ar->n_channels(); ++n) {
if (&ar->source (n) == (*i)) {
@@ -3026,7 +3026,7 @@ Session::cleanup_sources (Session::cleanup_report& rep)
for (AudioSourceList::iterator i = audio_sources.begin(); i != audio_sources.end(); ++i) {
AudioFileSource* fs;
- if ((fs = dynamic_cast<AudioFileSource*> ((*i).second)) != 0) {
+ if ((fs = dynamic_cast<AudioFileSource*> (i->second)) != 0) {
all_sources.insert (fs->path());
}
}
@@ -3235,3 +3235,30 @@ Session::set_clean ()
}
}
+void
+Session::add_controllable (Controllable* c)
+{
+ Glib::Mutex::Lock lm (controllables_lock);
+ controllables.push_back (c);
+}
+
+void
+Session::remove_controllable (Controllable* c)
+{
+ Glib::Mutex::Lock lm (controllables_lock);
+ controllables.remove (c);
+}
+
+Controllable*
+Session::controllable_by_id (const PBD::ID& id)
+{
+ Glib::Mutex::Lock lm (controllables_lock);
+
+ for (Controllables::iterator i = controllables.begin(); i != controllables.end(); ++i) {
+ if ((*i)->id() == id) {
+ return *i;
+ }
+ }
+
+ return 0;
+}