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 b44a10db1969c76bd631bee3788e2f24c8bb03ca..9884e9936d18a0dc8ae3e9ec4ca959d53818503d 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 ad2606d84bbab3dbda3031c963fd42b1dc8c3553..e4a100c4a3fd92265635448538ec4b2f3f894551 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 d8dcda2f19c43b8d18b22a53cb5ce81c96d70e4c..b88d6c2bf4e97ba7bd3acbdaf51583f46e284014 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 e2302a2153a01275686c20d724849328bb3c752a..26e2d28970a71c0f5a9d90b7582ed2738fd2fca0 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 81687ca809942ecb00a67a209b71180ba94fda38..f3f7c1f8ced0797c21d9dd3a9595eb9b1dc4e6b5 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)
                        );