don't display internal returns to user
[ardour.git] / libs / ardour / region_factory.cc
index 7f11b8089cbc8494e23fdbfb13fbc05c93ac98f1..6f49d8c5b392e17b72eeb7ed9c64ccbf6a3e5fb7 100644 (file)
@@ -17,7 +17,6 @@
 
 */
 
-#define __STDC_FORMAT_MACROS
 #include <inttypes.h>
 
 #include "pbd/error.h"
@@ -46,7 +45,7 @@ Glib::StaticMutex RegionFactory::region_name_map_lock;
 std::map<std::string, uint32_t> RegionFactory::region_name_map;
 
 boost::shared_ptr<Region>
-RegionFactory::create (boost::shared_ptr<const Region> region)
+RegionFactory::create (boost::shared_ptr<const Region> region, bool announce)
 {
        boost::shared_ptr<Region> ret;
        boost::shared_ptr<const AudioRegion> ar;
@@ -73,12 +72,17 @@ RegionFactory::create (boost::shared_ptr<const Region> region)
        }
 
        if (ret) {
+               ret->set_name (new_region_name(ret->name()));
                map_add (ret);
 
                /* pure copy constructor - no property list */
                /* pure copy constructor - no CheckNewRegion emitted */
+               if (announce) {
+                       CheckNewRegion (ret);
+               }
        }
 
+
        return ret;
 }
 
@@ -123,7 +127,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, frameoffset_t offset, b
        }
 
        if (ret) {
-               ret->set_properties (plist);
+               ret->apply_changes (plist);
                map_add (ret);
 
                if (announce) {
@@ -162,7 +166,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs,
 
        if (ret) {
 
-               ret->set_properties (plist);
+               ret->apply_changes (plist);
                map_add (ret);
 
                if (announce) {
@@ -207,7 +211,7 @@ RegionFactory::create (const SourceList& srcs, const PropertyList& plist, bool a
 
        if (ret) {
 
-               ret->set_properties (plist);
+               ret->apply_changes (plist);
                map_add (ret);
 
                if (announce) {
@@ -271,7 +275,6 @@ RegionFactory::map_add (boost::shared_ptr<Region> r)
 
         { 
                 Glib::Mutex::Lock lm (region_map_lock);
-                cerr << "MAP ADD: " << r->name() << " ID = " << r->id() << endl;
                 region_map.insert (p);
         }
 
@@ -324,13 +327,34 @@ RegionFactory::region_by_id (const PBD::ID& id)
        RegionMap::iterator i = region_map.find (id);
 
        if (i == region_map.end()) {
-                cerr << "ID " << id << " not found in region map\n";
                return boost::shared_ptr<Region>();
        }
 
        return i->second;
 }
-       
+
+boost::shared_ptr<Region>
+RegionFactory::wholefile_region_by_name (const std::string& name)
+{
+        for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
+                if (i->second->whole_file() && i->second->name() == name) {
+                        return i->second;
+                }
+        }
+        return boost::shared_ptr<Region>();
+}      
+
+boost::shared_ptr<Region>
+RegionFactory::region_by_name (const std::string& name)
+{
+        for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
+                if (i->second->name() == name) {
+                        return i->second;
+                }
+        }
+        return boost::shared_ptr<Region>();
+}      
+
 void
 RegionFactory::clear_map ()
 {