+
+void
+JobManager::analyse_subtitles (
+ shared_ptr<const Film> film,
+ shared_ptr<Content> content,
+ boost::signals2::connection& connection,
+ function<void()> ready
+ )
+{
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+
+ for (auto i: _jobs) {
+ auto a = dynamic_pointer_cast<AnalyseSubtitlesJob> (i);
+ if (a && a->path() == film->subtitle_analysis_path(content)) {
+ i->when_finished (connection, ready);
+ return;
+ }
+ }
+ }
+
+ shared_ptr<AnalyseSubtitlesJob> job;
+
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+
+ job = make_shared<AnalyseSubtitlesJob>(film, content);
+ connection = job->Finished.connect (ready);
+ _jobs.push_back (job);
+ _empty_condition.notify_all ();
+ }
+
+ emit (boost::bind(boost::ref(JobAdded), weak_ptr<Job>(job)));
+}
+
+