diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2008-02-12 02:51:51 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2008-02-12 02:51:51 +0000 |
commit | a1955a82e81816161f5b7dbf460a694e902237b0 (patch) | |
tree | 3c576a733aed52ff02a8fdc9786838bdea7758d2 /libs/ardour/session.cc | |
parent | 7999372faccab884b4e652da83702d7ec252e14b (diff) |
AU GUIs basically working, though unfinished; push up dialog for massive split operations (still in progress); fix problem where peakfile is slightly older than audio data even though it is ready to use (debugging output still present); move sync-menu code to libs/gtkmm2ext for linkage reasons; prevent flush_pending() calls from "top menu" items on OS X from locking the GUI; try to make adding lots of regions (e.g. from split-at-points) scale a bit better; SAE version has no timecode mode for audio clocks
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3038 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session.cc')
-rw-r--r-- | libs/ardour/session.cc | 114 |
1 files changed, 77 insertions, 37 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 1f2ba8d61b..454a710236 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2568,6 +2568,14 @@ Session::region_name (string& result, string base, bool newlevel) const void Session::add_region (boost::shared_ptr<Region> region) { + vector<boost::shared_ptr<Region> > v; + v.push_back (region); + add_regions (v); +} + +void +Session::add_regions (vector<boost::shared_ptr<Region> >& new_regions) +{ boost::shared_ptr<AudioRegion> ar; boost::shared_ptr<AudioRegion> oar; bool added = false; @@ -2575,45 +2583,52 @@ Session::add_region (boost::shared_ptr<Region> region) { Glib::Mutex::Lock lm (region_lock); - if (region == 0) { - error << _("Session::add_region() ignored a null region. Warning: you might have lost a region.") << endmsg; - } else if ((ar = boost::dynamic_pointer_cast<AudioRegion> (region)) != 0) { - - AudioRegionList::iterator x; - - for (x = audio_regions.begin(); x != audio_regions.end(); ++x) { - - oar = boost::dynamic_pointer_cast<AudioRegion> (x->second); - - if (ar->region_list_equivalent (oar)) { - break; - } - } - - if (x == audio_regions.end()) { - - pair<AudioRegionList::key_type,AudioRegionList::mapped_type> entry; - - entry.first = region->id(); - entry.second = ar; + for (vector<boost::shared_ptr<Region> >::iterator ii = new_regions.begin(); ii != new_regions.end(); ++ii) { + + boost::shared_ptr<Region> region = *ii; + + if (region == 0) { - pair<AudioRegionList::iterator,bool> x = audio_regions.insert (entry); + error << _("Session::add_region() ignored a null region. Warning: you might have lost a region.") << endmsg; + } else if ((ar = boost::dynamic_pointer_cast<AudioRegion> (region)) != 0) { - if (!x.second) { - return; + AudioRegionList::iterator x; + + for (x = audio_regions.begin(); x != audio_regions.end(); ++x) { + + oar = boost::dynamic_pointer_cast<AudioRegion> (x->second); + + if (ar->region_list_equivalent (oar)) { + break; + } } + + if (x == audio_regions.end()) { + + pair<AudioRegionList::key_type,AudioRegionList::mapped_type> entry; + + entry.first = region->id(); + entry.second = ar; + + pair<AudioRegionList::iterator,bool> x = audio_regions.insert (entry); + + + if (!x.second) { + return; + } + + added = true; + } - added = true; - } - - } else { - - fatal << _("programming error: ") - << X_("unknown region type passed to Session::add_region()") - << endmsg; - /*NOTREACHED*/ - + } else { + + fatal << _("programming error: ") + << X_("unknown region type passed to Session::add_region()") + << endmsg; + /*NOTREACHED*/ + + } } } @@ -2624,9 +2639,34 @@ Session::add_region (boost::shared_ptr<Region> region) set_dirty(); if (added) { - region->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_region), boost::weak_ptr<Region>(region))); - region->StateChanged.connect (sigc::bind (mem_fun (*this, &Session::region_changed), boost::weak_ptr<Region>(region))); - AudioRegionAdded (ar); /* EMIT SIGNAL */ + + vector<boost::weak_ptr<AudioRegion> > v; + boost::shared_ptr<AudioRegion> first_ar; + + for (vector<boost::shared_ptr<Region> >::iterator ii = new_regions.begin(); ii != new_regions.end(); ++ii) { + + boost::shared_ptr<Region> region = *ii; + boost::shared_ptr<AudioRegion> ar; + + if (region == 0) { + + error << _("Session::add_region() ignored a null region. Warning: you might have lost a region.") << endmsg; + + } else if ((ar = boost::dynamic_pointer_cast<AudioRegion> (region)) != 0) { + v.push_back (ar); + + if (!first_ar) { + first_ar = ar; + } + } + + region->StateChanged.connect (sigc::bind (mem_fun (*this, &Session::region_changed), boost::weak_ptr<Region>(region))); + region->GoingAway.connect (sigc::bind (mem_fun (*this, &Session::remove_region), boost::weak_ptr<Region>(region))); + } + + if (!v.empty()) { + AudioRegionsAdded (v); /* EMIT SIGNAL */ + } } } |