+
+void
+JobManager::drop ()
+{
+ delete _instance;
+ _instance = 0;
+}
+
+void
+JobManager::analyse_audio (
+ shared_ptr<const Film> film,
+ shared_ptr<const Playlist> playlist,
+ boost::signals2::connection& connection,
+ function<void()> ready
+ )
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+
+ BOOST_FOREACH (shared_ptr<Job> i, _jobs) {
+ shared_ptr<AnalyseAudioJob> a = dynamic_pointer_cast<AnalyseAudioJob> (i);
+ if (a && a->playlist () == playlist) {
+ i->when_finished (connection, ready);
+ return;
+ }
+ }
+ }
+
+ shared_ptr<AnalyseAudioJob> job;
+
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+
+ job.reset (new AnalyseAudioJob (film, playlist));
+ connection = job->Finished.connect (ready);
+ _jobs.push_back (job);
+ }
+
+ emit (boost::bind (boost::ref (JobAdded), weak_ptr<Job> (job)));
+}