Make sure audio analysis is re-run even if there's an existing job for the same playl...
authorCarl Hetherington <cth@carlh.net>
Tue, 8 Jan 2019 23:34:04 +0000 (23:34 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 8 Jan 2019 23:34:04 +0000 (23:34 +0000)
ChangeLog
src/lib/analyse_audio_job.cc
src/lib/analyse_audio_job.h
src/lib/job_manager.cc
src/wx/audio_dialog.cc

index b44a10d..9884e99 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2019-01-08  Carl Hetherington  <cth@carlh.net>
+
+       * Fix failure to re-analyse audio when the channel map changes (#1257).
+
 2019-01-06  Carl Hetherington  <cth@carlh.net>
 
        * Disable subtitle view/font buttons with FFmpeg content (#1236).
index ad2606d..e4a100c 100644 (file)
@@ -54,6 +54,7 @@ int const AnalyseAudioJob::_num_points = 1024;
 AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, bool from_zero)
        : Job (film)
        , _playlist (playlist)
+       , _path (film->audio_analysis_path(playlist))
        , _from_zero (from_zero)
        , _done (0)
        , _samples_per_point (1)
@@ -166,7 +167,7 @@ AnalyseAudioJob::run ()
 
        _analysis->set_samples_per_point (_samples_per_point);
        _analysis->set_sample_rate (_film->audio_frame_rate ());
-       _analysis->write (_film->audio_analysis_path (_playlist));
+       _analysis->write (_path);
 
        set_progress (1);
        set_state (FINISHED_OK);
index d8dcda2..b88d6c2 100644 (file)
@@ -51,14 +51,16 @@ public:
        std::string json_name () const;
        void run ();
 
-       boost::shared_ptr<const Playlist> playlist () const {
-               return _playlist;
+       boost::filesystem::path path () const {
+               return _path;
        }
 
 private:
        void analyse (boost::shared_ptr<const AudioBuffers>, DCPTime time);
 
        boost::shared_ptr<const Playlist> _playlist;
+       /** playlist's audio analysis path when the job was created */
+       boost::filesystem::path _path;
        DCPTime _start;
        bool _from_zero;
 
index e2302a2..26e2d28 100644 (file)
@@ -233,7 +233,7 @@ JobManager::analyse_audio (
 
                BOOST_FOREACH (shared_ptr<Job> i, _jobs) {
                        shared_ptr<AnalyseAudioJob> a = dynamic_pointer_cast<AnalyseAudioJob> (i);
-                       if (a && a->playlist () == playlist) {
+                       if (a && a->path() == film->audio_analysis_path(playlist)) {
                                i->when_finished (connection, ready);
                                return;
                        }
index 81687ca..f3f7c1f 100644 (file)
@@ -182,6 +182,13 @@ AudioDialog::try_to_load_analysis ()
        if (!boost::filesystem::exists (path)) {
                _plot->set_analysis (shared_ptr<AudioAnalysis> ());
                _analysis.reset ();
+
+               BOOST_FOREACH (shared_ptr<Job> i, JobManager::instance()->get()) {
+                       if (dynamic_pointer_cast<AnalyseAudioJob>(i)) {
+                               i->cancel ();
+                       }
+               }
+
                JobManager::instance()->analyse_audio (
                        film, _playlist, !static_cast<bool>(check), _analysis_finished_connection, bind (&AudioDialog::analysis_finished, this)
                        );