Add option to analyse audio automatically when content is added (#673).
authorCarl Hetherington <cth@carlh.net>
Wed, 2 Sep 2015 10:20:24 +0000 (11:20 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 14 Sep 2015 09:20:41 +0000 (10:20 +0100)
16 files changed:
src/lib/analyse_audio_job.h
src/lib/config.cc
src/lib/config.h
src/lib/film.cc
src/lib/film.h
src/lib/job.cc
src/lib/job.h
src/lib/job_manager.cc
src/lib/job_manager.h
src/tools/dcpomatic.cc
src/wx/audio_dialog.cc
src/wx/config_dialog.cc
src/wx/film_editor.cc
src/wx/film_editor.h
src/wx/film_viewer.cc
src/wx/film_viewer.h

index d484bff2c8c2df130d51e5fa8bd0cb7c5984c5d7..d9b90ec668acc5c0ad090ad6139fe7c9efa4f6a9 100644 (file)
@@ -28,6 +28,7 @@
 class AudioBuffers;
 class AudioAnalysis;
 class Playlist;
 class AudioBuffers;
 class AudioAnalysis;
 class Playlist;
+class AudioPoint;
 
 /** @class AnalyseAudioJob
  *  @brief A job to analyse the audio of a film and make a note of its
 
 /** @class AnalyseAudioJob
  *  @brief A job to analyse the audio of a film and make a note of its
@@ -46,6 +47,10 @@ public:
        std::string json_name () const;
        void run ();
 
        std::string json_name () const;
        void run ();
 
+       boost::shared_ptr<const Playlist> playlist () const {
+               return _playlist;
+       }
+
 private:
        void analyse (boost::shared_ptr<const AudioBuffers>);
 
 private:
        void analyse (boost::shared_ptr<const AudioBuffers>);
 
index fc71a72f3399430a3951c7cdfe01ac94238f13b0..20386368e9aa1d96d5b3d46b1c1b0c1ee85302f7 100644 (file)
@@ -97,6 +97,7 @@ Config::set_defaults ()
        _check_for_test_updates = false;
        _maximum_j2k_bandwidth = 250000000;
        _log_types = Log::TYPE_GENERAL | Log::TYPE_WARNING | Log::TYPE_ERROR;
        _check_for_test_updates = false;
        _maximum_j2k_bandwidth = 250000000;
        _log_types = Log::TYPE_GENERAL | Log::TYPE_WARNING | Log::TYPE_ERROR;
+       _automatic_audio_analysis = false;
 #ifdef DCPOMATIC_WINDOWS
        _win32_console = false;
 #endif
 #ifdef DCPOMATIC_WINDOWS
        _win32_console = false;
 #endif
@@ -231,6 +232,7 @@ Config::read ()
        _allow_any_dcp_frame_rate = f.optional_bool_child ("AllowAnyDCPFrameRate");
 
        _log_types = f.optional_number_child<int> ("LogTypes").get_value_or (Log::TYPE_GENERAL | Log::TYPE_WARNING | Log::TYPE_ERROR);
        _allow_any_dcp_frame_rate = f.optional_bool_child ("AllowAnyDCPFrameRate");
 
        _log_types = f.optional_number_child<int> ("LogTypes").get_value_or (Log::TYPE_GENERAL | Log::TYPE_WARNING | Log::TYPE_ERROR);
+       _automatic_audio_analysis = f.optional_bool_child ("AutomaticAudioAnalysis").get_value_or (false);
 #ifdef DCPOMATIC_WINDOWS
        _win32_console = f.optional_bool_child ("Win32Console").get_value_or (false);
 #endif
 #ifdef DCPOMATIC_WINDOWS
        _win32_console = f.optional_bool_child ("Win32Console").get_value_or (false);
 #endif
@@ -375,6 +377,7 @@ Config::write () const
        root->add_child("MaximumJ2KBandwidth")->add_child_text (raw_convert<string> (_maximum_j2k_bandwidth));
        root->add_child("AllowAnyDCPFrameRate")->add_child_text (_allow_any_dcp_frame_rate ? "1" : "0");
        root->add_child("LogTypes")->add_child_text (raw_convert<string> (_log_types));
        root->add_child("MaximumJ2KBandwidth")->add_child_text (raw_convert<string> (_maximum_j2k_bandwidth));
        root->add_child("AllowAnyDCPFrameRate")->add_child_text (_allow_any_dcp_frame_rate ? "1" : "0");
        root->add_child("LogTypes")->add_child_text (raw_convert<string> (_log_types));
+       root->add_child("AutomaticAudioAnalysis")->add_child_text (_automatic_audio_analysis ? "1" : "0");
 #ifdef DCPOMATIC_WINDOWS
        root->add_child("Win32Console")->add_child_text (_win32_console ? "1" : "0");
 #endif
 #ifdef DCPOMATIC_WINDOWS
        root->add_child("Win32Console")->add_child_text (_win32_console ? "1" : "0");
 #endif
index fc63c518cd944b71aaca336c5c1f1944702dace2..2f68ea31cb7b91cc5e085f78fee121400ae87ef8 100644 (file)
@@ -226,6 +226,10 @@ public:
                return _log_types;
        }
 
                return _log_types;
        }
 
+       bool automatic_audio_analysis () const {
+               return _automatic_audio_analysis;
+       }
+
 #ifdef DCPOMATIC_WINDOWS
        bool win32_console () const {
                return _win32_console;
 #ifdef DCPOMATIC_WINDOWS
        bool win32_console () const {
                return _win32_console;
@@ -407,6 +411,10 @@ public:
                maybe_set (_log_types, t);
        }
 
                maybe_set (_log_types, t);
        }
 
+       void set_automatic_audio_analysis (bool a) {
+               maybe_set (_automatic_audio_analysis, a);
+       }
+
 #ifdef DCPOMATIC_WINDOWS
        void set_win32_console (bool c) {
                maybe_set (_win32_console, c);
 #ifdef DCPOMATIC_WINDOWS
        void set_win32_console (bool c) {
                maybe_set (_win32_console, c);
@@ -505,6 +513,7 @@ private:
        /** maximum allowed J2K bandwidth in bits per second */
        int _maximum_j2k_bandwidth;
        int _log_types;
        /** maximum allowed J2K bandwidth in bits per second */
        int _maximum_j2k_bandwidth;
        int _log_types;
+       bool _automatic_audio_analysis;
 #ifdef DCPOMATIC_WINDOWS
        bool _win32_console;
 #endif
 #ifdef DCPOMATIC_WINDOWS
        bool _win32_console;
 #endif
index 685fc76588981c4b43aeabf12eb2c8b601d26e6e..231ac92e19daf13affba40b10a2d66650c323e19 100644 (file)
@@ -162,8 +162,12 @@ Film::Film (boost::filesystem::path dir, bool log)
 
 Film::~Film ()
 {
 
 Film::~Film ()
 {
-       for (list<boost::signals2::connection>::const_iterator i = _job_connections.begin(); i != _job_connections.end(); ++i) {
-               i->disconnect ();
+       BOOST_FOREACH (boost::signals2::connection& i, _job_connections) {
+               i.disconnect ();
+       }
+
+       BOOST_FOREACH (boost::signals2::connection& i, _audio_analysis_connections) {
+               i.disconnect ();
        }
 }
 
        }
 }
 
@@ -947,8 +951,19 @@ Film::maybe_add_content (weak_ptr<Job> j, weak_ptr<Content> c)
        }
 
        shared_ptr<Content> content = c.lock ();
        }
 
        shared_ptr<Content> content = c.lock ();
-       if (content) {
-               add_content (content);
+       if (!content) {
+               return;
+       }
+
+       add_content (content);
+       if (Config::instance()->automatic_audio_analysis ()) {
+               shared_ptr<Playlist> playlist (new Playlist);
+               playlist->add (content);
+               boost::signals2::connection c;
+               JobManager::instance()->analyse_audio (
+                       shared_from_this (), playlist, c, bind (&Film::audio_analysis_finished, this)
+                       );
+               _audio_analysis_connections.push_back (c);
        }
 }
 
        }
 }
 
@@ -1233,3 +1248,9 @@ Film::remove_content (ContentList c)
 {
        _playlist->remove (c);
 }
 {
        _playlist->remove (c);
 }
+
+void
+Film::audio_analysis_finished ()
+{
+       /* XXX */
+}
index 2165eed23d203d4dd39fb7b0c327e04d604f312a..aa7be939ea950262a52f2ff9d677ca7982643bd6 100644 (file)
@@ -296,6 +296,7 @@ private:
        void playlist_changed ();
        void playlist_content_changed (boost::weak_ptr<Content>, int, bool frequent);
        void maybe_add_content (boost::weak_ptr<Job>, boost::weak_ptr<Content>);
        void playlist_changed ();
        void playlist_content_changed (boost::weak_ptr<Content>, int, bool frequent);
        void maybe_add_content (boost::weak_ptr<Job>, boost::weak_ptr<Content>);
+       void audio_analysis_finished ();
 
        /** Log to write to */
        boost::shared_ptr<Log> _log;
 
        /** Log to write to */
        boost::shared_ptr<Log> _log;
@@ -345,6 +346,7 @@ private:
        boost::signals2::scoped_connection _playlist_changed_connection;
        boost::signals2::scoped_connection _playlist_content_changed_connection;
        std::list<boost::signals2::connection> _job_connections;
        boost::signals2::scoped_connection _playlist_changed_connection;
        boost::signals2::scoped_connection _playlist_content_changed_connection;
        std::list<boost::signals2::connection> _job_connections;
+       std::list<boost::signals2::connection> _audio_analysis_connections;
 
        friend struct paths_test;
        friend struct film_metadata_test;
 
        friend struct paths_test;
        friend struct film_metadata_test;
index 784defc91736074e53292fdbcdb4c306341d7d6f..37bf462fca0a3b1ffb65063a008f9b572df18982 100644 (file)
@@ -39,6 +39,7 @@ using std::list;
 using std::cout;
 using boost::shared_ptr;
 using boost::optional;
 using std::cout;
 using boost::shared_ptr;
 using boost::optional;
+using boost::function;
 
 #define LOG_ERROR_NC(...) _film->log()->log (__VA_ARGS__, Log::TYPE_ERROR);
 
 
 #define LOG_ERROR_NC(...) _film->log()->log (__VA_ARGS__, Log::TYPE_ERROR);
 
@@ -434,3 +435,15 @@ Job::resume ()
                _pause_changed.notify_all ();
        }
 }
                _pause_changed.notify_all ();
        }
 }
+
+void
+Job::when_finished (boost::signals2::connection& connection, function<void()> finished)
+{
+       boost::mutex::scoped_lock lm (_state_mutex);
+       if (_state == FINISHED_OK || _state == FINISHED_ERROR || _state == FINISHED_CANCELLED) {
+               finished ();
+       } else {
+               connection = Finished.connect (finished);
+       }
+}
+
index 1caa5a90458368e4cdd0d6af696044966efeed93..32e71d6581c0bb3767f68dca222cc58ce601aa80 100644 (file)
@@ -80,6 +80,8 @@ public:
                return _film;
        }
 
                return _film;
        }
 
+       void when_finished (boost::signals2::connection& connection, boost::function<void()> finished);
+
        boost::signals2::signal<void()> Progress;
        /** Emitted from the UI thread when the job is finished */
        boost::signals2::signal<void()> Finished;
        boost::signals2::signal<void()> Progress;
        /** Emitted from the UI thread when the job is finished */
        boost::signals2::signal<void()> Finished;
index e3f91f4fcf22dde2721e9c100d7e1a0e8c379dbf..3748fa3537b7e972fb5f31b5a65ca026466e78a3 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     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
 
     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
  *  @brief A simple scheduler for jobs.
  */
 
  *  @brief A simple scheduler for jobs.
  */
 
-#include <iostream>
-#include <boost/thread.hpp>
 #include "job_manager.h"
 #include "job.h"
 #include "cross.h"
 #include "job_manager.h"
 #include "job.h"
 #include "cross.h"
+#include "analyse_audio_job.h"
+#include "film.h"
+#include <boost/thread.hpp>
+#include <boost/foreach.hpp>
+#include <iostream>
 
 using std::string;
 using std::list;
 using std::cout;
 using boost::shared_ptr;
 using boost::weak_ptr;
 
 using std::string;
 using std::list;
 using std::cout;
 using boost::shared_ptr;
 using boost::weak_ptr;
+using boost::function;
+using boost::dynamic_pointer_cast;
+using boost::optional;
 
 JobManager* JobManager::_instance = 0;
 
 JobManager::JobManager ()
        : _terminate (false)
 
 JobManager* JobManager::_instance = 0;
 
 JobManager::JobManager ()
        : _terminate (false)
-       , _last_active_jobs (false)
        , _scheduler (0)
 {
 
        , _scheduler (0)
 {
 
@@ -113,7 +118,7 @@ JobManager::scheduler ()
 {
        while (true) {
 
 {
        while (true) {
 
-               bool active_jobs = false;
+               optional<string> active_job;
 
                {
                        boost::mutex::scoped_lock lm (_mutex);
 
                {
                        boost::mutex::scoped_lock lm (_mutex);
@@ -121,29 +126,28 @@ JobManager::scheduler ()
                                return;
                        }
 
                                return;
                        }
 
-                       for (list<shared_ptr<Job> >::iterator i = _jobs.begin(); i != _jobs.end(); ++i) {
+                       BOOST_FOREACH (shared_ptr<Job> i, _jobs) {
 
 
-                               if (!(*i)->finished ()) {
-                                       active_jobs = true;
+                               if (!i->finished ()) {
+                                       active_job = i->json_name ();
                                }
 
                                }
 
-                               if ((*i)->running ()) {
+                               if (i->running ()) {
                                        /* Something is already happening */
                                        break;
                                }
 
                                        /* Something is already happening */
                                        break;
                                }
 
-                               if ((*i)->is_new()) {
-                                       (*i)->start ();
-
+                               if (i->is_new()) {
+                                       i->start ();
                                        /* Only start one job at once */
                                        break;
                                }
                        }
                }
 
                                        /* Only start one job at once */
                                        break;
                                }
                        }
                }
 
-               if (active_jobs != _last_active_jobs) {
-                       _last_active_jobs = active_jobs;
-                       emit (boost::bind (boost::ref (ActiveJobsChanged), active_jobs));
+               if (active_job != _last_active_job) {
+                       _last_active_job = active_job;
+                       emit (boost::bind (boost::ref (ActiveJobsChanged), active_job));
                }
 
                dcpomatic_sleep (1);
                }
 
                dcpomatic_sleep (1);
@@ -167,3 +171,32 @@ JobManager::drop ()
        delete _instance;
        _instance = 0;
 }
        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
+       )
+{
+       shared_ptr<AnalyseAudioJob> job;
+
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+
+               BOOST_FOREACH (shared_ptr<Job> i, _jobs) {
+                       shared_ptr<AnalyseAudioJob> a = dynamic_pointer_cast<AnalyseAudioJob> (i);
+                       if (a && film->audio_analysis_path (a->playlist ()) == film->audio_analysis_path (playlist)) {
+                               i->when_finished (connection, ready);
+                               return;
+                       }
+               }
+
+               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)));
+}
index 3cd8be6d67e21207caaeb86cb25d57943ac87b57..7de7862a18bd2ff7bfc929462d184279d8c8bfb3 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     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
 
     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
@@ -28,6 +28,9 @@
 #include <list>
 
 class Job;
 #include <list>
 
 class Job;
+class Film;
+class Playlist;
+
 extern void wait_for_jobs ();
 
 /** @class JobManager
 extern void wait_for_jobs ();
 
 /** @class JobManager
@@ -42,8 +45,15 @@ public:
        bool work_to_do () const;
        bool errors () const;
 
        bool work_to_do () const;
        bool errors () const;
 
+       void analyse_audio (
+               boost::shared_ptr<const Film> film,
+               boost::shared_ptr<const Playlist> playlist,
+               boost::signals2::connection& connection,
+               boost::function<void()> ready
+               );
+
        boost::signals2::signal<void (boost::weak_ptr<Job>)> JobAdded;
        boost::signals2::signal<void (boost::weak_ptr<Job>)> JobAdded;
-       boost::signals2::signal<void (bool)> ActiveJobsChanged;
+       boost::signals2::signal<void (boost::optional<std::string>)> ActiveJobsChanged;
 
        static JobManager* instance ();
        static void drop ();
 
        static JobManager* instance ();
        static void drop ();
@@ -61,7 +71,7 @@ private:
        std::list<boost::shared_ptr<Job> > _jobs;
        bool _terminate;
 
        std::list<boost::shared_ptr<Job> > _jobs;
        bool _terminate;
 
-       bool _last_active_jobs;
+       boost::optional<std::string> _last_active_job;
        boost::thread* _scheduler;
 
        static JobManager* _instance;
        boost::thread* _scheduler;
 
        static JobManager* _instance;
index 8692f4c83094bc23ca5f18de2a1e06dd44fafd92..5abf47182a89a46e44dc131256c4678b062cffcb 100644 (file)
@@ -44,7 +44,6 @@
 #include "lib/signal_manager.h"
 #include "lib/log.h"
 #include "lib/job_manager.h"
 #include "lib/signal_manager.h"
 #include "lib/log.h"
 #include "lib/job_manager.h"
-#include "lib/transcode_job.h"
 #include "lib/exceptions.h"
 #include "lib/cinema.h"
 #include "lib/kdm.h"
 #include "lib/exceptions.h"
 #include "lib/cinema.h"
 #include "lib/kdm.h"
@@ -606,7 +605,7 @@ private:
        {
                list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
                list<shared_ptr<Job> >::iterator i = jobs.begin();
        {
                list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
                list<shared_ptr<Job> >::iterator i = jobs.begin();
-               while (i != jobs.end() && dynamic_pointer_cast<TranscodeJob> (*i) == 0) {
+               while (i != jobs.end() && (*i)->json_name() != "transcode") {
                        ++i;
                }
                bool const dcp_creation = (i != jobs.end ()) && !(*i)->finished ();
                        ++i;
                }
                bool const dcp_creation = (i != jobs.end ()) && !(*i)->finished ();
index a14498359078bc901fcfd5b8228bdb51137f1769..d4108f89c32aeffadf6136320c1d14693227c999 100644 (file)
@@ -133,14 +133,11 @@ AudioDialog::try_to_load_analysis ()
        shared_ptr<const Film> film = _film.lock ();
        DCPOMATIC_ASSERT (film);
 
        shared_ptr<const Film> film = _film.lock ();
        DCPOMATIC_ASSERT (film);
 
-       boost::filesystem::path path = film->audio_analysis_path (_playlist);
-
+       boost::filesystem::path const path = film->audio_analysis_path (_playlist);
        if (!boost::filesystem::exists (path)) {
                _plot->set_analysis (shared_ptr<AudioAnalysis> ());
                _analysis.reset ();
        if (!boost::filesystem::exists (path)) {
                _plot->set_analysis (shared_ptr<AudioAnalysis> ());
                _analysis.reset ();
-               shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, _playlist));
-               _analysis_finished_connection = job->Finished.connect (bind (&AudioDialog::analysis_finished, this));
-               JobManager::instance()->add (job);
+               JobManager::instance()->analyse_audio (film, _playlist, _analysis_finished_connection, bind (&AudioDialog::analysis_finished, this));
                return;
        }
 
                return;
        }
 
@@ -148,9 +145,7 @@ AudioDialog::try_to_load_analysis ()
                _analysis.reset (new AudioAnalysis (path));
        } catch (xmlpp::exception& e) {
                /* Probably an old-style analysis file: recreate it */
                _analysis.reset (new AudioAnalysis (path));
        } catch (xmlpp::exception& e) {
                /* Probably an old-style analysis file: recreate it */
-               shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, _playlist));
-               _analysis_finished_connection = job->Finished.connect (bind (&AudioDialog::analysis_finished, this));
-               JobManager::instance()->add (job);
+               JobManager::instance()->analyse_audio (film, _playlist, _analysis_finished_connection, bind (&AudioDialog::analysis_finished, this));
                return;
         }
 
                return;
         }
 
index 08b78bce1abdc3291964b4a67d32789463233675..4633552a6e874c6e0ffdf613815b72dca50e74a6 100644 (file)
@@ -183,6 +183,10 @@ private:
                table->Add (_num_local_encoding_threads, wxGBPosition (r, 1));
                ++r;
 
                table->Add (_num_local_encoding_threads, wxGBPosition (r, 1));
                ++r;
 
+               _automatic_audio_analysis = new wxCheckBox (_panel, wxID_ANY, _("Automatically analyse content audio"));
+               table->Add (_automatic_audio_analysis, wxGBPosition (r, 0), wxGBSpan (1, 2));
+               ++r;
+
                _check_for_updates = new wxCheckBox (_panel, wxID_ANY, _("Check for updates on startup"));
                table->Add (_check_for_updates, wxGBPosition (r, 0), wxGBSpan (1, 2));
                ++r;
                _check_for_updates = new wxCheckBox (_panel, wxID_ANY, _("Check for updates on startup"));
                table->Add (_check_for_updates, wxGBPosition (r, 0), wxGBSpan (1, 2));
                ++r;
@@ -211,6 +215,7 @@ private:
                _num_local_encoding_threads->SetRange (1, 128);
                _num_local_encoding_threads->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&GeneralPage::num_local_encoding_threads_changed, this));
 
                _num_local_encoding_threads->SetRange (1, 128);
                _num_local_encoding_threads->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&GeneralPage::num_local_encoding_threads_changed, this));
 
+               _automatic_audio_analysis->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::automatic_audio_analysis_changed, this));
                _check_for_updates->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::check_for_updates_changed, this));
                _check_for_test_updates->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::check_for_test_updates_changed, this));
 
                _check_for_updates->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::check_for_updates_changed, this));
                _check_for_test_updates->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::check_for_test_updates_changed, this));
 
@@ -249,6 +254,7 @@ private:
                setup_language_sensitivity ();
 
                checked_set (_num_local_encoding_threads, config->num_local_encoding_threads ());
                setup_language_sensitivity ();
 
                checked_set (_num_local_encoding_threads, config->num_local_encoding_threads ());
+               checked_set (_automatic_audio_analysis, config->automatic_audio_analysis ());
                checked_set (_check_for_updates, config->check_for_updates ());
                checked_set (_check_for_test_updates, config->check_for_test_updates ());
                checked_set (_issuer, config->dcp_issuer ());
                checked_set (_check_for_updates, config->check_for_updates ());
                checked_set (_check_for_test_updates, config->check_for_test_updates ());
                checked_set (_issuer, config->dcp_issuer ());
@@ -306,6 +312,11 @@ private:
                }
        }
 
                }
        }
 
+       void automatic_audio_analysis_changed ()
+       {
+               Config::instance()->set_automatic_audio_analysis (_automatic_audio_analysis->GetValue ());
+       }
+
        void check_for_updates_changed ()
        {
                Config::instance()->set_check_for_updates (_check_for_updates->GetValue ());
        void check_for_updates_changed ()
        {
                Config::instance()->set_check_for_updates (_check_for_updates->GetValue ());
@@ -334,6 +345,7 @@ private:
        wxCheckBox* _set_language;
        wxChoice* _language;
        wxSpinCtrl* _num_local_encoding_threads;
        wxCheckBox* _set_language;
        wxChoice* _language;
        wxSpinCtrl* _num_local_encoding_threads;
+       wxCheckBox* _automatic_audio_analysis;
        wxCheckBox* _check_for_updates;
        wxCheckBox* _check_for_test_updates;
        wxTextCtrl* _issuer;
        wxCheckBox* _check_for_updates;
        wxCheckBox* _check_for_test_updates;
        wxTextCtrl* _issuer;
index 545eaf56ea610f13099c3e25784373b78a97dbe9..b67c9612dbb765e4eeaa67070f1e0693712e89d3 100644 (file)
@@ -34,7 +34,9 @@
 #include <iostream>
 
 using std::cout;
 #include <iostream>
 
 using std::cout;
+using std::string;
 using boost::shared_ptr;
 using boost::shared_ptr;
+using boost::optional;
 
 /** @param f Film to edit */
 FilmEditor::FilmEditor (wxWindow* parent, FilmViewer* viewer)
 
 /** @param f Film to edit */
 FilmEditor::FilmEditor (wxWindow* parent, FilmViewer* viewer)
@@ -136,7 +138,7 @@ FilmEditor::set_general_sensitivity (bool s)
 }
 
 void
 }
 
 void
-FilmEditor::active_jobs_changed (bool a)
+FilmEditor::active_jobs_changed (optional<string> j)
 {
 {
-       set_general_sensitivity (!a);
+       set_general_sensitivity (!j || *j == "analyse_audio");
 }
 }
index 43a1214c2c915aad424bd63178c8852201cb823f..e19fcabdf81cd45db2fe0fd0ac8551a08b7c33d5 100644 (file)
@@ -58,7 +58,7 @@ public:
        void film_content_changed (int);
 
        void set_general_sensitivity (bool);
        void film_content_changed (int);
 
        void set_general_sensitivity (bool);
-       void active_jobs_changed (bool);
+       void active_jobs_changed (boost::optional<std::string>);
 
        wxNotebook* _main_notebook;
        ContentPanel* _content_panel;
 
        wxNotebook* _main_notebook;
        ContentPanel* _content_panel;
index 3f4bc6514048143df7f464280b3926d6ec9d4b5c..f00cdfe28ae8ee910940c8d185f541a8cf146792 100644 (file)
@@ -54,6 +54,7 @@ using std::exception;
 using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 using boost::weak_ptr;
 using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 using boost::weak_ptr;
+using boost::optional;
 using dcp::Size;
 
 FilmViewer::FilmViewer (wxWindow* p)
 using dcp::Size;
 
 FilmViewer::FilmViewer (wxWindow* p)
@@ -385,23 +386,12 @@ FilmViewer::update_position_label ()
 }
 
 void
 }
 
 void
-FilmViewer::active_jobs_changed (bool a)
+FilmViewer::active_jobs_changed (optional<string> j)
 {
 {
-       if (a) {
-               list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
-               list<shared_ptr<Job> >::iterator i = jobs.begin ();
-               while (i != jobs.end() && boost::dynamic_pointer_cast<ExamineContentJob> (*i) == 0) {
-                       ++i;
-               }
-
-               if (i == jobs.end() || (*i)->finished()) {
-                       /* no examine content job running, so we're ok to use the viewer */
-                       a = false;
-               }
-       }
-
-       _slider->Enable (!a);
-       _play_button->Enable (!a);
+       /* examine content is the only job which stops the viewer working */
+       bool const a = !j || *j != "examine_content";
+       _slider->Enable (a);
+       _play_button->Enable (a);
 }
 
 void
 }
 
 void
index eb9d256d3782857b2c83e4d5d06a964a2c105ce7..4776d24b48cc37976a5036e3e991056117e5b9de 100644 (file)
@@ -56,7 +56,7 @@ private:
        void timer ();
        void calculate_sizes ();
        void check_play_state ();
        void timer ();
        void calculate_sizes ();
        void check_play_state ();
-       void active_jobs_changed (bool);
+       void active_jobs_changed (boost::optional<std::string>);
        void back_clicked ();
        void forward_clicked ();
        void player_changed (bool);
        void back_clicked ();
        void forward_clicked ();
        void player_changed (bool);