Allow configuration of default audio delay (#276).
authorCarl Hetherington <cth@carlh.net>
Fri, 20 Dec 2013 21:26:17 +0000 (21:26 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 20 Dec 2013 21:26:17 +0000 (21:26 +0000)
ChangeLog
src/lib/audio_content.cc
src/lib/config.cc
src/lib/config.h
src/wx/config_dialog.cc
src/wx/config_dialog.h

index 7b384191fd6ccfff6428d068a5e2d707a9853358..ed6021c98495c7775e2d8d177733d8835589db75 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2013-12-20  Carl Hetherington  <cth@carlh.net>
 
+       * Add configuration option for default audio delay (#276).
+
        * Version 1.46 released.
 
 2013-12-19  Carl Hetherington  <cth@carlh.net>
index 97372b962a7285368d2317d1d3be5c769d313eb4..b4c4f34b6f064aaa71e822869728e266c488bdf0 100644 (file)
@@ -23,6 +23,7 @@
 #include "job_manager.h"
 #include "film.h"
 #include "exceptions.h"
+#include "config.h"
 
 #include "i18n.h"
 
@@ -42,7 +43,7 @@ int const AudioContentProperty::AUDIO_MAPPING = 205;
 AudioContent::AudioContent (shared_ptr<const Film> f, Time s)
        : Content (f, s)
        , _audio_gain (0)
-       , _audio_delay (0)
+       , _audio_delay (Config::instance()->default_audio_delay ())
 {
 
 }
@@ -50,7 +51,7 @@ AudioContent::AudioContent (shared_ptr<const Film> f, Time s)
 AudioContent::AudioContent (shared_ptr<const Film> f, boost::filesystem::path p)
        : Content (f, p)
        , _audio_gain (0)
-       , _audio_delay (0)
+       , _audio_delay (Config::instance()->default_audio_delay ())
 {
 
 }
index ccbcdf7ddb04e5cf08f4a80ca3c1d609545ce556..93eec9bc0330fb4258f3f90d78de59759adc83b7 100644 (file)
@@ -64,6 +64,7 @@ Config::Config ()
        , _default_container (Ratio::from_id ("185"))
        , _default_dcp_content_type (DCPContentType::from_dci_name ("TST"))
        , _default_j2k_bandwidth (200000000)
+       , _default_audio_delay (0)
        , _kdm_email (
                "Dear Projectionist\n\nPlease find attached KDMs for $CPL_NAME.\n\nBest regards,\nDCP-o-matic"
                )
@@ -145,6 +146,7 @@ Config::read ()
        _default_dci_metadata = DCIMetadata (f.node_child ("DCIMetadata"));
        _default_still_length = f.optional_number_child<int>("DefaultStillLength").get_value_or (10);
        _default_j2k_bandwidth = f.optional_number_child<int>("DefaultJ2KBandwidth").get_value_or (200000000);
+       _default_audio_delay = f.optional_number_child<int>("DefaultAudioDelay").get_value_or (0);
 
        list<cxml::NodePtr> cc = f.node_children ("ColourConversion");
 
@@ -334,6 +336,7 @@ Config::write () const
 
        root->add_child("DefaultStillLength")->add_child_text (lexical_cast<string> (_default_still_length));
        root->add_child("DefaultJ2KBandwidth")->add_child_text (lexical_cast<string> (_default_j2k_bandwidth));
+       root->add_child("DefaultAudioDelay")->add_child_text (lexical_cast<string> (_default_audio_delay));
 
        for (vector<PresetColourConversion>::const_iterator i = _colour_conversions.begin(); i != _colour_conversions.end(); ++i) {
                i->as_xml (root->add_child ("ColourConversion"));
index 1fa54f669bd83130fa8502faf3c9789e9a5a8285..14c707dd2dcf85d70fe4449b05d82637040cf7fb 100644 (file)
@@ -143,6 +143,10 @@ public:
                return _default_j2k_bandwidth;
        }
 
+       int default_audio_delay () const {
+               return _default_audio_delay;
+       }
+
        std::vector<PresetColourConversion> colour_conversions () const {
                return _colour_conversions;
        }
@@ -245,6 +249,10 @@ public:
                _default_j2k_bandwidth = b;
        }
 
+       void set_default_audio_delay (int d) {
+               _default_audio_delay = d;
+       }
+
        void set_colour_conversions (std::vector<PresetColourConversion> const & c) {
                _colour_conversions = c;
        }
@@ -309,6 +317,7 @@ private:
        DCPContentType const * _default_dcp_content_type;
        libdcp::XMLMetadata _dcp_metadata;
        int _default_j2k_bandwidth;
+       int _default_audio_delay;
        std::vector<PresetColourConversion> _colour_conversions;
        std::list<boost::shared_ptr<Cinema> > _cinemas;
        std::string _mail_server;
index 71a0f505fc794947ce5a7791e5564245de078428..4743000f23a90000ff7371d84bcb6e36c1ff49a5 100644 (file)
@@ -158,6 +158,15 @@ ConfigDialog::make_misc_panel ()
                add_label_to_sizer (s, _misc_panel, _("MBps"), false);
                table->Add (s, 1);
        }
+
+       {
+               add_label_to_sizer (table, _misc_panel, _("Default audio delay"), true);
+               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+               _default_audio_delay = new wxSpinCtrl (_misc_panel);
+               s->Add (_default_audio_delay);
+               add_label_to_sizer (s, _misc_panel, _("ms"), false);
+               table->Add (s, 1);
+       }
        
        Config* config = Config::instance ();
 
@@ -225,6 +234,10 @@ ConfigDialog::make_misc_panel ()
        _default_j2k_bandwidth->SetRange (50, 250);
        _default_j2k_bandwidth->SetValue (config->default_j2k_bandwidth() / 1000000);
        _default_j2k_bandwidth->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&ConfigDialog::default_j2k_bandwidth_changed, this));
+
+       _default_audio_delay->SetRange (-1000, 1000);
+       _default_audio_delay->SetValue (config->default_audio_delay ());
+       _default_audio_delay->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&ConfigDialog::default_audio_delay_changed, this));
 }
 
 void
@@ -457,6 +470,12 @@ ConfigDialog::default_j2k_bandwidth_changed ()
        Config::instance()->set_default_j2k_bandwidth (_default_j2k_bandwidth->GetValue() * 1000000);
 }
 
+void
+ConfigDialog::default_audio_delay_changed ()
+{
+       Config::instance()->set_default_audio_delay (_default_audio_delay->GetValue());
+}
+
 static std::string
 colour_conversion_column (PresetColourConversion c)
 {
index 3a196cce309d031b742a1da39fcbfd692fe91089..45739ef9287ba3a9253ea7124159ac8b9d07b467 100644 (file)
@@ -58,6 +58,7 @@ private:
        void issuer_changed ();
        void creator_changed ();
        void default_j2k_bandwidth_changed ();
+       void default_audio_delay_changed ();
        void mail_server_changed ();
        void kdm_from_changed ();
        void kdm_email_changed ();
@@ -99,6 +100,7 @@ private:
        wxTextCtrl* _issuer;
        wxTextCtrl* _creator;
        wxSpinCtrl* _default_j2k_bandwidth;
+       wxSpinCtrl* _default_audio_delay;
        wxPanel* _kdm_email_panel;
        wxTextCtrl* _kdm_email;
        wxCheckBox* _use_any_servers;