LuaProc::can_support_io_configuration: don't mix int and int32_t
[ardour.git] / gtk2_ardour / engine_dialog.cc
index da0e6168d93eff63e7ad914506dbc35e09abd5e7..4f03e92a49205f2c337e9c4a30037357c353343a 100644 (file)
@@ -53,7 +53,7 @@
 #include "engine_dialog.h"
 #include "gui_thread.h"
 #include "utils.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace Gtk;
@@ -423,6 +423,18 @@ EngineControl::on_show ()
        ok_button->grab_focus();
 }
 
+bool
+EngineControl::try_autostart ()
+{
+       if (!start_stop_button.get_sensitive()) {
+               return false;
+       }
+       if (ARDOUR::AudioEngine::instance()->running()) {
+               return true;
+       }
+       return start_engine ();
+}
+
 bool
 EngineControl::start_engine ()
 {
@@ -1584,12 +1596,7 @@ EngineControl::output_device_changed ()
 string
 EngineControl::bufsize_as_string (uint32_t sz)
 {
-       /* Translators: "samples" is always plural here, so no
-          need for plural+singular forms.
-        */
-       char buf[64];
-       snprintf (buf, sizeof (buf), "%u %s", sz, P_("sample", "samples", sz));
-       return buf;
+       return string_compose (P_("%1 sample", "%1 samples", sz), sz);
 }
 
 string
@@ -1888,7 +1895,7 @@ EngineControl::maybe_display_saved_state ()
 XMLNode&
 EngineControl::get_state ()
 {
-       LocaleGuard lg (X_("C"));
+       LocaleGuard lg;
 
        XMLNode* root = new XMLNode ("AudioMIDISetup");
        std::string path;
@@ -1958,11 +1965,9 @@ EngineControl::set_state (const XMLNode& root)
 {
        XMLNodeList          clist, cclist;
        XMLNodeConstIterator citer, cciter;
-       XMLNode* child;
-       XMLNode* grandchild;
-       XMLProperty* prop = NULL;
-
-       fprintf (stderr, "EngineControl::set_state\n");
+       XMLNode const * child;
+       XMLNode const * grandchild;
+       XMLProperty const * prop = NULL;
 
        if (root.name() != "AudioMIDISetup") {
                return false;
@@ -2230,7 +2235,9 @@ EngineControl::set_current_state (const State& state)
        device_combo.set_active_text (state->device);
        input_device_combo.set_active_text (state->input_device);
        output_device_combo.set_active_text (state->output_device);
-       sample_rate_combo.set_active_text (rate_as_string (state->sample_rate));
+       if (!_desired_sample_rate) {
+               sample_rate_combo.set_active_text (rate_as_string (state->sample_rate));
+       }
        set_active_text_if_present (buffer_size_combo, bufsize_as_string (state->buffer_size));
        set_active_text_if_present (nperiods_combo, nperiods_as_string (state->n_periods));
        input_latency.set_value (state->input_latency);
@@ -2355,6 +2362,8 @@ EngineControl::push_state_to_backend (bool start)
                        change_channels = true;
                        change_latency = true;
                        change_midi = true;
+                       change_buffered_io = backend->can_use_buffered_io();
+                       change_channels = true;
                        change_nperiods = backend->can_set_period_size() && get_popdown_string_count (nperiods_combo) > 0;
                }
 
@@ -2416,7 +2425,7 @@ EngineControl::push_state_to_backend (bool start)
        if (change_driver || change_device || change_channels || change_nperiods ||
                        (change_latency && !backend->can_change_systemic_latency_when_running ()) ||
                        (change_rate && !backend->can_change_sample_rate_when_running()) ||
-                       change_midi ||
+                       change_midi || change_buffered_io ||
                        (change_bufsize && !backend->can_change_buffer_size_when_running())) {
                restart_required = true;
        } else {
@@ -2759,6 +2768,10 @@ void
 EngineControl::set_desired_sample_rate (uint32_t sr)
 {
        _desired_sample_rate = sr;
+       if (ARDOUR::AudioEngine::instance ()->running ()
+                       && ARDOUR::AudioEngine::instance ()->sample_rate () != sr) {
+               stop_engine ();
+       }
        device_changed ();
 }