13
0

Remove empty MIDI regions which result from recordings made when no MIDI data is received.

git-svn-id: svn://localhost/ardour2/branches/3.0@7167 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-05-26 16:03:47 +00:00
parent b91e1f3605
commit 102f64f94c
3 changed files with 24 additions and 0 deletions

View File

@ -136,6 +136,7 @@ class Playlist : public SessionObject
void add_region (boost::shared_ptr<Region>, framepos_t position, float times = 1, bool auto_partition = false);
void remove_region (boost::shared_ptr<Region>);
void remove_region_by_source (boost::shared_ptr<Source>);
void get_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&);
void get_region_list_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&);
void replace_region (boost::shared_ptr<Region> old, boost::shared_ptr<Region> newr, framepos_t pos);

View File

@ -1321,6 +1321,10 @@ MidiDiskstream::use_new_write_source (uint32_t n)
if (_write_source) {
if (_write_source->is_empty ()) {
/* remove any region that is using this empty source; they can result when MIDI recordings
are made, but no MIDI data is received.
*/
_playlist->remove_region_by_source (_write_source);
_write_source->mark_for_remove ();
_write_source->drop_references ();
_write_source.reset();

View File

@ -2939,3 +2939,22 @@ Playlist::has_region_at (framepos_t const p) const
return (i != regions.end());
}
/** Remove any region that uses a given source */
void
Playlist::remove_region_by_source (boost::shared_ptr<Source> s)
{
RegionLock rl (this);
RegionList::iterator i = regions.begin();
while (i != regions.end()) {
RegionList::iterator j = i;
++j;
if ((*i)->uses_source (s)) {
remove_region_internal (*i);
}
i = j;
}
}