fix_bbtppq: add missing space - no-op
[ardour.git] / gtk2_ardour / engine_dialog.cc
index cc85bda8783e5b7a028a6b79be32e18ffbb51a92..8a6c42fd8c79bdb11771d4463dcfe96322fa65b3 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;
@@ -852,11 +852,17 @@ EngineControl::update_sensitivity ()
        }
 
        if (get_popdown_string_count (sample_rate_combo) > 0) {
+               bool allow_to_set_rate = false;
                if (!ARDOUR::AudioEngine::instance()->running()) {
-                       sample_rate_combo.set_sensitive (true);
-               } else {
-                       sample_rate_combo.set_sensitive (false);
+                       if (!ARDOUR_UI::instance()->session_loaded) {
+                               // engine is not running, no session loaded -> anything goes.
+                               allow_to_set_rate = true;
+                       } else if (_desired_sample_rate > 0 && get_rate () != _desired_sample_rate) {
+                               // only allow to change if the current setting is not the native session rate.
+                               allow_to_set_rate = true;
+                       }
                }
+               sample_rate_combo.set_sensitive (allow_to_set_rate);
        } else {
                sample_rate_combo.set_sensitive (false);
                valid = false;
@@ -1392,7 +1398,10 @@ EngineControl::set_samplerate_popdown_strings ()
        set_popdown_strings (sample_rate_combo, s);
 
        if (!s.empty()) {
-               if (desired.empty ()) {
+               if (ARDOUR::AudioEngine::instance()->running()) {
+                       sample_rate_combo.set_active_text (rate_as_string (backend->sample_rate()));
+               }
+               else if (desired.empty ()) {
                        float new_active_sr = backend->default_sample_rate ();
 
                        if (std::find (sr.begin (), sr.end (), new_active_sr) == sr.end ()) {
@@ -1596,12 +1605,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
@@ -1900,7 +1904,7 @@ EngineControl::maybe_display_saved_state ()
 XMLNode&
 EngineControl::get_state ()
 {
-       LocaleGuard lg (X_("C"));
+       LocaleGuard lg;
 
        XMLNode* root = new XMLNode ("AudioMIDISetup");
        std::string path;
@@ -1974,8 +1978,6 @@ EngineControl::set_state (const XMLNode& root)
        XMLNode const * grandchild;
        XMLProperty const * prop = NULL;
 
-       fprintf (stderr, "EngineControl::set_state\n");
-
        if (root.name() != "AudioMIDISetup") {
                return false;
        }
@@ -2242,7 +2244,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);
@@ -2367,6 +2371,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;
                }
 
@@ -2428,7 +2434,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 {