/*
- Copyright (C) 2008 Paul Davis
+ Copyright (C) 2008 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
-#include <ardour/analyser.h>
-#include <ardour/audiofilesource.h>
-#include <ardour/transient_detector.h>
-
-#include <pbd/pthread_utils.h>
-#include <pbd/convert.h>
+#include "ardour/analyser.h"
+#include "ardour/audiofilesource.h"
+#include "ardour/session_event.h"
+#include "ardour/transient_detector.h"
using namespace std;
-using namespace sigc;
using namespace ARDOUR;
using namespace PBD;
Analyser* Analyser::the_analyser = 0;
-Glib::StaticMutex Analyser::analysis_queue_lock = GLIBMM_STATIC_MUTEX_INIT;
-Glib::Cond* Analyser::SourcesToAnalyse = 0;
+Glib::Threads::Mutex Analyser::analysis_queue_lock;
+Glib::Threads::Cond Analyser::SourcesToAnalyse;
list<boost::weak_ptr<Source> > Analyser::analysis_queue;
Analyser::Analyser ()
{
-
+
}
Analyser::~Analyser ()
void
Analyser::init ()
{
- SourcesToAnalyse = new Glib::Cond();
- Glib::Thread::create (sigc::ptr_fun (analyser_work), false);
+ Glib::Threads::Thread::create (sigc::ptr_fun (analyser_work));
}
void
return;
}
- Glib::Mutex::Lock lm (analysis_queue_lock);
+ Glib::Threads::Mutex::Lock lm (analysis_queue_lock);
analysis_queue.push_back (boost::weak_ptr<Source>(src));
- SourcesToAnalyse->broadcast ();
+ SourcesToAnalyse.broadcast ();
}
void
Analyser::work ()
{
- PBD::ThreadCreated (pthread_self(), string ("analyser-") + to_string (pthread_self(), std::dec));
+ SessionEvent::create_per_thread_pool ("Analyser", 64);
while (true) {
analysis_queue_lock.lock ();
wait:
if (analysis_queue.empty()) {
- SourcesToAnalyse->wait (analysis_queue_lock);
+ SourcesToAnalyse.wait (analysis_queue_lock);
}
if (analysis_queue.empty()) {
boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (src);
- if (afs) {
+ if (afs && afs->length(afs->timeline_position())) {
analyse_audio_file_source (afs);
}
}
}
-