diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-09-02 11:20:24 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-09-14 10:20:41 +0100 |
| commit | d2bd0c628fd0616fe3b7dd02bd955b2c07ab48d5 (patch) | |
| tree | e974870e7e4b6014520b461a19a7b336eb7617a3 /src/wx | |
| parent | c138f4050bffbdc97edca8a824297f155dc62da3 (diff) | |
Add option to analyse audio automatically when content is added (#673).
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/audio_dialog.cc | 11 | ||||
| -rw-r--r-- | src/wx/config_dialog.cc | 12 | ||||
| -rw-r--r-- | src/wx/film_editor.cc | 6 | ||||
| -rw-r--r-- | src/wx/film_editor.h | 2 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 22 | ||||
| -rw-r--r-- | src/wx/film_viewer.h | 2 |
6 files changed, 27 insertions, 28 deletions
diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index a14498359..d4108f89c 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -133,14 +133,11 @@ AudioDialog::try_to_load_analysis () 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 (); - 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; } @@ -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 */ - 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; } diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 08b78bce1..4633552a6 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -183,6 +183,10 @@ private: 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; @@ -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)); + _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)); @@ -249,6 +254,7 @@ private: 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 ()); @@ -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 ()); @@ -334,6 +345,7 @@ private: 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; diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 545eaf56e..b67c9612d 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -34,7 +34,9 @@ #include <iostream> using std::cout; +using std::string; using boost::shared_ptr; +using boost::optional; /** @param f Film to edit */ FilmEditor::FilmEditor (wxWindow* parent, FilmViewer* viewer) @@ -136,7 +138,7 @@ FilmEditor::set_general_sensitivity (bool s) } 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"); } diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 43a1214c2..e19fcabdf 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -58,7 +58,7 @@ public: 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; diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 3f4bc6514..f00cdfe28 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -54,6 +54,7 @@ using std::exception; using boost::shared_ptr; using boost::dynamic_pointer_cast; using boost::weak_ptr; +using boost::optional; using dcp::Size; FilmViewer::FilmViewer (wxWindow* p) @@ -385,23 +386,12 @@ FilmViewer::update_position_label () } 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 diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index eb9d256d3..4776d24b4 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -56,7 +56,7 @@ private: 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); |
