diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in
index 27c030669e..f997347a7b 100644
--- a/gtk2_ardour/ardour.menus.in
+++ b/gtk2_ardour/ardour.menus.in
@@ -36,7 +36,8 @@
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index 89f0bb4f90..c041e7d89f 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -107,6 +107,7 @@ typedef uint64_t microseconds_t;
#include "ambiguous_file_dialog.h"
#include "ardour_ui.h"
#include "audio_clock.h"
+#include "audio_region_view.h"
#include "big_clock_window.h"
#include "bundle_manager.h"
#include "engine_dialog.h"
@@ -3712,6 +3713,47 @@ ARDOUR_UI::flush_trash ()
display_cleanup_results (rep, _("deleted file"), true);
}
+void
+ARDOUR_UI::cleanup_peakfiles ()
+{
+ if (_session == 0) {
+ /* shouldn't happen: menu item is insensitive */
+ return;
+ }
+
+ if (! _session->can_cleanup_peakfiles ()) {
+ return;
+ }
+
+ // get all region-views in this session
+ RegionSelection rs;
+ TrackViewList empty;
+ empty.clear();
+ editor->get_regions_after(rs, (framepos_t) 0, empty);
+ std::list views = rs.by_layer();
+
+ // remove displayed audio-region-views waveforms
+ for (list::iterator i = views.begin(); i != views.end(); ++i) {
+ AudioRegionView* arv = dynamic_cast (*i);
+ if (!arv) { continue ; }
+ arv->delete_waves();
+ }
+
+ // cleanup peak files:
+ // - stop pending peakfile threads
+ // - close peakfiles if any
+ // - remove peak dir in session
+ // - setup peakfiles (background thread)
+ _session->cleanup_peakfiles ();
+
+ // re-add waves to ARV
+ for (list::iterator i = views.begin(); i != views.end(); ++i) {
+ AudioRegionView* arv = dynamic_cast (*i);
+ if (!arv) { continue ; }
+ arv->create_waves();
+ }
+}
+
void
ARDOUR_UI::setup_order_hint (AddRouteDialog::InsertAt place)
{
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h
index f279ebd6ad..244972d838 100644
--- a/gtk2_ardour/ardour_ui.h
+++ b/gtk2_ardour/ardour_ui.h
@@ -688,6 +688,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
void display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete);
void cleanup ();
+ void cleanup_peakfiles ();
void flush_trash ();
bool have_configure_timeout;
diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc
index 4455e72832..d08f47f76a 100644
--- a/gtk2_ardour/ardour_ui_ed.cc
+++ b/gtk2_ardour/ardour_ui_ed.cc
@@ -182,6 +182,10 @@ ARDOUR_UI::install_actions ()
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::write_sensitive_actions.push_back (act);
+ act = ActionManager::register_action (main_actions, X_("CleanupPeakFiles"), _("Clean-up Peak Files..."), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::cleanup_peakfiles));
+ ActionManager::session_sensitive_actions.push_back (act);
+ ActionManager::write_sensitive_actions.push_back (act);
+
act = ActionManager::register_action (main_actions, X_("FlushWastebasket"), _("Flush Wastebasket"), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::flush_trash));
ActionManager::write_sensitive_actions.push_back (act);
ActionManager::session_sensitive_actions.push_back (act);
diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc
index fef4868dc8..18d17af380 100644
--- a/gtk2_ardour/audio_region_view.cc
+++ b/gtk2_ardour/audio_region_view.cc
@@ -1115,6 +1115,22 @@ AudioRegionView::update_envelope_visibility ()
}
}
+void
+AudioRegionView::delete_waves ()
+{
+ for (vector::iterator i = _data_ready_connections.begin(); i != _data_ready_connections.end(); ++i) {
+ delete *i;
+ }
+ _data_ready_connections.clear ();
+
+ for (vector::iterator w = waves.begin(); w != waves.end(); ++w) {
+ group->remove(*w);
+ }
+ waves.clear();
+ tmp_waves.clear();
+ pending_peak_data->show ();
+}
+
void
AudioRegionView::create_waves ()
{
diff --git a/gtk2_ardour/audio_region_view.h b/gtk2_ardour/audio_region_view.h
index 367a701ea8..e82b5fc5ed 100644
--- a/gtk2_ardour/audio_region_view.h
+++ b/gtk2_ardour/audio_region_view.h
@@ -74,6 +74,7 @@ class AudioRegionView : public RegionView
boost::shared_ptr audio_region() const;
void create_waves ();
+ void delete_waves ();
void set_height (double);
void set_samples_per_pixel (double);
diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h
index 63778dfaec..fcc53464a6 100644
--- a/gtk2_ardour/public_editor.h
+++ b/gtk2_ardour/public_editor.h
@@ -421,6 +421,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi
bool for_mark = false) = 0;
virtual void get_regions_at (RegionSelection &, framepos_t where, TrackViewList const &) const = 0;
+ virtual void get_regions_after (RegionSelection&, framepos_t where, const TrackViewList& ts) const = 0;
virtual RegionSelection get_regions_from_selection_and_mouse (framepos_t) = 0;
virtual void get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const = 0;
virtual void get_per_region_note_selection (std::list > > > >&) const = 0;