From 3c45ab08468e552b1c6f2b5bd6dff2b74204a0b9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 8 Sep 2006 17:12:14 +0000 Subject: [PATCH] never remove tape track source files even if empty, reconnect editor mute/solo buttons git-svn-id: svn://localhost/ardour2/trunk@911 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/route_time_axis.cc | 5 +++++ libs/ardour/ardour/audiofilesource.h | 1 - libs/ardour/audiofilesource.cc | 5 +++-- libs/ardour/session.cc | 28 +++++++++++++++++++++++----- libs/ardour/session_state.cc | 2 -- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index c57b093c77..68c108c917 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -125,6 +125,11 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh visual_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::visual_click)); hide_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::hide_click)); + solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false); + solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false); + mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false); + mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false); + if (is_track()) { rec_enable_button->set_active (false); rec_enable_button->set_name ("TrackRecordEnableButton"); diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h index a18f055fd3..507a464421 100644 --- a/libs/ardour/ardour/audiofilesource.h +++ b/libs/ardour/ardour/audiofilesource.h @@ -121,7 +121,6 @@ class AudioFileSource : public AudioSource { string _path; Flag _flags; string _take_id; - bool allow_remove_if_empty; uint64_t timeline_position; static string peak_dir; diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index ad473e9d64..256286b729 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -101,6 +101,7 @@ AudioFileSource::AudioFileSource (Session& s, const XMLNode& node) AudioFileSource::~AudioFileSource () { if (removable()) { + cerr << "Removing file " << _path << " because its removable\n"; unlink (_path.c_str()); unlink (peakpath.c_str()); } @@ -109,7 +110,7 @@ AudioFileSource::~AudioFileSource () bool AudioFileSource::removable () const { - return (_flags & Removable) && ((_flags & RemoveAtDestroy) || ((_flags & RemovableIfEmpty) && is_empty (_session, _path))); + return (_flags & Removable) && ((_flags & RemoveAtDestroy) || ((_flags & RemovableIfEmpty) && length() == 0)); } int @@ -518,7 +519,7 @@ void AudioFileSource::set_allow_remove_if_empty (bool yn) { if (writable()) { - allow_remove_if_empty = yn; + _flags = Flag (_flags | RemovableIfEmpty); } } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index bafb43a57c..c7e349d14e 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -3183,16 +3183,34 @@ Session::RoutePublicOrderSorter::operator() (boost::shared_ptr a, boost:: void Session::remove_empty_sounds () { - PathScanner scanner; - string dir; - dir = sound_dir (); - - vector* possible_audiofiles = scanner (dir, "\\.wav$", false, true); + vector* possible_audiofiles = scanner (sound_dir(), "\\.(wav|aiff|caf|w64)$", false, true); + + Glib::Mutex::Lock lm (audio_source_lock); + regex_t compiled_tape_track_pattern; + int err; + + if ((err = regcomp (&compiled_tape_track_pattern, "/T[0-9][0-9][0-9][0-9]-", REG_EXTENDED|REG_NOSUB))) { + + char msg[256]; + + regerror (err, &compiled_tape_track_pattern, msg, sizeof (msg)); + + error << string_compose (_("Cannot compile tape track regexp for use (%1)"), msg) << endmsg; + return; + } + for (vector::iterator i = possible_audiofiles->begin(); i != possible_audiofiles->end(); ++i) { + + /* never remove files that appear to be a tape track */ + if (regexec (&compiled_tape_track_pattern, (*i)->c_str(), 0, 0, 0) == 0) { + delete *i; + continue; + } + if (AudioFileSource::is_empty (*this, *(*i))) { unlink ((*i)->c_str()); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 18c5721f7a..53a6273072 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -302,7 +302,6 @@ Session::second_stage_init (bool new_session) if (!new_session) { if (load_state (_current_snapshot_name)) { - cerr << "load state failed\n"; return -1; } remove_empty_sounds (); @@ -1884,7 +1883,6 @@ Session::load_sources (const XMLNode& node) boost::shared_ptr Session::XMLSourceFactory (const XMLNode& node) { - if (node.name() != "Source") { return boost::shared_ptr(); } -- 2.30.2