mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-04 20:55:48 +01:00
actually fix cleanup design, plus buglet that used the wrong directory to store files in when cleaned up
git-svn-id: svn://localhost/ardour2/trunk@1276 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
443126d148
commit
87a5518eb1
6 changed files with 24 additions and 111 deletions
|
|
@ -957,7 +957,6 @@ RouteTimeAxisView::use_new_playlist (bool prompt)
|
|||
if (name.length()) {
|
||||
ds->use_new_playlist ();
|
||||
ds->playlist()->set_name (name);
|
||||
cerr << " installed new PL, UC = " << ds->playlist().use_count() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -575,7 +575,6 @@ class Session : public PBD::StatefulDestructible
|
|||
|
||||
void add_source (boost::shared_ptr<Source>);
|
||||
void remove_source (boost::weak_ptr<Source>);
|
||||
int cleanup_audio_file_source (boost::shared_ptr<AudioFileSource>);
|
||||
|
||||
struct cleanup_report {
|
||||
vector<string> paths;
|
||||
|
|
|
|||
|
|
@ -1630,7 +1630,7 @@ AudioDiskstream::finish_capture (bool rec_monitors_input)
|
|||
void
|
||||
AudioDiskstream::set_record_enabled (bool yn)
|
||||
{
|
||||
if (!recordable() || !_session.record_enabling_legal()) {
|
||||
if (!recordable() || !_session.record_enabling_legal() || _io->n_inputs() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1927,7 +1927,7 @@ AudioDiskstream::reset_write_sources (bool mark_write_complete, bool force)
|
|||
}
|
||||
|
||||
capturing_sources.clear ();
|
||||
|
||||
|
||||
for (chan = channels.begin(), n = 0; chan != channels.end(); ++chan, ++n) {
|
||||
if (!destructive()) {
|
||||
|
||||
|
|
|
|||
|
|
@ -285,9 +285,11 @@ AudioFileSource::move_to_trash (const string trash_dir_name)
|
|||
stick it in the `trash_dir_name' directory
|
||||
on whichever filesystem it was already on.
|
||||
*/
|
||||
|
||||
|
||||
newpath = Glib::path_get_dirname (_path);
|
||||
newpath = Glib::path_get_dirname (newpath);
|
||||
newpath = Glib::path_get_dirname (newpath);
|
||||
|
||||
cerr << "from " << _path << " dead dir looks like " << newpath << endl;
|
||||
|
||||
newpath += '/';
|
||||
newpath += trash_dir_name;
|
||||
|
|
@ -511,7 +513,7 @@ AudioFileSource::set_name (string newname, bool destructive)
|
|||
}
|
||||
|
||||
if (rename (oldpath.c_str(), newpath.c_str()) != 0) {
|
||||
error << string_compose (_("cannot rename audio file for %1 to %2"), _name, newpath) << endmsg;
|
||||
error << string_compose (_("cannot rename audio file %1 to %2"), _name, newpath) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3080,19 +3080,16 @@ Session::remove_playlist (boost::weak_ptr<Playlist> weak_playlist)
|
|||
|
||||
{
|
||||
Glib::Mutex::Lock lm (playlist_lock);
|
||||
cerr << "removing playlist: " << playlist->name() << endl;
|
||||
|
||||
PlaylistList::iterator i;
|
||||
|
||||
i = find (playlists.begin(), playlists.end(), playlist);
|
||||
if (i != playlists.end()) {
|
||||
cerr << "\tfound it in used playlist\n";
|
||||
playlists.erase (i);
|
||||
}
|
||||
|
||||
i = find (unused_playlists.begin(), unused_playlists.end(), playlist);
|
||||
if (i != unused_playlists.end()) {
|
||||
cerr << "\tfound it in unused playlist\n";
|
||||
unused_playlists.erase (i);
|
||||
}
|
||||
|
||||
|
|
@ -3640,12 +3637,6 @@ Session::route_name_unique (string n) const
|
|||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
Session::cleanup_audio_file_source (boost::shared_ptr<AudioFileSource> fs)
|
||||
{
|
||||
return fs->move_to_trash (dead_sound_dir_name);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Session::n_playlists () const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2457,9 +2457,7 @@ struct RegionCounter {
|
|||
int
|
||||
Session::cleanup_sources (Session::cleanup_report& rep)
|
||||
{
|
||||
typedef map<boost::shared_ptr<Source>, RegionCounter> SourceRegionMap;
|
||||
SourceRegionMap dead_sources;
|
||||
|
||||
vector<boost::shared_ptr<Source> > dead_sources;
|
||||
vector<boost::shared_ptr<Playlist> > playlists_tbd;
|
||||
PathScanner scanner;
|
||||
string sound_path;
|
||||
|
|
@ -2505,104 +2503,26 @@ Session::cleanup_sources (Session::cleanup_report& rep)
|
|||
|
||||
playlists_tbd.clear ();
|
||||
|
||||
/* step 2: find all un-referenced sources */
|
||||
/* step 2: find all un-used sources */
|
||||
|
||||
rep.paths.clear ();
|
||||
rep.space = 0;
|
||||
|
||||
for (AudioSourceList::iterator i = audio_sources.begin(); i != audio_sources.end(); ++i) {
|
||||
for (AudioSourceList::iterator i = audio_sources.begin(); i != audio_sources.end(); ) {
|
||||
|
||||
/* we expect the use_count() to be at least 2: one for the shared_ptr<> in the sources
|
||||
list and one for the iterator. if its used by 1 region, we'd expect a value of 3.
|
||||
|
||||
do not bother with files that are zero size, otherwise we remove the current "nascent"
|
||||
capture files.
|
||||
*/
|
||||
|
||||
if (i->second.use_count() <= 3 && i->second->length() > 0) {
|
||||
|
||||
pair<boost::shared_ptr<Source>, RegionCounter> newpair;
|
||||
|
||||
newpair.first = i->second;
|
||||
newpair.second.iter = i;
|
||||
|
||||
dead_sources.insert (newpair);
|
||||
}
|
||||
}
|
||||
|
||||
/* Search the region list to find out the state of the supposedly unreferenced regions
|
||||
*/
|
||||
|
||||
for (SourceRegionMap::iterator i = dead_sources.begin(); i != dead_sources.end();++i) {
|
||||
|
||||
for (AudioRegionList::iterator r = audio_regions.begin(); r != audio_regions.end(); ++r) {
|
||||
|
||||
boost::shared_ptr<AudioRegion> ar = r->second;
|
||||
|
||||
for (uint32_t n = 0; n < ar->n_channels(); ++n) {
|
||||
|
||||
if (ar->source (n) == i->first) {
|
||||
|
||||
/* this region uses this source */
|
||||
|
||||
i->second.region = ar;
|
||||
i->second.count++;
|
||||
|
||||
if (i->second.count > 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* next, get rid of all regions in the region list that use any dead sources
|
||||
in case the sources themselves don't go away (they might be referenced in
|
||||
other snapshots).
|
||||
|
||||
this is also where we remove the apparently unused sources from our source
|
||||
list. this doesn't rename them or delete them, but it means they are
|
||||
potential candidates for renaming after we find all soundfiles
|
||||
and scan for use across all snapshots (including this one).
|
||||
*/
|
||||
|
||||
for (SourceRegionMap::iterator i = dead_sources.begin(); i != dead_sources.end(); ) {
|
||||
|
||||
SourceRegionMap::iterator tmp;
|
||||
AudioSourceList::iterator tmp;
|
||||
|
||||
tmp = i;
|
||||
++tmp;
|
||||
|
||||
if (i->second.count == 0) {
|
||||
/* do not bother with files that are zero size, otherwise we remove the current "nascent"
|
||||
capture files.
|
||||
*/
|
||||
|
||||
/* no regions use this source */
|
||||
|
||||
/* remove this source from our own list to avoid us
|
||||
adding it to the list of all sources below
|
||||
*/
|
||||
|
||||
audio_sources.erase (i->second.iter);
|
||||
|
||||
} else if (i->second.count == 1) {
|
||||
|
||||
/* the use_count for the source was 3. this means that there is only reference to it in addition to the source
|
||||
list and an iterator used to traverse that list. since there is a single region using the source, that
|
||||
must be the extra reference. this implies that its a whole-file region
|
||||
with no children, so remove the region and the source.
|
||||
*/
|
||||
|
||||
remove_region (i->second.region);
|
||||
|
||||
/* remove this source from our own list to avoid us
|
||||
adding it to the list of all sources below
|
||||
*/
|
||||
|
||||
audio_sources.erase (i->second.iter);
|
||||
|
||||
} else {
|
||||
/* more than one region uses this source, do not remove it */
|
||||
dead_sources.erase (i);
|
||||
}
|
||||
if (!i->second->used() && i->second->length() > 0) {
|
||||
dead_sources.push_back (i->second);
|
||||
i->second->GoingAway();
|
||||
}
|
||||
|
||||
i = tmp;
|
||||
}
|
||||
|
|
@ -2663,7 +2583,6 @@ Session::cleanup_sources (Session::cleanup_report& rep)
|
|||
used = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!used) {
|
||||
|
|
@ -2697,6 +2616,12 @@ Session::cleanup_sources (Session::cleanup_report& rep)
|
|||
|
||||
newpath += '/';
|
||||
newpath += dead_sound_dir_name;
|
||||
|
||||
if (g_mkdir_with_parents (newpath.c_str(), 0755) < 0) {
|
||||
error << string_compose(_("Session: cannot create session peakfile dir \"%1\" (%2)"), newpath, strerror (errno)) << endmsg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
newpath += '/';
|
||||
newpath += Glib::path_get_basename ((*x));
|
||||
|
||||
|
|
@ -2736,7 +2661,6 @@ Session::cleanup_sources (Session::cleanup_report& rep)
|
|||
<< endmsg;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
/* see if there an easy to find peakfile for this file, and remove it.
|
||||
*/
|
||||
|
|
@ -2934,8 +2858,6 @@ Session::save_history (string snapshot_name)
|
|||
return -1;
|
||||
}
|
||||
|
||||
cerr << "actually writing history\n";
|
||||
|
||||
if (!tree.write (xml_path))
|
||||
{
|
||||
error << string_compose (_("history could not be saved to %1"), xml_path) << endmsg;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue