sane naming scheme for combined regions; fix deadlock when nesting to more than one...
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 16 May 2011 13:06:55 +0000 (13:06 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 16 May 2011 13:06:55 +0000 (13:06 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9519 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/route_time_axis.cc
libs/ardour/ardour/audio_playlist_source.h
libs/ardour/ardour/playlist.h
libs/ardour/audio_playlist_source.cc
libs/ardour/playlist.cc

index 449718d15ab919f69d2f0ad499c195741cdcc5a2..81dbefcd2994a3619de875bbaa9715ba36b27640 100644 (file)
@@ -2479,9 +2479,10 @@ RouteTimeAxisView::create_gain_automation_child (const Evoral::Parameter& param,
 }
 
 static
-void add_region_to_list (RegionView* rv, Playlist::RegionList* l)
+void add_region_to_list (RegionView* rv, Playlist::RegionList* l, uint32_t* max_level)
 {
        l->push_back (rv->region());
+       *max_level = max (*max_level, rv->region()->max_source_level());
 }
 
 void
@@ -2494,7 +2495,11 @@ RouteTimeAxisView::join_regions ()
        }
 
        Playlist::RegionList selected_regions;
+       uint32_t max_level = 0;
 
-       _view->foreach_selected_regionview (sigc::bind (sigc::ptr_fun (add_region_to_list), &selected_regions));
-       track()->playlist()->join (selected_regions, "foshizzle");
+       _view->foreach_selected_regionview (sigc::bind (sigc::ptr_fun (add_region_to_list), &selected_regions, &max_level));
+       
+       uint32_t num_joined_regions = track()->playlist()->count_joined_regions();
+       string name = string_compose (_("%1 combine-%2 (%3)"), track()->playlist()->name(), num_joined_regions+1, max_level+1);
+       track()->playlist()->join (selected_regions, name);
 }
index 868e8c743e140089f711c29f22ce0b11ee76cc80..d6047de1fc18e7353a0994f7e214edbed6b00ea5 100644 (file)
@@ -65,7 +65,6 @@ class AudioPlaylistSource : public AudioSource {
     framecnt_t                       _playlist_length;
     uint32_t                         _playlist_channel;
     std::string                      _peak_path;
-    uint32_t                         _level; /* how recursive is this? */
 };
         
 } /* namespace */
index e23ba264fc6944a6d61e874b3ab222bd13d6b4f9..3234e4c10829f85f875b4a56fb484f3ab1b992d2 100644 (file)
@@ -151,7 +151,8 @@ public:
        const RegionListProperty& region_list () const { return regions; }
 
        RegionList*                regions_at (framepos_t frame);
-        uint32_t                   count_regions_at (framepos_t);
+        uint32_t                   count_regions_at (framepos_t) const;
+       uint32_t                   count_joined_regions () const;
        RegionList*                regions_touched (framepos_t start, framepos_t end);
        RegionList*                regions_to_read (framepos_t start, framepos_t end);
        uint32_t                   region_use_count (boost::shared_ptr<Region>) const;
index 7d1e528ee685afcb8c48d39cd6508c8e061ca885..e8fabef7b1aa2c9c33fdd2413c924a169b10a4ca 100644 (file)
@@ -158,7 +158,7 @@ AudioPlaylistSource::set_state (const XMLNode& node, int /* version */)
 
        _peak_path = prop->value ();
 
-       _level = _playlist->max_source_level ();
+       _level = _playlist->max_source_level () + 1;
        ensure_buffers_for_level (_level);
 
        return 0;
@@ -167,6 +167,8 @@ AudioPlaylistSource::set_state (const XMLNode& node, int /* version */)
 framecnt_t 
 AudioPlaylistSource::read_unlocked (Sample* dst, framepos_t start, framecnt_t cnt) const
 {
+       Sample* sbuf;
+       gain_t* gbuf;
        framecnt_t to_read;
        framecnt_t to_zero;
        pair<framepos_t,framepos_t> extent = _playlist->get_extent();
@@ -185,10 +187,18 @@ AudioPlaylistSource::read_unlocked (Sample* dst, framepos_t start, framecnt_t cn
        }
 
        { 
+               /* Don't need to hold the lock for the actual read, and
+                  actually, we cannot, but we do want to interlock
+                  with any changes to the list of buffers caused
+                  by creating new nested playlists/sources
+               */
                Glib::Mutex::Lock lm (_level_buffer_lock);
-               _playlist->read (dst, _mixdown_buffers[_level-1], _gain_buffers[_level-1], start+_playlist_offset, to_read, _playlist_channel);
+               sbuf = _mixdown_buffers[_level-1];
+               gbuf = _gain_buffers[_level-1];
        }
 
+       _playlist->read (dst, sbuf, gbuf, start+_playlist_offset, to_read, _playlist_channel);
+
        if (to_zero) {
                memset (dst+to_read, 0, sizeof (Sample) * to_zero);
        }
@@ -246,19 +256,13 @@ AudioPlaylistSource::setup_peakfile ()
        /* the peak data is setup once and once only 
         */
        
-       cerr << "looking for peakfile " << _peak_path << endl;
-
-
        if (!Glib::file_test (_peak_path, Glib::FILE_TEST_EXISTS)) {
                /* the 2nd argument here will be passed
                   in to ::peak_path, and is irrelevant
                   since our peak file path is fixed and
                   not dependent on anything.
                */
-               cerr << "build it!\n";
                return initialize_peakfile (false, string());
-       } else {
-               cerr << "exists!\n";
        }
 
        return 0;
index 5d77310ccb30e8142ed6a889f090c87c30fcbbbb..fd9af56e80c1865e26a02b8a6b0b4960bb7272dc 100644 (file)
@@ -1756,12 +1756,12 @@ Playlist::regions_at (framepos_t frame)
 }
 
 uint32_t
-Playlist::count_regions_at (framepos_t frame)
+Playlist::count_regions_at (framepos_t frame) const
 {
-       RegionLock rlock (this);
+       RegionLock rlock (const_cast<Playlist*>(this));
        uint32_t cnt = 0;
 
-       for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+       for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
                if ((*i)->covers (frame)) {
                        cnt++;
                }
@@ -3166,3 +3166,20 @@ Playlist::max_source_level () const
 
        return lvl;
 }
+
+
+uint32_t
+Playlist::count_joined_regions () const
+{
+       RegionLock rlock (const_cast<Playlist *> (this));
+       uint32_t cnt = 0;
+
+       for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
+               if ((*i)->max_source_level() > 0) {
+                       cnt++;
+               }
+       }
+
+       return cnt;
+}
+