Cope with e.g. truehd audio streams having not every audio frame arriving with a...
[dcpomatic.git] / src / lib / config.cc
index 18fda63e3750467d3d958a2533777724dd10b68d..4f481ef3043d0b31e82e0bcda024c175e8cd02d1 100644 (file)
@@ -64,6 +64,7 @@ using dcp::raw_convert;
 
 Config* Config::_instance = 0;
 boost::signals2::signal<void ()> Config::FailedToLoad;
+boost::signals2::signal<void (string)> Config::Warning;
 
 /** Construct default configuration */
 Config::Config ()
@@ -125,8 +126,8 @@ Config::set_defaults ()
        for (int i = 0; i < NAG_COUNT; ++i) {
                _nagged[i] = false;
        }
-       _preview_sound = false;
-       _preview_sound_output = optional<string> ();
+       _sound = false;
+       _sound_output = optional<string> ();
 
        _allowed_dcp_frame_rates.clear ();
        _allowed_dcp_frame_rates.push_back (24);
@@ -225,6 +226,11 @@ try
                _default_container = Ratio::from_id (c.get ());
        }
 
+       if (_default_container && !_default_container->used_for_container()) {
+               Warning (_("Your default container is not valid and has been changed to Flat (1.85:1)"));
+               _default_container = Ratio::from_id ("185");
+       }
+
        c = f.optional_string_child ("DefaultScaleTo");
        if (c) {
                _default_scale_to = Ratio::from_id (c.get ());
@@ -342,11 +348,13 @@ try
                        _nagged[id] = raw_convert<int>(i->content());
                }
        }
-       _preview_sound = f.optional_bool_child("PreviewSound").get_value_or (false);
-       _preview_sound_output = f.optional_string_child("PreviewSoundOutput");
+       /* The variable was renamed but not the XML tag */
+       _sound = f.optional_bool_child("PreviewSound").get_value_or (false);
+       _sound_output = f.optional_string_child("PreviewSoundOutput");
        if (f.optional_string_child("CoverSheet")) {
                _cover_sheet = f.optional_string_child("CoverSheet").get();
        }
+       _last_player_load_directory = f.optional_string_child("LastPlayerLoadDirectory");
 
        /* Replace any cinemas from config.xml with those from the configured file */
        if (boost::filesystem::exists (_cinemas_file)) {
@@ -474,9 +482,9 @@ Config::write_config () const
                root->add_child("Language")->add_child_text (_language.get());
        }
        if (_default_container) {
-               /* [XML:opt] DefaultContainer ID of default container to use when creating new films (<code>119</code>, <code>133</code>,
-                  <code>138</code>, <code>143</code>, <code>166</code>, <code>178</code>, <code>185</code>, <code>235</code>,
-                  <code>239</code> or <code>full-frame</code>).
+               /* [XML:opt] DefaultContainer ID of default container
+                * to use when creating new films (<code>185</code>,<code>239</code> or
+                * <code>full-frame</code>).
                */
                root->add_child("DefaultContainer")->add_child_text (_default_container->id ());
        }
@@ -616,14 +624,17 @@ Config::write_config () const
                e->set_attribute ("Id", raw_convert<string>(i));
                e->add_child_text (_nagged[i] ? "1" : "0");
        }
-       /* [XML] PreviewSound 1 to use sound in the GUI preview, otherwise 0 */
-       root->add_child("PreviewSound")->add_child_text (_preview_sound ? "1" : "0");
-       if (_preview_sound_output) {
+       /* [XML] PreviewSound 1 to use sound in the GUI preview and player, otherwise 0 */
+       root->add_child("PreviewSound")->add_child_text (_sound ? "1" : "0");
+       if (_sound_output) {
                /* [XML:opt] PreviewSoundOutput Name of the audio output to use */
-               root->add_child("PreviewSoundOutput")->add_child_text (_preview_sound_output.get());
+               root->add_child("PreviewSoundOutput")->add_child_text (_sound_output.get());
        }
        /* [XML] CoverSheet Text of the cover sheet to write when making DCPs */
        root->add_child("CoverSheet")->add_child_text (_cover_sheet);
+       if (_last_player_load_directory) {
+               root->add_child("LastPlayerLoadDirectory")->add_child_text(_last_player_load_directory->string());
+       }
 
        try {
                doc.write_to_file_formatted(config_file().string());