summaryrefslogtreecommitdiff
path: root/libs/ardour/analyser.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-11-25 00:55:41 +0100
committerRobin Gareus <robin@gareus.org>2015-11-25 00:56:05 +0100
commit71520c743212de6d4e42fbdfd8bfbd0611600dae (patch)
tree44f296e679de75ad423f36c6fcecefecd9cde4a8 /libs/ardour/analyser.cc
parentff62cec27d710a5a25caf028010aadd5a4bf0bac (diff)
Prevent crash at session-close when analysing.
The Analyser only holds a weak-pointer the the Source, session-destruction frees the actual Source, which is fatal for any ongoing audio analysis. This fix simply waits for the current ongoing analysis to complete, ideally TransientDetector::run, EBUr128Analysis::run, OnsetDetector::run and AudioAnalyser::analyse could be interrupted. Alternate option: cancel the Analyser::work thread (and re-create with the every session).
Diffstat (limited to 'libs/ardour/analyser.cc')
-rw-r--r--libs/ardour/analyser.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/libs/ardour/analyser.cc b/libs/ardour/analyser.cc
index fa22bd757d..58a8f30245 100644
--- a/libs/ardour/analyser.cc
+++ b/libs/ardour/analyser.cc
@@ -31,6 +31,7 @@ using namespace ARDOUR;
using namespace PBD;
Analyser* Analyser::the_analyser = 0;
+Glib::Threads::Mutex Analyser::analysis_active_lock;
Glib::Threads::Mutex Analyser::analysis_queue_lock;
Glib::Threads::Cond Analyser::SourcesToAnalyse;
list<boost::weak_ptr<Source> > Analyser::analysis_queue;
@@ -96,6 +97,7 @@ Analyser::work ()
boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src);
if (afs && afs->length(afs->timeline_position())) {
+ Glib::Threads::Mutex::Lock lm (analysis_active_lock);
analyse_audio_file_source (afs);
}
}
@@ -119,3 +121,11 @@ Analyser::analyse_audio_file_source (boost::shared_ptr<AudioFileSource> src)
return;
}
}
+
+void
+Analyser::flush ()
+{
+ Glib::Threads::Mutex::Lock lq (analysis_queue_lock);
+ Glib::Threads::Mutex::Lock la (analysis_active_lock);
+ analysis_queue.clear();
+}