remove obsolete jack includes in libardour
[ardour.git] / gtk2_ardour / engine_dialog.cc
index 3da4dca38e0e804e454ac73ec24f67f60b2a3b57..f3dba387abbb5109e035decff1738eaf17bc5841 100644 (file)
@@ -58,6 +58,7 @@ using namespace Gtk;
 using namespace Gtkmm2ext;
 using namespace PBD;
 using namespace Glib;
+using namespace ARDOUR_UI_UTILS;
 
 static const unsigned int midi_tab = 2;
 static const unsigned int latency_tab = 1; /* zero-based, page zero is the main setup page */
@@ -299,6 +300,13 @@ EngineControl::EngineControl ()
        notebook.signal_switch_page().connect (sigc::mem_fun (*this, &EngineControl::on_switch_page));
 }
 
+void
+EngineControl::on_show ()
+{
+       ArdourDialog::on_show ();
+       ok_button->grab_focus();
+}
+
 void
 EngineControl::on_response (int response_id)
 {
@@ -365,7 +373,10 @@ EngineControl::build_notebook ()
                basic_vbox.pack_start (*hpacker);
        }
 
-       basic_vbox.show_all ();
+       {
+               PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
+               basic_vbox.show_all ();
+       }
 }
 
 void
@@ -547,10 +558,10 @@ EngineControl::enable_latency_tab ()
        lm_back_button_signal.disconnect();
        if (_measure_midi) {
                lm_back_button_signal = lm_back_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (notebook, &Gtk::Notebook::set_current_page), midi_tab));
-               lm_preamble.set_markup (_(""));
+               lm_preamble.hide ();
        } else {
                lm_back_button_signal = lm_back_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (notebook, &Gtk::Notebook::set_current_page), 0));
-               lm_preamble.set_markup (_("<span weight=\"bold\">Turn down the volume on your audio equipment to a very low level.</span>"));
+               lm_preamble.show ();
        }
 
        set_popdown_strings (lm_output_channel_combo, outputs);
@@ -705,9 +716,20 @@ EngineControl::backend_changed ()
 
                if (!drivers.empty()) {
                        {
+                               string current_driver;
+                               current_driver = backend->driver_name ();
+
+                               // driver might not have been set yet
+                               if (current_driver == "") {
+                                       current_driver = driver_combo.get_active_text ();
+                                       if (current_driver == "")
+                                               // driver has never been set, make sure it's not blank
+                                               current_driver = drivers.front ();
+                               }
+
                                PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
                                set_popdown_strings (driver_combo, drivers);
-                               driver_combo.set_active_text (drivers.front());
+                               driver_combo.set_active_text (current_driver);
                        }
 
                        driver_changed ();
@@ -789,13 +811,29 @@ EngineControl::list_devices ()
                update_sensitivity ();
 
                {
+                       string current_device;
+                       current_device = backend->device_name ();
+                       if (current_device == "") {
+                               // device might not have been set yet
+                               current_device = device_combo.get_active_text ();
+                               if (current_device == "")
+                                       // device has never been set, make sure it's not blank
+                                       current_device = available_devices.front ();
+                       }
+
                        PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
                        set_popdown_strings (device_combo, available_devices);
-                       device_combo.set_active_text (available_devices.front());
+
+                       device_combo.set_active_text (current_device);
                }
 
                device_changed ();
 
+               input_latency.set_sensitive (true);
+               output_latency.set_sensitive (true);
+               input_channels.set_sensitive (true);
+               output_channels.set_sensitive (true);
+
                ok_button->set_sensitive (true);
                apply_button->set_sensitive (true);
 
@@ -1294,7 +1332,7 @@ EngineControl::set_state (const XMLNode& root)
 
                        state->midi_devices.clear();
                        XMLNode* midinode;
-                       if ((midinode = find_named_node (*grandchild, "MIDIDevices")) != 0) {
+                       if ((midinode = ARDOUR::find_named_node (*grandchild, "MIDIDevices")) != 0) {
                                const XMLNodeList mnc = midinode->children();
                                for (XMLNodeList::const_iterator n = mnc.begin(); n != mnc.end(); ++n) {
                                        if ((*n)->property (X_("name")) == 0
@@ -1336,6 +1374,21 @@ EngineControl::set_state (const XMLNode& root)
 
        /* now see if there was an active state and switch the setup to it */
 
+       // purge states of backend that are not available in this built
+       vector<const ARDOUR::AudioBackendInfo*> backends = ARDOUR::AudioEngine::instance()->available_backends();
+       vector<std::string> backend_names;
+
+       for (vector<const ARDOUR::AudioBackendInfo*>::const_iterator i = backends.begin(); i != backends.end(); ++i) {
+               backend_names.push_back((*i)->name);
+       }
+       for (StateList::iterator i = states.begin(); i != states.end();) {
+               if (std::find(backend_names.begin(), backend_names.end(), (*i)->backend) == backend_names.end()) {
+                       i = states.erase(i);
+               } else {
+                       ++i;
+               }
+       }
+
        for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) {
 
                if ((*i)->active) {