fix_bbtppq: add missing space - no-op
[ardour.git] / gtk2_ardour / engine_dialog.cc
index cf1d3b0d36eee0ee1efd76140d6ecc28744b228a..8a6c42fd8c79bdb11771d4463dcfe96322fa65b3 100644 (file)
@@ -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 ()) {
@@ -1969,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;
        }
@@ -2237,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);